Compare commits

...

2 Commits

Author SHA1 Message Date
shahrzad f50031393e feat: add enums and helper functions 2026-08-16 16:58:00 +03:30
shahrzad 497aa161a7 feat: add admin generator command 2026-08-16 16:56:43 +03:30
2 changed files with 62 additions and 0 deletions
@@ -0,0 +1,43 @@
<?php
namespace App\Console\Commands;
use App\Enums\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 = 'Create default admin user';
/**
* Execute the console command.
*/
public function handle()
{
Admin::create([
'full_name' => 'مدیر سیستم',
'username' => 'admin',
'email' => 'admin@gmail.com',
'mobile' => '09123456789',
'password' => Hash::make('123456789'),
'status' => AdminStatus::ENABLE,
]);
$this->info('Admin created successfully.');
}
}
+19
View File
@@ -0,0 +1,19 @@
<?php
function ActiveAdminSidebar(array $routes): string
{
$currentRouteName = Route::currentRouteName();
if (in_array($currentRouteName, $routes)) {
return 'active';
}
// برای مسیرهایی که پیشوند دارند (مثلاً admin.tours.*)
foreach ($routes as $route) {
if ($currentRouteName && str_starts_with($currentRouteName, $route . '.')) {
return 'active';
}
}
return '';
}