Support the ongoing development of Laravel.io →
Blade Validation
Last updated 3 months ago.
0

By convention, $request->validate([]) will return the errors to the view. However you are assigning it to a variable ($validatedData) so laravel thinks that you are treating the data anyways.

Just remove the assigment of $validatedData and laravel will return it for you:

public function store(Request $request)

{
$request->validate([
'name' => 'required|max: 10',
'avatar' => 'required|image',
'slug' => 'required',
'description' => 'required',
]);
...
}
0

By convention, $request->validate([]) will return the errors to the view. However you are assigning it to a variable ($validatedData) so laravel thinks that you are treating the data anyways.

thanks but makes no difference, only refresh the view

Last updated 2 years ago.
0

try this

$this->validate($request, [ 'name' => 'required|max: 10', 'avatar' => 'required|image', 'slug' => 'required', 'description' => 'required', ]);

0

$this->validate($request, [ 'name' => 'required|max: 10', 'avatar' => 'required|image', 'slug' => 'required', 'description' => 'required', ]);

try this but return this error:

Symfony\Component\Debug\Exception\FatalThrowableError thrown with message "Argument 1 passed to LaraDex\Http\Controllers\Controller::validate() must be an instance of Illuminate\Http\Request, array given, called in /Users/jerefigueroa/.bitnami/stackman/machines/xampp/volumes/root/htdocs/laravel/cursoLaravel/app/Http/Controllers/TrainerController.php on line 63"

0

Please make sure that the form action is pertaining to the controller on which your store method is defined.

that's ok

0

can you please do {{ $errrors ? dd($errors) : null }}

And post here what you got

0

i got this

but this way:

@if ($errors->any())
        {{ $errors ? dd($errors) : null }}
        <div class="alert alert-danger">
            <ul>
                @foreach ($errors->all() as $message)
                <li>{{ $message }}</li>
                @endforeach
            </ul>
        </div>
    @endif

makes no difference, refresh the view

Last updated 2 years ago.
0

It's strange but solve the problem by changing local server. I used XAMPP and now I use MAMP and everything works perfect. If you are working locally with Laravel I recommend not using XAMPP.

1

Sign in to participate in this thread!

LoadForge

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2022 Laravel.io - All rights reserved.