abstract class Model implements ArrayAccess, JsonSerializable (View source)

Traits

Properties

protected array $hidden

The hidden field

protected bool $timestamps

Enable the timestamps support

protected string $prefix

Define the table prefix

protected bool $auto_increment

Enable the autoincrement support

protected bool $soft_delete

Enable the soft deletion

protected string $latest

Defines the column where the query construct will use for the last query

protected array $attributes

The table columns listing

protected array $dates

The date mutation

protected array $casts

The casts mutation

protected string $primary_key

The table primary key column name

protected string $primary_key_type

The table primary key type

protected string $table

The table name

protected string $connection

The connection name

static protected Builder $builder

The query builder instance

Methods

string
getKey()

Retrieves the primary key

belongsTo(string $related, string $foreign_key = null, string $local_key = null)

The has one relative

belongsToMany(string $related, string $primary_key = null, string $foreign_key = null)

The belongs to many relative

hasMany(string $related, string $primary_key = null, string $foreign_key = null)

The has many relative

hasOne(string $related, string $primary_key = null, string $foreign_key = null)

The has one relative

offsetSet(mixed $offset, mixed $value)

_offsetSet

bool
offsetExists(mixed $offset)

_offsetExists

offsetUnset(mixed $offset)

_offsetUnset

mixed|null
offsetGet(mixed $offset)

_offsetGet

__construct(array $attributes = [])

Model constructor.

static Collection
all(array $columns = [])

Get all records

static Model
first()

Get first rows

static Model
latest()

Get last

static Collection|Model|null
find(mixed $id, array $select = ['*'])

find

static Collection|null
findBy(string $column, mixed $value)

Find by column name

static mixed
describe()

Returns the description of the table

static Collection|Model|null
findAndDelete(mixed $id, array $select = ['*'])

Find information and delete it

static Model
findOrFail(mixed $id, array|callable $select = ['*'])

Find information by id or throws an exception in data box not found

static Model
create(array $data)

Create a persist information

static Collection
paginate(int $page_number, int $current = 0, int $chunk = null)

Pagination configuration

static 
deleted(callable $cb)

Allows to associate listener

static 
created(callable $cb)

Allows to associate a listener

static 
updated(callable $cb)

Allows to associate a listener

static 
query()

Initialize the connection

mixed
getKeyValue()

Retrieves the primary key value

save()

Save aliases on insert action

update(array $attribute)

Delete a record

delete()

Delete a record

static int
deleteBy(string $column, mixed $value)

Delete Active Record by column name

bool
touch()

Used to update the timestamp.

setAttributes(array $attributes)

Assign values to class attributes

setAttribute(string $key, string $value)

Assign a value

setConnection(string $connection)

Set connection point

array
getAttributes()

Retrieves the list of attributes.

mixed|null
getAttribute(string $key)

Allows you to recover an attribute

string
getTable()

Get the table name.

array
toArray()

Returns the data

array
toJson()

Returns the data

jsonSerialize()

No description

mixed|null
__get(string $name)

__get

__set(string $name, mixed $value)

__set

string
__toString()

__toString

mixed
__call(string $name, array $arguments)

__call

static mixed
__callStatic(string $name, array $arguments)

__callStatic

Details

string getKey()

Retrieves the primary key

Return Value

string

BelongsTo belongsTo(string $related, string $foreign_key = null, string $local_key = null)

The has one relative

Parameters

string $related
string $foreign_key
string $local_key

Return Value

BelongsTo

BelongsToMany belongsToMany(string $related, string $primary_key = null, string $foreign_key = null)

The belongs to many relative

Parameters

string $related
string $primary_key
string $foreign_key

Return Value

BelongsToMany

HasMany hasMany(string $related, string $primary_key = null, string $foreign_key = null)

The has many relative

Parameters

string $related
string $primary_key
string $foreign_key

Return Value

HasMany

