Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
85.71% |
6 / 7 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| UpdateDeveloperModeRequest | |
85.71% |
6 / 7 |
|
50.00% |
1 / 2 |
3.03 | |
0.00% |
0 / 1 |
| authorize | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
2.06 | |||
| rules | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Http\Requests\v2\User; |
| 4 | |
| 5 | use App\Http\Models\Auth\Role; |
| 6 | use Illuminate\Foundation\Http\FormRequest; |
| 7 | |
| 8 | /** |
| 9 | * Request for updating a user's developer_mode flag (VENGRESO_ADMIN only). |
| 10 | * |
| 11 | * When developer mode is enabled for a user, the meta-data endpoint will |
| 12 | * return a `developer_mode: true` flag that the client uses to override |
| 13 | * global remote configuration. |
| 14 | * |
| 15 | * @property bool $developer_mode Whether to enable or disable developer mode for the user |
| 16 | */ |
| 17 | class UpdateDeveloperModeRequest extends FormRequest |
| 18 | { |
| 19 | /** |
| 20 | * Determine if the user is authorized to make this request. |
| 21 | * |
| 22 | * Only users with the VENGRESO_ADMIN role can update the developer_mode flag. |
| 23 | */ |
| 24 | public function authorize(): bool |
| 25 | { |
| 26 | $user = $this->user(); |
| 27 | |
| 28 | if (! $user) { |
| 29 | return false; |
| 30 | } |
| 31 | |
| 32 | return in_array(Role::VENGRESO_ADMIN, $user->roles()); |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Get the validation rules that apply to the request. |
| 37 | * |
| 38 | * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string> |
| 39 | */ |
| 40 | public function rules(): array |
| 41 | { |
| 42 | return [ |
| 43 | 'developer_mode' => 'required|boolean', |
| 44 | ]; |
| 45 | } |
| 46 | } |