mercredi 13 janvier 2016

Laravel 5.2 - not show errors

It's impossible to show errors in views

here is my Controller:

public function create(){
        return view('articles.create');
    }

public function store(Request $request){
$this->validate($request, [
            'title' => 'required|max:5',
            'content' => 'required',
        ]);
}

this is my view create.blade.php:

        @if (count($errors) > 0)
        <!-- Form Error List -->
            <div class="alert alert-danger">
                <strong>Whoops!</strong> Something went wrong!.<br><br>
                <ul>
                    @foreach ($errors->all() as $error)
                        <li>{{ $error }}</li>
                    @endforeach
                </ul>
            </div>
        @endif

Kernel.php ShareErrorsFromSession already there

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

here is the route.php i have added the route in web

Route::group(['middleware' => ['web']], function () {
    Route::get('articles/create', 'ArticlesController@create'); // Display a form to create an article...
});
Route::get('articles', 'ArticlesController@index'); // Display all articles...
Route::post('articles', 'ArticlesController@store'); // Store a new article...
Route::get('articles/{id}', 'ArticlesController@show');



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire