Skip to content

Commit

Permalink
Merge pull request #71 from Crudzaso/feature/2004/role_organizer
Browse files Browse the repository at this point in the history
Feature/2004/role organizer
  • Loading branch information
alejandro-velasquez authored Nov 14, 2024
2 parents 96dfb2b + 67be595 commit ee4a34e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
7 changes: 5 additions & 2 deletions Modules/OrganizerPanel/routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@
|
*/

Route::group([], function () {
Route::middleware(['role:organizador'])->group(function () {
// Rutas del panel del organizador
Route::resource('organizerpanel', OrganizerPanelController::class)->names('organizerpanel');
Route::get('admin/panel', [OrganizerPanelController::class, 'index'])->name('organizer.dashboard');

// Rutas para rifas
Route::get('/admin/crear-rifa', [RaffleController::class, 'create'])->name('create');
Route::post('/admin/actualizar-rifa', [RaffleController::class, 'store'])->name('store');
Route::get('/admin/rifas', [RaffleController::class, 'index'])->name('index');
});
});
9 changes: 9 additions & 0 deletions app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,15 @@ public function storeOrganizer(Request $request)
'document_type' => $validated['document_type'] ?? $user->document_type,
'document_image_path' => $documentImagePath,
]);

$user->assignRole('organizador');

// Redirigir al panel de administración
return response()->json([
'success' => true,
'message' => 'Usuario registrado y rol asignado como organizador.',
]);

}

return response()->json([
Expand Down
8 changes: 4 additions & 4 deletions database/seeders/RolesPermissionsSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ class RolesPermissionsSeeder extends Seeder
public function run(): void
{
// Crear permisos
$permissions = ['view_rifas', 'create_rifas', 'edit_rifas', 'delete_rifas', 'manage_users'];
$permissions = ['view_rifas', 'create_rifas', 'edit_rifas', 'delete_rifas', 'manage_users','admin_panel'];
foreach ($permissions as $permission) {
Permission::firstOrCreate(['name' => $permission]);
}

// Crear roles y asignar permisos
$roles = [
'userPublic' => [],
'client' => ['view_rifas'],
'organizer' => ['view_rifas', 'create_rifas', 'edit_rifas', 'delete_rifas'],
'usuario_publico' => [],
'cliente' => ['view_rifas'],
'organizador' => ['view_rifas', 'create_rifas', 'edit_rifas', 'delete_rifas','admin_panel'],
'admin' => ['manage_users', 'view_rifas', 'create_rifas', 'edit_rifas', 'delete_rifas']
];

Expand Down

0 comments on commit ee4a34e

Please sign in to comment.