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

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.

$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.

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 TReturn
withoutTimestamps(callable $callback)

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

static TReturn
withoutTimestampsOn(array $models, TReturn $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

void initializeHasTimestamps()

Initialize the HasTimestamps trait.

Return Value

void

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

Update the model's update timestamp.

Parameters

array|string|null $attribute

Return Value

bool

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

$this updateTimestamps()

Update the creation and update timestamps.

Return Value

$this

$this setCreatedAt(mixed $value)

Set the value of the "created at" attribute.

Parameters

mixed $value

Return Value

$this

$this setUpdatedAt(mixed $value)

Set the value of the "updated at" attribute.

Parameters

mixed $value

Return Value

$this

Carbon freshTimestamp()

Get a fresh timestamp for the model.

Return Value

Carbon

string freshTimestampString()

Get a fresh timestamp for the model.

Return Value

string

bool usesTimestamps()

Determine if the model uses timestamps.

Return Value

bool

string|null getCreatedAtColumn()

Get the name of the "created at" column.

Return Value

string|null

string|null getUpdatedAtColumn()

Get the name of the "updated at" column.

Return Value

string|null

string|null getQualifiedCreatedAtColumn()

Get the fully-qualified "created at" column.

Return Value

string|null

string|null getQualifiedUpdatedAtColumn()

Get the fully-qualified "updated at" column.

Return Value

string|null

static TReturn withoutTimestamps(callable $callback)

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

Parameters

callable $callback

Return Value

TReturn

static TReturn withoutTimestampsOn(array $models, TReturn $callback)

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

Parameters

array $models
TReturn $callback

Return Value

TReturn

static bool isIgnoringTimestamps(string|null $class = null)

Determine if the given model is ignoring timestamps / touches.

Parameters

string|null $class

Return Value

bool

Laravel Cloud is the best place to deploy Laravel, Nuxt, Express, Hono, Node.js, Bun, Go, Flask, Python, and more, with dedicated infrastructure available on AWS through Laravel Private Cloud.