Edit File: Store.php
<?php namespace App\Http\Requests\Admin\Product; use Illuminate\Foundation\Http\FormRequest; class Store extends FormRequest { /** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { return true; } /** * Get the validation rules that apply to the request. * * @return array */ public function rules() { if ($this->getMethod() === 'PUT') { // 'nullable_if :discount_price,==,null|required|date|after:from' return [ 'image' => 'nullable|image' , 'name_ar' => 'required' , 'name_en' => 'required' , // 'price' => 'required|numeric|min:0' , // 'discount' => 'nullable|numeric|min:0|lt:price' , // 'discount_price' =>'nullable|required_with:from|gt:0|required_with:to|numeric|lt:price', // 'from' => 'nullable|required_with:discount_price|date|after:yesterday' , // 'to' => 'required_with:discount_price|date|after:from|nullable' , // 'in_stock_type' => 'required|in:out,in' , // 'in_stock_sku' => 'required|unique:product_groups,in_stock_sku,'.$this->group_one_id , // 'in_stock_qty' => 'required|gt:0' , 'type' => 'required' , 'available' => 'required|in:true,false' , 'desc_ar' => 'required' , 'desc_en' => 'required' , 'store_menu_category_id' => 'required|exists:store_menu_categories,id' , ]; }else{ return [ 'image' => 'required|image' , 'name_ar' => 'required' , 'name_en' => 'required' , // 'price' => 'required|numeric|gt:0' , // 'discount' => 'nullable|numeric|gt:0' , // 'discount_price' => 'nullable|required_with:from|gt:0|required_with:to|numeric|lt:price', // 'from' => 'nullable|required_with:discount_price|date|after:yesterday' , // 'to' => 'required_with:discount_price|date|after:from|nullable' , // 'in_stock_type' => 'required|in:out,in' , // 'in_stock_sku' => 'required|unique:product_groups,in_stock_sku' , // 'in_stock_qty' => 'required|gt:0' , 'type' => 'required' , 'available' => 'required|in:true,false' , 'desc_ar' => 'required' , 'desc_en' => 'required' , 'store_menu_category_id' => 'required|exists:store_menu_categories,id' , ]; } } public function messages(){ return [ 'from.after' => ' يجب على تاريخ البداية أن يكون تاريخًا لاحقًا لتاريخ الامس ', // 'in_stock_qty.gt' => trans('auth.in_stk_qty_gt'), 'price.gt' => trans('auth.price_gt'), 'discount_price.gt' => trans('auth.dis_prc_gt'), ]; } }
Back to File Manager