Recall & Review
beginner
What are timestamps in Laravel Eloquent models?
Timestamps are special columns named
created_at and updated_at that Laravel automatically manages to record when a record is created and last updated.Click to reveal answer
beginner
How do you disable automatic timestamps in a Laravel model?
Set the public property <code>public $timestamps = false;</code> inside the model class to stop Laravel from automatically updating <code>created_at</code> and <code>updated_at</code>.Click to reveal answer
beginner
Which Laravel migration method adds
created_at and updated_at columns?The
$table->timestamps(); method adds both created_at and updated_at columns as nullable timestamp fields.Click to reveal answer
intermediate
How can you customize the names of timestamp columns in Laravel?
Override the <code>const CREATED_AT</code> and <code>const UPDATED_AT</code> constants in your model to use custom column names for timestamps.Click to reveal answer
intermediate
What happens if you manually set
updated_at to null in a Laravel model?If you set
updated_at to null, Laravel will treat it as no update time. But on saving, Laravel will overwrite it with the current timestamp unless timestamps are disabled.Click to reveal answer
Which columns does Laravel automatically manage for timestamps?
✗ Incorrect
Laravel uses
created_at and updated_at columns by default to track record creation and updates.How do you add timestamp columns in a Laravel migration?
✗ Incorrect
The correct method to add
created_at and updated_at columns is $table->timestamps();.To disable automatic timestamps in a Laravel model, you should:
✗ Incorrect
Setting
public $timestamps = false; in the model disables automatic timestamp updates.Which constants do you override to rename timestamp columns in Laravel?
✗ Incorrect
You override
const CREATED_AT and const UPDATED_AT in your model to customize timestamp column names.If you want Laravel to stop updating timestamps but keep the columns, what do you do?
✗ Incorrect
Disabling timestamps by setting
public $timestamps = false; stops Laravel from updating those columns.Explain how Laravel manages timestamps in Eloquent models and how you can customize or disable this feature.
Think about the default columns and how Laravel updates them automatically.
You got /4 concepts.
Describe the steps to add timestamps to a new Laravel database table and how to prevent Laravel from updating them automatically.
Consider both migration and model changes.
You got /2 concepts.