app/Http/Requests/ProductRequest.php
/**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
Get the validation rules that apply to the request.
@return array
Get the validation rules that apply to the request . @return array
public function rules()
    {
        switch ($this->method()) {
            case 'GET':
            case 'DELETE':
                return [];
            case 'POST': {
                return [
                    'name' => 'required|min:5',
                    'description' => 'required|min:30',
                    'price' => 'required',
                    'image' => 'required|image|mimes:jpg,jpeg,png',
                ];
            }
            case 'PUT': {
                return [
                    'name' => 'required|min:5',
                    'description' => 'required|min:30',
                    'price' => 'required',
                    'image' => 'sometimes|image|mimes:jpg,jpeg,png',
                ];
            }
        }
    }
public function rules ( ) { switch ( $ this -> method ( ) ) { case 'GET' : case 'DELETE' : return [ ] ; case 'POST' : { return [ 'name' => 'required|min:5' , 'description' => 'required|min:30' , 'price' => 'required' , 'image' => 'required|image|mimes:jpg,jpeg,png' , ] ; } case 'PUT' : { return [ 'name' => 'required|min:5' , 'description' => 'required|min:30' , 'price' => 'required' , 'image' => 'sometimes|image|mimes:jpg,jpeg,png' , ] ; } } }
Get the validation rules that apply to the request.
Get the validation rules that apply to the request .