HasOne hasOne(string $related, string $primary_key = null, string $foreign_key = null)

The has one relative

Parameters

string $related
string $primary_key
string $foreign_key

Return Value

HasOne

offsetSet(mixed $offset, mixed $value)

_offsetSet

Parameters

mixed $offset
mixed $value

See also

http://php.net/manual/fr/class.arrayaccess.php

bool offsetExists(mixed $offset)

_offsetExists

Parameters

mixed $offset

Return Value

bool

See also

http://php.net/manual/fr/class.arrayaccess.php

offsetUnset(mixed $offset)

_offsetUnset

Parameters

mixed $offset

See also

http://php.net/manual/fr/class.arrayaccess.php

mixed|null offsetGet(mixed $offset)

_offsetGet

Parameters

mixed $offset

Return Value

mixed|null

See also

http://php.net/manual/fr/class.arrayaccess.php

__construct(array $attributes = [])

Model constructor.

Parameters

array $attributes

static Collection all(array $columns = [])

Get all records

Parameters

array $columns

Return Value

Collection

static Model first()

Get first rows

Return Value

Model

static Model latest()

Get last

Return Value

Model

static Collection|Model|null find(mixed $id, array $select = ['*'])

find

Parameters

mixed $id
array $select

Return Value

Collection|Model|null

static Collection|null findBy(string $column, mixed $value)

Find by column name

Parameters

string $column
mixed $value

Return Value

Collection|null

static mixed describe()

Returns the description of the table

Return Value

mixed

static Collection|Model|null findAndDelete(mixed $id, array $select = ['*'])

Find information and delete it

Parameters

mixed $id
array $select

Return Value

Collection|Model|null

static Model findOrFail(mixed $id, array|callable $select = ['*'])

Find information by id or throws an exception in data box not found

Parameters

mixed $id
array|callable $select

Return Value

Model

Exceptions

NotFoundException

static Model create(array $data)

Create a persist information

Parameters

array $data

Return Value

Model

static Collection paginate(int $page_number, int $current = 0, int $chunk = null)

Pagination configuration

Parameters

int $page_number
int $current
int $chunk

Return Value

Collection

static deleted(callable $cb)

Allows to associate listener

Parameters

callable $cb

static created(callable $cb)

Allows to associate a listener

Parameters

callable $cb

static updated(callable $cb)

Allows to associate a listener

Parameters

callable $cb

static query()

Initialize the connection

mixed getKeyValue()

Retrieves the primary key value

Return Value

mixed

save()

Save aliases on insert action

update(array $attribute)

Delete a record

Parameters

array $attribute

delete()

Delete a record

static int deleteBy(string $column, mixed $value)

Delete Active Record by column name

Parameters

string $column
mixed $value

Return Value

int

bool touch()

Used to update the timestamp.

Return Value

bool

setAttributes(array $attributes)

Assign values to class attributes

Parameters

array $attributes

setAttribute(string $key, string $value)

Assign a value

Parameters

string $key
string $value

Builder setConnection(string $connection)

Set connection point

Parameters

string $connection

Return Value

Builder

array getAttributes()

Retrieves the list of attributes.

Return Value

array

mixed|null getAttribute(string $key)

Allows you to recover an attribute

Parameters

string $key

Return Value

mixed|null

string getTable()

Get the table name.

Return Value

string

array toArray()

Returns the data

Return Value

array

array toJson()

Returns the data

Return Value

array

jsonSerialize()

No description

mixed|null __get(string $name)

__get

Parameters

string $name

Return Value

mixed|null

__set(string $name, mixed $value)

__set

Parameters

string $name
mixed $value

string __toString()

__toString

Return Value

string

mixed __call(string $name, array $arguments)

__call

Parameters

string $name
array $arguments

Return Value

mixed

static mixed __callStatic(string $name, array $arguments)

__callStatic

Parameters

string $name
array $arguments

Return Value

mixed