SaveProductRequest.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace App\Http\Requests;
  3. use Illuminate\Foundation\Http\FormRequest;
  4. use Illuminate\Support\Facades\Session;
  5. class SaveProductRequest extends FormRequest
  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 (Session::get('user')['role'] == 1) ? true : false;
  15. // return true; // todo just admin can save it
  16. }
  17. /**
  18. * Get the validation rules that apply to the request.
  19. *
  20. * @return array<string, mixed>
  21. */
  22. public function rules()
  23. {
  24. return [
  25. 'id' => 'required',
  26. 'series' => 'required|string',
  27. 'name' => 'required|string',
  28. 'name_for_form' => 'required|string',
  29. 'product_group' => 'required|string',
  30. 'price' => 'required|numeric',
  31. 'characteristics' => 'required|string',
  32. 'tech_description' => 'required|string',
  33. 'tech_description_short' => 'required|string',
  34. ];
  35. }
  36. public function messages()
  37. {
  38. return [
  39. 'series.required' => 'Не может быть пустым',
  40. 'name.required' => 'Не может быть пустым',
  41. 'name_for_form.required' => 'Не может быть пустым',
  42. 'product_group.required' => 'Не может быть пустым',
  43. 'price.required' => 'Не может быть пустым',
  44. 'characteristics.required' => 'Не может быть пустым',
  45. 'tech_description.required' => 'Не может быть пустым',
  46. 'tech_description_short.required' => 'Не может быть пустым',
  47. ];
  48. }
  49. }