Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Method validate does not exist - Laravel 5.4

I have a very weird problem. When I'm submitting the form, it throws an error with server-side validation.

Here is my simple controller:

namespace App\Http\Controllers;  use Newsletter; use Illuminate\Http\Request;  class SubscriptionController extends Controller {     public function subscribe(Request $request)     {         $request->validate([             'email' => 'required|email',             ]);     } } 

Submitting the form gives me:

BadMethodCallException Method validate does not exist.

it should work according to:

https://laravel.com/docs/5.4/validation

like image 896
Parth Vora Avatar asked Aug 21 '17 11:08

Parth Vora


Video Answer


1 Answers

In docs said:

$this->validate($request, [     'email' => 'required|email', ]); 

This string - works :)

like image 180
arku Avatar answered Sep 18 '22 12:09

arku