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:
Actually If you add the right controller, validate method should be already included. You can try adding below controller.
Instead:
use App\Http\Controllers\Controller;
lets add these two packages Best of luck
use Illuminate\Support\Facades\Validator; use Illuminate\Foundation\Auth\RegistersUsers;
Well means its no longer available in 5.4 however its available in controller
Try:
You can use the Validator service provider.
Hope this works for you..
In docs said:
This string - works :)