Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
UpdateInAppNotificationStatusRequest
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
3 / 3
3
100.00% covered (success)
100.00%
1 / 1
 authorize
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 rules
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 messages
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace App\Http\Requests\v2\InAppNotification;
4
5use App\Enums\InAppNotificationStatus;
6use Illuminate\Foundation\Http\FormRequest;
7use Illuminate\Validation\Rule;
8
9/**
10 * Request for updating an in-app notification's status.
11 *
12 * @property string $status The new status (viewed, clicked, dismissed)
13 */
14class UpdateInAppNotificationStatusRequest extends FormRequest
15{
16    /**
17     * Determine if the user is authorized to make this request.
18     */
19    public function authorize(): bool
20    {
21        return $this->user() !== null;
22    }
23
24    /**
25     * Get the validation rules that apply to the request.
26     *
27     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
28     */
29    public function rules(): array
30    {
31        return [
32            'status' => ['required', 'string', Rule::in(InAppNotificationStatus::userSettable())],
33        ];
34    }
35
36    /**
37     * Get custom messages for validator errors.
38     *
39     * @return array<string, string>
40     */
41    public function messages(): array
42    {
43        return [
44            'status.in' => 'The status must be one of: '.implode(', ', InAppNotificationStatus::userSettable()),
45        ];
46    }
47}