feat(allocation): implement resource allocation feature
- Add AllocationController with CRUD + bulk endpoints - Add AllocationValidationService for capacity/estimate validation - Add AllocationMatrixService for optimized matrix queries - Add AllocationPolicy for authorization - Add AllocationResource for API responses - Add frontend allocationService and matrix UI - Add E2E tests for allocation matrix (20 tests) - Add unit tests for validation service and policies - Fix month format conversion (YYYY-MM to YYYY-MM-01)
This commit is contained in:
49
backend/app/Policies/AllocationPolicy.php
Normal file
49
backend/app/Policies/AllocationPolicy.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Allocation;
|
||||
use App\Models\User;
|
||||
|
||||
class AllocationPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any allocations.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view a specific allocation.
|
||||
*/
|
||||
public function view(User $user, Allocation $allocation): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create allocations.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return in_array($user->role, ['superuser', 'manager']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update allocations.
|
||||
*/
|
||||
public function update(User $user, Allocation $allocation): bool
|
||||
{
|
||||
return in_array($user->role, ['superuser', 'manager']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete allocations.
|
||||
*/
|
||||
public function delete(User $user, Allocation $allocation): bool
|
||||
{
|
||||
return in_array($user->role, ['superuser', 'manager']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user