ProductRequest.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace App\Http\Requests;
  3. use Illuminate\Foundation\Http\FormRequest;
  4. class ProductRequest extends FormRequest
  5. {
  6. /**
  7. * Determine if the user is authorized to make this request.
  8. *
  9. * @return bool
  10. */
  11. public function authorize()
  12. {
  13. return true;
  14. }
  15. /**
  16. * Get the validation rules that apply to the request.
  17. *
  18. * @return array
  19. */
  20. public function rules()
  21. {
  22. return [
  23. 'name' => 'required|max:255',
  24. 'category_id' => 'required',
  25. 'unit' => 'required',
  26. 'min_qty' => 'required|numeric',
  27. 'unit_price' => 'required|numeric',
  28. 'discount' => 'required|numeric',
  29. 'current_stock' => 'required|numeric',
  30. ];
  31. }
  32. /**
  33. * Get the validation messages of rules that apply to the request.
  34. *
  35. * @return array
  36. */
  37. public function messages()
  38. {
  39. return [
  40. 'name.required' => 'Product name is required',
  41. 'category_id.required' => 'Category is required',
  42. 'unit.required' => 'Unit field is required',
  43. 'min_qty.required' => 'Minimum purchase quantity is required',
  44. 'min_qty.numeric' => 'Minimum purchase must be numeric',
  45. 'unit_price.required' => 'Unit price is required',
  46. 'unit_price.numeric' => 'Unit price must be numeric',
  47. 'discount.required' => 'Discount is required',
  48. 'discount.numeric' => 'Discount must be numeric',
  49. 'current_stock.required' => 'Current stock is required',
  50. 'current_stock.numeric' => 'Current stock must be numeric',
  51. ];
  52. }
  53. }