| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- namespace App\Http\Requests;
- use Illuminate\Foundation\Http\FormRequest;
- use Illuminate\Support\Facades\Session;
- class SaveProductRequest extends FormRequest
- {
- /**
- * Determine if the user is authorized to make this request.
- *
- * @return bool
- */
- public function authorize()
- {
- return (Session::get('user')['role'] == 1) ? true : false;
- // return true; // todo just admin can save it
- }
- /**
- * Get the validation rules that apply to the request.
- *
- * @return array<string, mixed>
- */
- public function rules()
- {
- return [
- 'id' => 'required',
- 'series' => 'required|string',
- 'name' => 'required|string',
- 'name_for_form' => 'required|string',
- 'product_group' => 'required|string',
- 'price' => 'required|numeric',
- 'characteristics' => 'required|string',
- 'tech_description' => 'required|string',
- 'tech_description_short' => 'required|string',
- ];
- }
- public function messages()
- {
- return [
- 'series.required' => 'Не может быть пустым',
- 'name.required' => 'Не может быть пустым',
- 'name_for_form.required' => 'Не может быть пустым',
- 'product_group.required' => 'Не может быть пустым',
- 'price.required' => 'Не может быть пустым',
- 'characteristics.required' => 'Не может быть пустым',
- 'tech_description.required' => 'Не может быть пустым',
- 'tech_description_short.required' => 'Не может быть пустым',
- ];
- }
- }
|