Loko Loko - 1 year ago 166
MySQL Question

Laravel:Unknown column 'updated_at'

I'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:


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'));

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?

Answer Source

In the model, write the below code;

public $timestamps = false;

This would work.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download