init commit

This commit is contained in:
unurled 2025-06-23 23:12:40 +02:00
commit c9d982669a
461 changed files with 30317 additions and 0 deletions

View file

@ -0,0 +1,51 @@
<?php
namespace App\Console\Commands;
use App\Models\User;
use Illuminate\Console\Command;
class MakeAdmin extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:make-admin {email : The email address of the user to make admin}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Makes someone an admin based on their email address';
/**
* Execute the console command.
*/
public function handle()
{
$email = $this->argument('email');
// Find the user by email
$user = User::where('email', $email)->first();
if (!$user) {
$this->error("User with email {$email} not found.");
return 1;
}
// Check if user is already an admin
if ($user->hasRole('admin')) {
$this->info("User {$email} is already an admin.");
return 0;
}
// Assign admin role
$user->assignRole('admin');
$this->info("User {$email} has been made an admin successfully.");
return 0;
}
}