Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
AuthorizesVengresoAdmin
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
1 / 1
 authorize
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3namespace App\Http\Requests\v2\Parameter\Concerns;
4
5use 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 */
13trait 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}