@@ 8-37 (lines=30) @@ | ||
5 | use Auth; |
|
6 | use Illuminate\Foundation\Http\FormRequest; |
|
7 | ||
8 | class LessonCreateRequest extends FormRequest |
|
9 | { |
|
10 | /** |
|
11 | * Determine if the user is authorized to make this request. |
|
12 | * |
|
13 | * @return bool |
|
14 | */ |
|
15 | public function authorize() |
|
16 | { |
|
17 | //recordar que s'ha de canviar cada cop |
|
18 | if (Auth::user()->can('add lessons')) { |
|
19 | return true; |
|
20 | } |
|
21 | return false; |
|
22 | } |
|
23 | ||
24 | /** |
|
25 | * Get the validation rules that apply to the request. |
|
26 | * |
|
27 | * @return array |
|
28 | */ |
|
29 | public function rules() |
|
30 | { |
|
31 | return [ |
|
32 | 'user_id' => 'nullable|integer', |
|
33 | 'location_id' => 'nullable|integer', |
|
34 | 'day_id' => 'nullable|integer', |
|
35 | 'timeslot_id' => 'nullable|integer', |
|
36 | 'classroom_id' => 'nullable|integer', |
|
37 | ]; |
|
38 | } |
|
39 | } |
|
40 |
@@ 8-37 (lines=30) @@ | ||
5 | use Auth; |
|
6 | use Illuminate\Foundation\Http\FormRequest; |
|
7 | ||
8 | class LessonUpdateRequest extends FormRequest |
|
9 | { |
|
10 | /** |
|
11 | * Determine if the user is authorized to make this request. |
|
12 | * |
|
13 | * @return bool |
|
14 | */ |
|
15 | public function authorize() |
|
16 | { |
|
17 | if (Auth::user()->can('edit lessons')) { |
|
18 | return true; |
|
19 | } |
|
20 | ||
21 | return false; |
|
22 | } |
|
23 | ||
24 | /** |
|
25 | * Get the validation rules that apply to the request. |
|
26 | * |
|
27 | * @return array |
|
28 | */ |
|
29 | public function rules() |
|
30 | { |
|
31 | return [ |
|
32 | 'user_id' => 'nullable|integer', |
|
33 | 'location_id' => 'nullable|integer', |
|
34 | 'day_id' => 'nullable|integer', |
|
35 | 'timeslot_id' => 'nullable|integer', |
|
36 | 'classroom_id' => 'nullable|integer', |
|
37 | ]; |
|
38 | } |
|
39 | } |
|
40 |