Support the ongoing development of Laravel.io →
Authentication Validation

Im sorry if I am new to Laravel 5.2, but I get empty string in $errors even though if I use duplicate entry or purposely token mismatch it.

Here is the full code: http://laravel.io/bin/429WD - Routes.php http://laravel.io/bin/nQMNd - create.blade.php http://laravel.io/bin/JxK4v - TodoListController.php

TodoListController.php

public function store()
    {

        // define rules
        $rules = array(
            'title' => array('required', 'unique:todo_lists,name')
        );

        // pass input to rules (validator)
        $validator = Validator::make(Input::all(), $rules);

        // test if input is valid
        if ($validator->fails()){
            return Redirect::route('todos.create')->withError($validator, 'error');
        }

        $name = \Input::get('title');
        $list = new TodoList();
        $list -> name = $name;
        $list -> save();
        return Redirect::route('todos.index');

    }

routes.php

Route::group(['middleware' => ['web']], function () {
    Route::get('/db', function(){
        $result = DB::table('todo_lists')->where('name', 'Your Name')->first();
        return $result->name;
    });
    Route::get('/', 'TodoListController@index' );
    Route::resource('todos', 'TodoListController' );
});

create.blade.php

{{ var_dump($errors) }}
Last updated 3 years ago.
0

nvm i got it, simple typo. withError to withErrors..

0

Sign in to participate in this thread!

Eventy

Your banner here too?

adeptgrim adeptgrim Joined 12 Mar 2016

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.