<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateMenusAndMenuItemsTables extends Migration {
    public function up(){
        Schema::create('menus', function(Blueprint $table){
            $table->id();
            $table->foreignId('restaurant_id')->constrained()->onDelete('cascade');
            $table->string('name');
            $table->text('description')->nullable();
            $table->timestamps();
        });

        Schema::create('menu_items', function(Blueprint $table){
            $table->id();
            $table->foreignId('restaurant_id')->constrained()->onDelete('cascade');
            $table->foreignId('menu_id')->nullable()->constrained('menus')->onDelete('set null');
            $table->string('name');
            $table->text('description')->nullable();
            $table->integer('price');
            $table->boolean('is_veg')->default(false);
            $table->string('image')->nullable();
            $table->boolean('is_available')->default(true);
            $table->timestamps();
        });
    }
    public function down(){
        Schema::dropIfExists('menu_items');
        Schema::dropIfExists('menus');
    }
}
