| @@ 8-64 (lines=57) @@ | ||
| 5 | use App\Http\Requests\Request; |
|
| 6 | use Illuminate\Validation\Rule; |
|
| 7 | ||
| 8 | class DocumentRequest extends \Backpack\CRUD\app\Http\Requests\CrudRequest |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * Determine if the user is authorized to make this request. |
|
| 12 | * |
|
| 13 | * @return bool |
|
| 14 | */ |
|
| 15 | public function authorize() |
|
| 16 | { |
|
| 17 | // only allow updates if the user is logged in |
|
| 18 | return \Auth::check(); |
|
| 19 | } |
|
| 20 | ||
| 21 | /** |
|
| 22 | * Get the validation rules that apply to the request. |
|
| 23 | * |
|
| 24 | * @return array |
|
| 25 | */ |
|
| 26 | public function rules() |
|
| 27 | { |
|
| 28 | return [ |
|
| 29 | 'type' => [ |
|
| 30 | 'required', |
|
| 31 | Rule::in(config('webfactor.documents.types')), |
|
| 32 | Rule::unique('documents') |
|
| 33 | ], |
|
| 34 | 'title' => 'required|min:5|max:255', |
|
| 35 | 'body' => 'required|string' |
|
| 36 | ]; |
|
| 37 | } |
|
| 38 | ||
| 39 | /** |
|
| 40 | * Get the validation attributes that apply to the request. |
|
| 41 | * |
|
| 42 | * @return array |
|
| 43 | */ |
|
| 44 | public function attributes() |
|
| 45 | { |
|
| 46 | return [ |
|
| 47 | 'type' => trans('webfactor::documents.type'), |
|
| 48 | 'title' => trans('webfactor::documents.title'), |
|
| 49 | 'body' => trans('webfactor::documents.body') |
|
| 50 | ]; |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * Get the validation messages that apply to the request. |
|
| 55 | * |
|
| 56 | * @return array |
|
| 57 | */ |
|
| 58 | public function messages() |
|
| 59 | { |
|
| 60 | return [ |
|
| 61 | // |
|
| 62 | ]; |
|
| 63 | } |
|
| 64 | } |
|
| 65 | ||
| @@ 8-64 (lines=57) @@ | ||
| 5 | use App\Http\Requests\Request; |
|
| 6 | use Illuminate\Validation\Rule; |
|
| 7 | ||
| 8 | class DocumentUpdateRequest extends \Backpack\CRUD\app\Http\Requests\CrudRequest |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * Determine if the user is authorized to make this request. |
|
| 12 | * |
|
| 13 | * @return bool |
|
| 14 | */ |
|
| 15 | public function authorize() |
|
| 16 | { |
|
| 17 | // only allow updates if the user is logged in |
|
| 18 | return \Auth::check(); |
|
| 19 | } |
|
| 20 | ||
| 21 | /** |
|
| 22 | * Get the validation rules that apply to the request. |
|
| 23 | * |
|
| 24 | * @return array |
|
| 25 | */ |
|
| 26 | public function rules() |
|
| 27 | { |
|
| 28 | return [ |
|
| 29 | 'type' => [ |
|
| 30 | 'required', |
|
| 31 | Rule::in(config('webfactor.documents.types')), |
|
| 32 | Rule::unique('documents')->ignore($this->id) |
|
| 33 | ], |
|
| 34 | 'title' => 'required|min:5|max:255', |
|
| 35 | 'body' => 'required|string' |
|
| 36 | ]; |
|
| 37 | } |
|
| 38 | ||
| 39 | /** |
|
| 40 | * Get the validation attributes that apply to the request. |
|
| 41 | * |
|
| 42 | * @return array |
|
| 43 | */ |
|
| 44 | public function attributes() |
|
| 45 | { |
|
| 46 | return [ |
|
| 47 | 'type' => trans('webfactor::documents.type'), |
|
| 48 | 'title' => trans('webfactor::documents.title'), |
|
| 49 | 'body' => trans('webfactor::documents.body') |
|
| 50 | ]; |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * Get the validation messages that apply to the request. |
|
| 55 | * |
|
| 56 | * @return array |
|
| 57 | */ |
|
| 58 | public function messages() |
|
| 59 | { |
|
| 60 | return [ |
|
| 61 | // |
|
| 62 | ]; |
|
| 63 | } |
|
| 64 | } |
|
| 65 | ||