Reputation: 15
I'm Created Form Request,it doesn't work. But if I put validation in the controller it is work.
i think it happend after (php artisan make:auth). Because before that it was working properly.
//StorBlogPost :
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$rules = [
'name' => 'bail|required',
'camera' => 'bail|required|numeric',
'weight' => 'bail|required|numeric',
'price' => 'bail|required|numeric',
'barcode' => 'bail|required',
'production_at' => 'bail|required'
];
return $rules;
}
//controller :
public function store(StoreBlogPost $request)
{
$request->validate();
product::create($request->except('_token'));
}
error : "Too few arguments to function App\Http\Requests\StoreBlogPost::Illuminate\Foundation\Providers{closure}(), 0 passed and exactly 1 expected"
Upvotes: 1
Views: 1900
Reputation: 1006
You don't need to call $request->validate()
in your controller. Laravel calls this automatically.
Upvotes: 4