trait HasTimestamps

Constants

protected IGNORE_TIMESTAMPS_CONTEXT_KEY

Context key for storing models that should ignore timestamps.

Properties

bool $timestamps

Indicates if the model should be timestamped.

Methods

void
initializeHasTimestamps()

Initialize the HasTimestamps trait.

bool
touch(array|string|null $attribute = null)

Update the model's update timestamp.

bool
touchQuietly(array|string|null $attribute = null)

Update the model's update timestamp without raising any events.

updateTimestamps()

Update the creation and update timestamps.

setCreatedAt(mixed $value)

Set the value of the "created at" attribute.

setUpdatedAt(mixed $value)

Set the value of the "updated at" attribute.

CarbonInterface
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

at line 30
void initializeHasTimestamps()

Initialize the HasTimestamps trait.

Return Value

void

at line 50
bool touch(array|string|null $attribute = null)

Update the model's update timestamp.

Parameters

array|string|null $attribute

Return Value

bool

at line 74
bool touchQuietly(array|string|null $attribute = null)

Update the model's update timestamp without raising any events.

Parameters

array|string|null $attribute

Return Value

bool

at line 84
HasTimestamps updateTimestamps()

Update the creation and update timestamps.

Return Value

HasTimestamps

at line 108
HasTimestamps setCreatedAt(mixed $value)

Set the value of the "created at" attribute.

Parameters

mixed $value

Return Value

HasTimestamps

at line 120
HasTimestamps setUpdatedAt(mixed $value)

Set the value of the "updated at" attribute.

Parameters

mixed $value

Return Value

HasTimestamps

at line 130
CarbonInterface freshTimestamp()

Get a fresh timestamp for the model.

Return Value

CarbonInterface

at line 138
string freshTimestampString()

Get a fresh timestamp for the model.

Return Value

string

at line 146
bool usesTimestamps()

Determine if the model uses timestamps.

Return Value

bool

at line 154
string|null getCreatedAtColumn()

Get the name of the "created at" column.

Return Value

string|null

at line 162
string|null getUpdatedAtColumn()

Get the name of the "updated at" column.

Return Value

string|null

at line 170
string|null getQualifiedCreatedAtColumn()

Get the fully qualified "created at" column.

Return Value

string|null

at line 180
string|null getQualifiedUpdatedAtColumn()

Get the fully qualified "updated at" column.

Return Value

string|null

at line 195
static mixed withoutTimestamps(callable $callback)

Disable timestamps for the current class during the given callback scope.

Parameters

callable $callback

Return Value

mixed

at line 209
static mixed withoutTimestampsOn(array $models, callable $callback)

Disable timestamps for the given model classes during the given callback scope.

Parameters

array $models
callable $callback

Return Value

mixed

at line 227
static bool isIgnoringTimestamps(string|null $class = null)

Determine if the given model is ignoring timestamps / touches.

Parameters

string|null $class

Return Value

bool