<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use App\Models\Product;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('products', function (Blueprint $table) {
            $table->id();
            $table->foreignId('category_id')->constrained()->cascadeOnDelete()->cascadeOnUpdate();
            $table->string('name');
            $table->integer('count')->default(10);
            $table->float('price');
            $table->string('photo');
            $table->timestamps();
        });
        Product::create([
            'category_id' => 1,
            'name' => 'Шаурма с курицей',
            'count' => 10,
            'price' => 150,
            'photo' => "products/shau1.jpg",
        ]);
        Product::create([
            'category_id' => 2,
            'name' => 'Шашлык с курицей',
            'count' => 10,
            'price' => 350,
            'photo' => "products/shash1.jpg",
        ]);
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('products');
    }
};
