HasCompositePrimaryKey
Generic class for all the classes that have a composite primary key Source : https://github.com/mopo922/LaravelTreats/blob/master/src/Model/Traits/HasCompositePrimaryKey.php
Tags
Table of Contents
- find() : mixed|static
- Execute a query for a single record by ID.
- findOrFail() : Model|Collection
- Find a model by its primary key or throw an exception.
- getIncrementing() : bool
- Get the value indicating whether the IDs are incrementing.
- getKey() : mixed
- Get the value of the model's primary key.
- refresh() : $this
- Reload the current model instance with fresh attributes from the database.
- setKeysForSaveQuery() : Builder
- Set the keys for a save update query.
Methods
find()
Execute a query for a single record by ID.
public
static find(array<string|int, mixed> $ids[, array<string|int, mixed> $columns = ['*'] ]) : mixed|static
Parameters
- $ids : array<string|int, mixed>
-
Array of keys, like [column => value].
- $columns : array<string|int, mixed> = ['*']
Return values
mixed|static —findOrFail()
Find a model by its primary key or throw an exception.
public
static findOrFail(mixed $ids[, array<string|int, mixed> $columns = ['*'] ]) : Model|Collection
Parameters
- $ids : mixed
- $columns : array<string|int, mixed> = ['*']
Tags
Return values
Model|Collection —getIncrementing()
Get the value indicating whether the IDs are incrementing.
public
getIncrementing() : bool
Return values
bool —getKey()
Get the value of the model's primary key.
public
getKey() : mixed
Return values
mixed —refresh()
Reload the current model instance with fresh attributes from the database.
public
refresh() : $this
Return values
$this —setKeysForSaveQuery()
Set the keys for a save update query.
protected
setKeysForSaveQuery(Builder $query) : Builder
Parameters
- $query : Builder