Reputation: 574
I generated my StorePostRequest using artisan make command.
I defined rules on the rules method doing this:
public function rules()
{
return [
'title' => 'required|min:3|max:255',
'slug' => ['required', Rule::unique('posts', 'slug')],
'thumbnail' =>'required|image',
'excerpt' => 'required|min:3',
'body' => 'required|min:3',
'category_id' => 'required|exists:categories,id'
];
}
However, in my PostController, I'm not able to get validated inputs except thumbnail
using the safe()->except('thumbnail')
like explained here
I'm getting the error
BadMethodCallException
Method App\Http\Requests\StorePostRequest::safe does not exist.
Upvotes: 1
Views: 2996
Reputation: 1346
Check your laravel/framework version by running
php artisan --version
The safe method found on the FormRequest class was only added in version 8.55.0
.
Just good to keep in mind that just because you're on a version 8 of laravel framework, that doesn't mean you'll have all methods and properties found in the laravel 8.x docs. That is unless you're on the current latest version 8 of course.
Upvotes: 4
Reputation: 574
Using the except()
method directly on $request
worked. Thanks to @JEJ for his help.
$request->except('thumbnail');
Upvotes: 3