| @@ 5-35 (lines=31) @@ | ||
| 2 | ||
| 3 | namespace Yajra\CMS\Http\Requests; |
|
| 4 | ||
| 5 | class ArticlesFormRequest extends Request |
|
| 6 | { |
|
| 7 | /** |
|
| 8 | * Determine if the user is authorized to make this request. |
|
| 9 | * |
|
| 10 | * @return bool |
|
| 11 | */ |
|
| 12 | public function authorize() |
|
| 13 | { |
|
| 14 | return $this->authorizeResource('article'); |
|
| 15 | } |
|
| 16 | ||
| 17 | /** |
|
| 18 | * Get the validation rules that apply to the request. |
|
| 19 | * |
|
| 20 | * @return array |
|
| 21 | */ |
|
| 22 | public function rules() |
|
| 23 | { |
|
| 24 | $required = $this->isEditing('article') ? 'required|' : 'nullable|'; |
|
| 25 | ||
| 26 | return [ |
|
| 27 | 'title' => 'required|max:255', |
|
| 28 | 'alias' => $required . 'max:255|alpha_dash', |
|
| 29 | 'order' => 'required|numeric', |
|
| 30 | 'blade_template' => 'nullable|view_exists', |
|
| 31 | 'body' => 'required_without:blade_template', |
|
| 32 | 'category_id' => 'required', |
|
| 33 | ]; |
|
| 34 | } |
|
| 35 | } |
|
| 36 | ||
| @@ 5-36 (lines=32) @@ | ||
| 2 | ||
| 3 | namespace Yajra\CMS\Http\Requests; |
|
| 4 | ||
| 5 | class WidgetFormRequest extends Request |
|
| 6 | { |
|
| 7 | /** |
|
| 8 | * Determine if the user is authorized to make this request. |
|
| 9 | * |
|
| 10 | * @return bool |
|
| 11 | */ |
|
| 12 | public function authorize() |
|
| 13 | { |
|
| 14 | return $this->authorizeResource('widget'); |
|
| 15 | } |
|
| 16 | ||
| 17 | /** |
|
| 18 | * Get the validation rules that apply to the request. |
|
| 19 | * |
|
| 20 | * @return array |
|
| 21 | */ |
|
| 22 | public function rules() |
|
| 23 | { |
|
| 24 | $required = $this->isEditing('widget') ? 'required|' : 'nullable|'; |
|
| 25 | ||
| 26 | return [ |
|
| 27 | 'title' => 'required|max:255', |
|
| 28 | 'extension_id' => 'required|exists:extensions,id', |
|
| 29 | 'template' => 'required', |
|
| 30 | 'custom_template' => $required . 'required_if:template,custom|view_exists', |
|
| 31 | 'parameter' => 'required_if:type,menu', |
|
| 32 | 'position' => 'required', |
|
| 33 | 'order' => 'required|numeric', |
|
| 34 | ]; |
|
| 35 | } |
|
| 36 | } |
|
| 37 | ||