PHP Class atk4\data\Reference_One

Inheritance: extends Reference
Show file Open project: atk4/data

Public Properties

Property Type Description
$dateTimeClass For example, 'DateTime', 'Carbon' etc.
$dateTimeZoneClass For example, 'DateTimeZone', 'Carbon' etc.
$default mixed Default value of field.
$mandatory boolean | string Is field mandatory? By default fields are not mandatory.
$never_persist boolean Setting this to true will never actually store the field in the database. It will action as normal, but will be skipped by update/insert.
$persist_format string For example, for date it can be 'Y-m-d', for datetime - 'Y-m-d H:i:s' etc.
$persist_timezone string For example, 'IST', 'UTC', 'Europe/Riga' etc.
$read_only boolean For example, expressions are read only.
$serialize null | boolean | array Value can be array [$encode_callback, $decode_callback].
$typecast null | boolean | array Value can be array [$typecast_save_callback, $typecast_load_callback].
$ui array By default hasOne relation ID field should be editable in forms, but not visible in grids. UI should respect these flags.

Protected Properties

Property Type Description
$join Join | null Points to the join if we are part of one.

Public Methods

Method Description
init ( ) Reference_One will also add a field corresponding to 'our_field' unless it exists of course.
ref ( array $defaults = [] ) : Model If owner model is loaded, then return referenced model with respective record loaded.

Protected Methods

Method Description
referenceOurValue ( ) : Field Returns our field or id field.

Method Details

init() public method

Reference_One will also add a field corresponding to 'our_field' unless it exists of course.
public init ( )

ref() public method

If owner model is not loaded, then return referenced model with condition set. This can happen in case of deep traversal $m->ref('Many')->ref('one_id'), for example.
public ref ( array $defaults = [] ) : Model
$defaults array Properties
return Model

referenceOurValue() protected method

Returns our field or id field.
protected referenceOurValue ( ) : Field
return Field

Property Details

$dateTimeClass public property

For example, 'DateTime', 'Carbon' etc.
public $dateTimeClass

$dateTimeZoneClass public property

For example, 'DateTimeZone', 'Carbon' etc.
public $dateTimeZoneClass

$default public property

Default value of field.
public mixed $default
return mixed

$join protected property

Points to the join if we are part of one.
protected Join,atk4\data|null $join
return Join | null

$mandatory public property

Is field mandatory? By default fields are not mandatory.
public bool|string $mandatory
return boolean | string

$never_persist public property

Setting this to true will never actually store the field in the database. It will action as normal, but will be skipped by update/insert.
public bool $never_persist
return boolean

$persist_format public property

For example, for date it can be 'Y-m-d', for datetime - 'Y-m-d H:i:s' etc.
public string $persist_format
return string

$persist_timezone public property

For example, 'IST', 'UTC', 'Europe/Riga' etc.
public string $persist_timezone
return string

$read_only public property

For example, expressions are read only.
public bool $read_only
return boolean

$serialize public property

Value can be array [$encode_callback, $decode_callback].
public null|bool|array $serialize
return null | boolean | array

$typecast public property

Value can be array [$typecast_save_callback, $typecast_load_callback].
public null|bool|array $typecast
return null | boolean | array

$ui public property

By default hasOne relation ID field should be editable in forms, but not visible in grids. UI should respect these flags.
public array $ui
return array