feat: add admin generator command and enum role/status to admins table
This commit is contained in:
@@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Enums\Admin\AdminRole;
|
||||||
|
use App\Enums\Admin\AdminStatus;
|
||||||
|
use App\Models\Admin;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
|
||||||
|
class AdminGeneratorCommand extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'app:admin-generator';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Command description';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
Admin::create([
|
||||||
|
'first_name' => 'Admin',
|
||||||
|
'last_name' => 'admin',
|
||||||
|
'username' => 'admin1234',
|
||||||
|
'password' => Hash::make('123456789'),
|
||||||
|
'status' => AdminStatus::ACTIVE,
|
||||||
|
'role' => AdminRole::SUPERADMIN
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->info('Admin created successfully.');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enums\Admin;
|
||||||
|
|
||||||
|
enum AdminRole:int
|
||||||
|
{
|
||||||
|
case ADMIN = 0;
|
||||||
|
case SUPERADMIN = 1;
|
||||||
|
|
||||||
|
public function label(): string
|
||||||
|
{
|
||||||
|
return match($this) {
|
||||||
|
self::ADMIN => 'ادمین عادی',
|
||||||
|
self::SUPERADMIN => 'سوپر ادمین',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enums\Admin;
|
||||||
|
|
||||||
|
enum AdminStatus:int
|
||||||
|
{
|
||||||
|
case ACTIVE = 0;
|
||||||
|
case INACTIVE = 1;
|
||||||
|
|
||||||
|
public function label(): string
|
||||||
|
{
|
||||||
|
return match($this) {
|
||||||
|
self::ACTIVE => 'فعال',
|
||||||
|
self::INACTIVE => 'غیر فعال',
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user