Initial commit

This commit is contained in:
2025-11-20 23:21:05 +08:00
commit 13bc6db529
378 changed files with 54527 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
<?php
namespace App\Console\Commands;
use App\Models\User;
use Illuminate\Console\Command;
use Spatie\Permission\Models\Role;
class AssignRole extends Command
{
protected $signature = 'roles:assign {email} {role}';
protected $description = 'Assign a role to a user by email';
public function handle(): int
{
$email = $this->argument('email');
$roleName = $this->argument('role');
$user = User::where('email', $email)->first();
if (! $user) {
$this->error("User not found for email {$email}");
return static::FAILURE;
}
$role = Role::firstOrCreate(['name' => $roleName, 'guard_name' => 'web']);
$user->assignRole($role);
$this->info("Assigned role {$roleName} to {$email}");
return static::SUCCESS;
}
}