Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| AuthorizesVengresoAdmin | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
2.06 | |
0.00% |
0 / 1 |
| authorize | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
2.06 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Http\Requests\v2\Parameter\Concerns; |
| 4 | |
| 5 | use App\Http\Models\Auth\Role; |
| 6 | |
| 7 | /** |
| 8 | * Trait for authorizing requests to VENGRESO_ADMIN users only. |
| 9 | * |
| 10 | * This trait provides a shared authorization method for Parameter-related |
| 11 | * requests that should only be accessible to Vengreso administrators. |
| 12 | */ |
| 13 | trait AuthorizesVengresoAdmin |
| 14 | { |
| 15 | /** |
| 16 | * Determine if the user is authorized to make this request. |
| 17 | * |
| 18 | * Only users with the VENGRESO_ADMIN role can access parameter management. |
| 19 | */ |
| 20 | public function authorize(): bool |
| 21 | { |
| 22 | $user = $this->user(); |
| 23 | |
| 24 | if (! $user) { |
| 25 | return false; |
| 26 | } |
| 27 | |
| 28 | return in_array(Role::VENGRESO_ADMIN, $user->roles()); |
| 29 | } |
| 30 | } |