Model
abstract class Model (View source)
Provides the model contract for the database subsystem.
Properties
| protected string | $table | ||
| protected string | $primaryKey | ||
| protected bool | $useTimestamps | ||
| protected bool | $useUserTracking | ||
| protected int|string|null | $actorId | ||
| protected string | $createdAt | ||
| protected string | $updatedAt | ||
| protected string | $createdBy | ||
| protected string | $updatedBy | ||
| protected bool | $useSoftDeletes | ||
| protected string | $deletedAt | ||
| protected list<string> | $allowedFields | ||
| protected bool | $allowCallbacks | ||
| protected list<string> | $beforeInsert | ||
| protected list<string> | $afterInsert | ||
| protected list<string> | $beforeUpdate | ||
| protected list<string> | $afterUpdate | ||
| protected list<string> | $beforeInsertBatch | ||
| protected list<string> | $afterInsertBatch | ||
| protected list<string> | $beforeUpdateBatch | ||
| protected list<string> | $afterUpdateBatch | ||
| protected list<string> | $beforeFind | ||
| protected list<string> | $afterFind | ||
| protected list<string> | $beforeDelete | ||
| protected list<string> | $afterDelete |
Methods
Initializes this Model with the collaborators and state required by its database contract.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Updates the query or object state used by subsequent database operations.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Runs the requested database operation and returns its driver-level outcome.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Updates the query or object state used by subsequent database operations.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Updates the query or object state used by subsequent database operations.
Resolves the effective value from the configured database dependencies and input.
Updates the query or object state used by subsequent database operations.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Provides this part of the database contract while preserving the object's current state and driver semantics.
Details
__construct
__construct(DatabaseDriverInterface $db)
Initializes this Model with the collaborators and state required by its database contract.
all
array
all()
No description
find
array|null
find(int|string $id)
No description
first
array|null
first(array $where = [])
No description
where
array
where(array $where, int|null $limit = null)
No description
exists
bool
exists(array $where)
No description
countAll
int
countAll()
Provides this part of the database contract while preserving the object's current state and driver semantics.
countWhere
int
countWhere(array $where)
No description
save
int|string|bool|null
save(array $data)
No description
firstOrCreate
array
firstOrCreate(array $attributes, array $values = [])
No description
updateOrCreate
array
updateOrCreate(array $attributes, array $values = [])
No description
upsert
int|string|bool|null
upsert(array $data, string|null $uniqueBy = null)
No description
batchUpsert
bool
batchUpsert(array $rows, string|null $uniqueBy = null)
No description
insert
int|string|null
insert(array $data)
No description
update
bool
update(int|string $id, array $data)
No description
insertBatch
bool
insertBatch(array $rows)
No description
updateBatch
bool
updateBatch(array $rows, string|null $index = null)
No description
delete
bool
delete(int|string $id)
Provides this part of the database contract while preserving the object's current state and driver semantics.
forceDelete
bool
forceDelete(int|string $id)
Provides this part of the database contract while preserving the object's current state and driver semantics.
deleteWhere
bool
deleteWhere(array $where)
No description
findMany
array
findMany(array $ids)
No description
increment
bool
increment(int|string $id, string $column, int|float $amount = 1)
Provides this part of the database contract while preserving the object's current state and driver semantics.
decrement
bool
decrement(int|string $id, string $column, int|float $amount = 1)
Provides this part of the database contract while preserving the object's current state and driver semantics.
restore
bool
restore(int|string $id)
Provides this part of the database contract while preserving the object's current state and driver semantics.
restoreWhere
bool
restoreWhere(array $where)
No description
withDeleted
Model
withDeleted(bool $state = true)
Updates the query or object state used by subsequent database operations.
onlyDeleted
Model
onlyDeleted(bool $state = true)
Provides this part of the database contract while preserving the object's current state and driver semantics.
builder
QueryBuilder
builder()
Provides this part of the database contract while preserving the object's current state and driver semantics.
query
QueryBuilder
query()
Runs the requested database operation and returns its driver-level outcome.
scoped
QueryBuilder
scoped(string $scope, mixed ...$args)
Provides this part of the database contract while preserving the object's current state and driver semantics.
applyScope
QueryBuilder
applyScope(QueryBuilder $builder, string $scope, mixed ...$args)
Updates the query or object state used by subsequent database operations.
chunk
void
chunk(int $size, callable $callback)
No description
tableName
protected string
tableName()
Provides this part of the database contract while preserving the object's current state and driver semantics.
requireTableName
protected string
requireTableName()
Provides this part of the database contract while preserving the object's current state and driver semantics.
columnName
protected string
columnName(string $column)
Provides this part of the database contract while preserving the object's current state and driver semantics.
prepareInsertData
protected array
prepareInsertData(array $data)
No description
prepareUpdateData
protected array
prepareUpdateData(array $data)
No description
filterAllowedFields
protected array
filterAllowedFields(array $data)
No description
now
protected string
now()
Provides this part of the database contract while preserving the object's current state and driver semantics.
setActorId
Model
setActorId(int|string|null $id)
Updates the query or object state used by subsequent database operations.
resolveActorId
protected int|string|null
resolveActorId()
Resolves the effective value from the configured database dependencies and input.
prepareDeleteData
protected array
prepareDeleteData()
No description
applySoftDeleteScope
protected QueryBuilder
applySoftDeleteScope(QueryBuilder $builder)
Updates the query or object state used by subsequent database operations.
resetSoftDeleteScope
protected void
resetSoftDeleteScope()
Provides this part of the database contract while preserving the object's current state and driver semantics.
scopeMethodName
protected string
scopeMethodName(string $scope)
Provides this part of the database contract while preserving the object's current state and driver semantics.
trigger
protected array
trigger(string $event, array $payload)
No description