Displaying the Error Messages in Laravel after being Redirected from controller

后端 未结 9 1134
情书的邮戳
情书的邮戳 2020-12-13 01:44

How can I display the validation message in the view that is being redirected in Laravel ?

Here is my function in a Controller

publi         


        
9条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-13 02:14

    Move all that in kernel.php if just the above method didn't work for you remember you have to move all those lines in kernel.php in addition to the above solution

    let me first display the way it is there in the file already..

    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',
        ],
    ];
    

    now what you have to do is

    protected $middleware = [
        \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
         \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,
    ];
    
    /**
     * The application's route middleware groups.
     *
     * @var array
     */
    protected $middlewareGroups = [
        'web' => [
    
        ],
    
        'api' => [
            'throttle:60,1',
        ],
    ];
    

    i.e.;

提交回复
热议问题