小众知识

Laravel:Unknown column 'updated_at'
2016-09-19 10:41:00   来源:   评论:0 点击:

Laravel使用默认model没有设置时间出现Unknown column updated_at 怎么解决

've just started with Laravel and I get this error: Unknown column 'updated_at' insert into gebruikers (naam, wachtwoord, updated_at, created_at) I know this updated_at thing is from the timestamp column when you migrate a table, but I'm not using the updated_at. I used to use it when I followed the Laravel tutorial but now that I am making(or attempting to make) my own stuff I get this error even though I dont use timestamps. I cant seem to find the place where it's being used. This is the code:

Controller:

public function created()
{
    if ( ! User::isValidRegister(Input::all()))
    {
        return Redirect::back()->withInput()->withErrors(User::$errors);
    }


        // Register the new user or whatever.
        $user = new User;
        $user->naam = Input::get('naam');
        $user->wachtwoord = Hash::make(Input::get('password'));
        $user->save();

        return Redirect::to('/users');  
}

The routing:

Route::get('created', 'UserController@created');

The model:

public static $rules_register = [
    'naam' => 'unique:gebruikers,naam'
 ];

public static $errors;
protected $table = 'gebruikers';

public static function isValidRegister($data)
    {
        $validation = Validator::make($data, static::$rules_register);

        if ($validation->passes())
        {
            return true;
        }
        static::$errors = $validation->messages();
        return false;
    }

I must be forgetting something... What am I doing wrong here?

 

In the model, write the below code;

public $timestamps = false;

This would work.

相关热词搜索:Laravel

上一篇:laravel 5 with omnipay composer update issue
下一篇:laravel数据迁移

分享到: 收藏
评论排行
最新发布