/ database / migrations / 2021_07_08_083446_create_entity_user_pivot_table.php
2021_07_08_083446_create_entity_user_pivot_table.php
 1  <?php
 2  
 3  use App\Models\User;
 4  use Illuminate\Database\Migrations\Migration;
 5  use Illuminate\Database\Schema\Blueprint;
 6  use Illuminate\Support\Facades\Schema;
 7  use Spatie\Permission\Models\Role;
 8  
 9  return new class extends Migration
10  {
11      /**
12       * Run the migrations.
13       *
14       * @return void
15       */
16      public function up()
17      {
18          Schema::create('entity_user', function (Blueprint $table) {
19              $table->id();
20              $table->foreignIdFor(User::class);
21              $table->morphs('entity');
22              $table->foreignIdFor(Role::class);
23              $table->boolean('is_default')->default(false);
24              $table->boolean('is_external')->default(false);
25              $table->boolean('is_poc')->default(false);
26              $table->timestamps();
27          });
28      }
29  
30      /**
31       * Reverse the migrations.
32       *
33       * @return void
34       */
35      public function down()
36      {
37          Schema::dropIfExists('entity_user');
38      }
39  };