first commit
This commit is contained in:
43
Console/Commands/CleanInitialAvatars.php
Normal file
43
Console/Commands/CleanInitialAvatars.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Koneko\VuexyAdmin\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class CleanInitialAvatars extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'avatars:clean-initial';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Elimina avatares generados automáticamente en el directorio initial-avatars';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$directory = 'initial-avatars';
|
||||
$files = Storage::disk('public')->files($directory);
|
||||
|
||||
foreach ($files as $file) {
|
||||
$lastModified = Storage::disk('public')->lastModified($file);
|
||||
|
||||
// Elimina archivos no accedidos en los últimos 30 días
|
||||
if (now()->timestamp - $lastModified > 30 * 24 * 60 * 60) {
|
||||
Storage::disk('public')->delete($file);
|
||||
}
|
||||
}
|
||||
|
||||
$this->info('Avatares iniciales antiguos eliminados.');
|
||||
}
|
||||
}
|
26
Console/Commands/SyncRBAC.php
Normal file
26
Console/Commands/SyncRBAC.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Koneko\VuexyAdmin\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Koneko\VuexyAdmin\Services\RBACService;
|
||||
|
||||
class SyncRBAC extends Command
|
||||
{
|
||||
protected $signature = 'rbac:sync {action}';
|
||||
protected $description = 'Sincroniza roles y permisos con archivos JSON';
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$action = $this->argument('action');
|
||||
if ($action === 'import') {
|
||||
RBACService::loadRolesAndPermissions();
|
||||
$this->info('Roles y permisos importados correctamente.');
|
||||
} elseif ($action === 'export') {
|
||||
// Implementación para exportar los roles a JSON
|
||||
$this->info('Exportación de roles y permisos completada.');
|
||||
} else {
|
||||
$this->error('Acción no válida. Usa "import" o "export".');
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user