Carga inicial

This commit is contained in:
IvanAS94
2025-12-26 17:21:11 -08:00
parent 45d9afc951
commit 51880798ca
359 changed files with 42159 additions and 1 deletions

View File

@@ -0,0 +1,76 @@
<?php
namespace App\Console\Commands;
use App\Models\Rol;
use Cartalyst\Sentinel\Native\Facades\Sentinel;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Route;
use Log;
class RolePermissions extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'permisos';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Actualiza permisos del root';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$roles = Rol::select('name')->orderBy('id')->get();
$procesos = array('Salir');
foreach ($roles as $r){
array_push($procesos, $r->name);
}
$proceso = $this->choice('Proceso ?', $procesos, 0);
if($proceso == 'Salir'){
$this->info('BYE :)');
dd();
}
$rolName = $proceso;
$this->info('Actualizando permisos para: ' . $rolName);
$role = Sentinel::findRoleByName($rolName);
$permisos = [];
$routeCollection = Route::getRoutes();
foreach ($routeCollection as $value) {
if($value->getName()!=""){
$permisos[$value->getName()] = true;
}
}
$role->permissions = $permisos;
$role->save();
$this->info('Permisos actualizados para rol: ' . $rolName);
}
}

40
app/Console/Kernel.php Normal file
View File

@@ -0,0 +1,40 @@
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
Commands\RolePermissions::class
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')
// ->hourly();
}
/**
* Register the Closure based commands for the application.
*
* @return void
*/
protected function commands()
{
require base_path('routes/console.php');
}
}