make(Illuminate\Contracts\Console\Kernel::class); $kernel->bootstrap(); $u = \App\Models\User::where('email', 'admin@example.com')->first(); if ($u) { $role = \Spatie\Permission\Models\Role::firstOrCreate(['name' => 'admin']); $u->assignRole($role); echo "Assigned 'admin' role to admin@example.com successfully!" . PHP_EOL; } else { echo "User admin@example.com not found." . PHP_EOL; }