On this page
HasTimestamps
trait HasTimestamps (View source)
Properties
bool | $timestamps | Indicates if the model should be timestamped. |
|
static protected array | $ignoreTimestampsOn | The list of models classes that have timestamps temporarily disabled. |
Methods
bool | touch(string|null $attribute = null) Update the model's update timestamp. |
|
bool | touchQuietly(string|null $attribute = null) Update the model's update timestamp without raising any events. |
|
$this | updateTimestamps() Update the creation and update timestamps. |
|
$this | setCreatedAt(mixed $value) Set the value of the "created at" attribute. |
|
$this | setUpdatedAt(mixed $value) Set the value of the "updated at" attribute. |
|
Carbon | freshTimestamp() Get a fresh timestamp for the model. |
|
string | freshTimestampString() Get a fresh timestamp for the model. |
|
bool | usesTimestamps() Determine if the model uses timestamps. |
|
string|null | getCreatedAtColumn() Get the name of the "created at" column. |
|
string|null | getUpdatedAtColumn() Get the name of the "updated at" column. |
|
string|null | getQualifiedCreatedAtColumn() Get the fully qualified "created at" column. |
|
string|null | getQualifiedUpdatedAtColumn() Get the fully qualified "updated at" column. |
|
static mixed | withoutTimestamps(callable $callback) Disable timestamps for the current class during the given callback scope. |
|
static mixed | withoutTimestampsOn(array $models, callable $callback) Disable timestamps for the given model classes during the given callback scope. |
|
static bool | isIgnoringTimestamps(string|null $class = null) Determine if the given model is ignoring timestamps / touches. |
Details
bool touch(string|null $attribute = null)
Update the model's update timestamp.
bool touchQuietly(string|null $attribute = null)
Update the model's update timestamp without raising any events.
$this updateTimestamps()
Update the creation and update timestamps.
$this setCreatedAt(mixed $value)
Set the value of the "created at" attribute.
$this setUpdatedAt(mixed $value)
Set the value of the "updated at" attribute.
Carbon freshTimestamp()
Get a fresh timestamp for the model.
string freshTimestampString()
Get a fresh timestamp for the model.
bool usesTimestamps()
Determine if the model uses timestamps.
string|null getCreatedAtColumn()
Get the name of the "created at" column.
string|null getUpdatedAtColumn()
Get the name of the "updated at" column.
string|null getQualifiedCreatedAtColumn()
Get the fully qualified "created at" column.
string|null getQualifiedUpdatedAtColumn()
Get the fully qualified "updated at" column.
static mixed withoutTimestamps(callable $callback)
Disable timestamps for the current class during the given callback scope.
static mixed withoutTimestampsOn(array $models, callable $callback)
Disable timestamps for the given model classes during the given callback scope.
static bool isIgnoringTimestamps(string|null $class = null)
Determine if the given model is ignoring timestamps / touches.
© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/10.x/Illuminate/Database/Eloquent/Concerns/HasTimestamps.html