feat: Initialize core application structure including authentication, role-based dashboards, service task management, and integration workflows.

This commit is contained in:
jeremy bayse
2026-02-16 09:30:23 +01:00
commit af060a8847
208 changed files with 26822 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
<?php
namespace App\Policies;
use App\Models\IntegrationRequest;
use App\Models\User;
use Illuminate\Auth\Access\Response;
class IntegrationRequestPolicy
{
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->hasAnyRole(['Admin', 'RH', 'DSI', 'Batiment', 'ParcAuto']);
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, IntegrationRequest $integrationRequest): bool
{
if ($user->hasRole('Admin') || $user->hasRole('RH')) {
return true;
}
// Check if user belongs to a service that has a task in this request
return $integrationRequest->serviceTasks()
->whereIn('service_id', $user->roles()->where('name', '!=', 'Prescripteur')->pluck('id'))
->exists();
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->hasAnyRole(['Admin', 'RH', 'Prescripteur', 'DSI', 'Batiment', 'ParcAuto']);
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, IntegrationRequest $integrationRequest): bool
{
return $user->hasAnyRole(['Admin', 'RH']);
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, IntegrationRequest $integrationRequest): bool
{
return $user->hasRole('Admin');
}
}