doujiao2000 2015-02-02 12:38
浏览 202
已采纳

Laravel未知专栏'updated_at'

I've just started with Laravel and I get the following error:

Unknown column 'updated_at' insert into gebruikers (naam, wachtwoord, updated_at, created_at)

I know the error is from the timestamp column when you migrate a table but I'm not using the updated_at field. 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 don't use timestamps. I can't 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');
}

Route

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

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?

  • 写回答

4条回答 默认 最新

  • douxi8119 2015-02-02 12:40
    关注

    In the model, write the below code;

    public $timestamps = false;
    

    This would work.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 武汉岩海低应变分析软件,导数据库里不显示波形图
  • ¥15 CreateBitmapFromWicBitmap内存释放问题。
  • ¥30 win c++ socket
  • ¥15 CanMv K210开发板实现功能
  • ¥15 C# datagridview 栏位进度
  • ¥15 vue3页面el-table页面数据过多
  • ¥100 vue3中融入gRPC-web
  • ¥15 kali环境运行volatility分析android内存文件,缺profile
  • ¥15 写uniapp时遇到的问题
  • ¥15 vs 2008 安装遇到问题