I have a request class that validates if the input has only alphabets. This is working fine no problem.
Validation works because Kernel.php file looks like below.
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
];
/**
* The application's route middleware groups.
*
* @var array
*/
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
],
'api' => [
'throttle:60,1',
],
];
Validation DOES NOT work if Kernel .php file looks like below.
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
];
/**
* The application's route middleware groups.
*
* @var array
*/
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
],
'api' => [
'throttle:60,1',
],
];
My very simple route file is below
Route::group(['middleware' => ['web']], function () {
Route::get('/Sports-Types', 'SportsTypeController@index');
Route::get('/Create-Sports-Type', 'SportsTypeController@create');
Route::post('/SaveSportsType', 'SportsTypeController@store');
Route::put('/UpdateSportsType', 'SportsTypeController@update');
Route::get('/SportsType/{SportsTypeID}', 'SportsTypeController@edit');
});
What's the confusion and Question
As we can see above, we have Route group with web Middleware. Why the validation is not working when Web middleware does not have following class in Kernel file.
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
Can somebody guide me in right direction?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire