Disable Laravel's Eloquent timestamps
You either have to declare public $timestamps = false;
in every model, or create a BaseModel, define it there, and have all your models extend it instead of eloquent. Just bare in mind pivot tables MUST have timestamps if you're using Eloquent.
Update: Note that timestamps are no longer REQUIRED in pivot tables after Laravel v3.
Update: You can also disable timestamps by removing $table->timestamps()
from your migration.
Simply place this line in your Model:
public $timestamps = false;
And that's it!
Example:
<?phpnamespace App;use Illuminate\Database\Eloquent\Model;class Post extends Model{ public $timestamps = false; //}
To disable timestamps for one operation (e.g. in a controller):
$post->content = 'Your content'; $post->timestamps = false; // Will not modify the timestamps on save$post->save();
To disable timestamps for all of your Models, create a new BaseModel
file:
<?phpnamespace App;use Illuminate\Database\Eloquent\Model;class BaseModel extends Model{ public $timestamps = false; //}
Then extend each one of your Models with the BaseModel
, like so:
<?phpnamespace App;class Post extends BaseModel{ //}