fanatic/database/migrations/10_create_categories_table.php
2022-04-23 16:25:16 -07:00

37 lines
753 B
PHP

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('categories', function (Blueprint $table) {
$table->id();
$table->timestamps();
$table->foreignId('parent_id')
->nullable()
->constrained('categories')
->onUpdate('cascade')
->onDelete('cascade');
$table->string('name');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('categories');
}
};