create menu migration, seeder and model
This commit is contained in:
46
database/migrations/2022_07_15_192421_create_menus_table.php
Normal file
46
database/migrations/2022_07_15_192421_create_menus_table.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?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('menus', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('parent_id')
|
||||
->nullable()
|
||||
->default(null);
|
||||
$table->string('name');
|
||||
$table->string('icon')
|
||||
->default('circle');
|
||||
$table->string('route_or_url')->default('#');
|
||||
$table->unsignedTinyInteger('position');
|
||||
$table->boolean('enable')->default(true);
|
||||
$table->boolean('deleteable')->default(true);
|
||||
$table->json('actives')->default('[]');
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('parent_id')
|
||||
->references('id')
|
||||
->on('menus');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('menus');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
<?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('menu_permission', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('menu_id')
|
||||
->constrained()
|
||||
->cascadeOnDelete();
|
||||
$table->foreignId('permission_id')
|
||||
->constrained()
|
||||
->cascadeOnDelete();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('menu_permission');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user