Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 12 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| StoreServiceRequest | |
0.00% |
0 / 12 |
|
0.00% |
0 / 4 |
20 | |
0.00% |
0 / 1 |
| authorize | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| prepareForValidation | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| rules | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| attributes | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Http\Requests\Bo\Services; |
| 4 | |
| 5 | use Illuminate\Foundation\Http\FormRequest; |
| 6 | |
| 7 | class StoreServiceRequest extends FormRequest |
| 8 | { |
| 9 | /** |
| 10 | * Determine if the user is authorized to make this request. |
| 11 | * |
| 12 | * @return boolean |
| 13 | */ |
| 14 | public function authorize(): bool |
| 15 | { |
| 16 | return auth('backend')->check(); |
| 17 | } |
| 18 | |
| 19 | /** |
| 20 | * Prepare the data for validation. |
| 21 | * |
| 22 | * @return void |
| 23 | */ |
| 24 | protected function prepareForValidation(): void |
| 25 | { |
| 26 | $this->merge([ |
| 27 | 'brand_id' => collect($this->brand)->pluck('id')->first() |
| 28 | ]); |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Get the validation rules that apply to the request. |
| 33 | * |
| 34 | * @return array |
| 35 | */ |
| 36 | public function rules(): array |
| 37 | { |
| 38 | return [ |
| 39 | 'name' => 'required|string|min:5|max:255', |
| 40 | 'brand_id' => 'required|integer|min:0|exists:brands,id', |
| 41 | ]; |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Get custom attributes for validator errors. |
| 46 | * |
| 47 | * @return array |
| 48 | */ |
| 49 | public function attributes(): array |
| 50 | { |
| 51 | return [ |
| 52 | 'name' => trans('Nom du service'), |
| 53 | 'brand_id' => trans('Id de la marque'), |
| 54 | ]; |
| 55 | } |
| 56 | } |