Support the ongoing development of Laravel.io →
Database Eloquent

Long story short. I created a migration named "create_music_table" which have following field increments('id'),string('title',70),string('url',255) and whenever i tried to insert a new record using ORM

		$music = new Music;
	$music->title = "Monster";
	$music->url = "aksjdaskldjsakldas";
	$music->singer = "Emenim ft Rihannah";
	$music->save();

its hitting this message

Illuminate \ Database \ QueryException
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'updated_at' in 'field list' (SQL: insert into `music`          (`title`, `url`, `singer`, `updated_at`, `created_at`) values (Monster, aksjdaskldjsakldas, Emenim ft Rihannah, 2014-03-30 17:28:35, 2014-03-30 17:28:35))

are you kiddding me?

Last updated 2 years ago.
0

well, you should have a look here: http://laravel.com/docs/eloquent#timestamps and here http://laravel.com/docs/schema

long storry short. -> In your model (Music), add the following somewhere near the top

 public $timestamps = false;

OR in your migration, add

$table->timestamps();

and rerun the migration

Last updated 2 years ago.
0

So did you read the docs? http://laravel.com/docs/eloquent

Once a model is defined, you are ready to start retrieving and creating records in your table. Note that you will need to place updated_at and created_at columns on your table by default. If you do not wish to have these columns automatically maintained, set the $timestamps property on your model to false.

If you want timestamp, just add $table->timestamps(); to your migration.

Last updated 2 years ago.
0

Oh. Now i feel stupid!

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

d1p d1p Joined 28 Mar 2014

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.