PHP Trait Eloquent\Dialect\Json

Datei anzeigen Open project: darrylkuhn/dialect

Public Properties

Property Type Description
$jsonOperators array test_column->>'value').

Public Methods

Method Description
addHintedAttributes ( ) Schema free data architecture give us tons of flexibility (yay) but makes it hard to inspect a structure and build getters/setters.
flagJsonAttribute ( string $key, string $col ) Record that a given JSON element is found on a particular column.
getDirty ( $includeJson = false ) : array Add json attributes to the list of things that have changed (when they've changed).
getMutatedAttributes ( ) : array Include the JSON attributes in the list of mutated attributes for a given instance.
hasGetMutator ( string $key ) : boolean Include JSON column in the list of attributes that have a get mutator.
hintJsonStructure ( string $column, string $structure ) Sets a hint for a given column.
inspectJsonColumns ( ) Decodes each of the declared JSON attributes and records the attributes on each.
newFromBuilder ( array $attributes = [], string | null $connection = null ) : static Create a new model instance that is existing.
setAttribute ( string $key, mixed $value ) Set a given attribute on the known JSON elements.
setJsonAttribute ( string $attribute, string $key, mixed $value ) Set a given attribute on the known JSON elements.
showJsonAttributes ( $show ) : boolean Allows you to specify if the attributes within various json columns should be shown on toArray() and toJson() calls. Set this value in the models constructor (to make sure it is set before newFromBuilder() is called). This is true by default.
showJsonColumns ( boolean $show ) : boolean Allows you to specify if the actual JSON column housing the attributes should be shown on toArray() and toJson() calls. Set this value in the models constructor (to make sure it is set before newFromBuilder() is called). This is false by default.

Protected Methods

Method Description
mutateAttribute ( string $key, mixed $value ) : mixed Check if the key is a known json attribute and return that value.

Method Details

addHintedAttributes() public method

Therefore you can "hint" the structure to make life easier.
public addHintedAttributes ( )

flagJsonAttribute() public method

Record that a given JSON element is found on a particular column.
public flagJsonAttribute ( string $key, string $col )
$key string attribute name within the JSON column
$col string name of JSON column

getDirty() public method

Add json attributes to the list of things that have changed (when they've changed).
public getDirty ( $includeJson = false ) : array
return array

getMutatedAttributes() public method

Include the JSON attributes in the list of mutated attributes for a given instance.
public getMutatedAttributes ( ) : array
return array

hasGetMutator() public method

Include JSON column in the list of attributes that have a get mutator.
public hasGetMutator ( string $key ) : boolean
$key string
return boolean

hintJsonStructure() public method

Sets a hint for a given column.
public hintJsonStructure ( string $column, string $structure )
$column string name of column that we're hinting
$structure string json encoded structure

inspectJsonColumns() public method

Decodes each of the declared JSON attributes and records the attributes on each.
public inspectJsonColumns ( )

mutateAttribute() protected method

Check if the key is a known json attribute and return that value.
protected mutateAttribute ( string $key, mixed $value ) : mixed
$key string
$value mixed
return mixed

newFromBuilder() public method

Overrides parent to set Json columns.
public newFromBuilder ( array $attributes = [], string | null $connection = null ) : static
$attributes array
$connection string | null
return static

setAttribute() public method

Set a given attribute on the known JSON elements.
public setAttribute ( string $key, mixed $value )
$key string
$value mixed

setJsonAttribute() public method

Set a given attribute on the known JSON elements.
public setJsonAttribute ( string $attribute, string $key, mixed $value )
$attribute string
$key string
$value mixed

showJsonAttributes() public method

Allows you to specify if the attributes within various json columns should be shown on toArray() and toJson() calls. Set this value in the models constructor (to make sure it is set before newFromBuilder() is called). This is true by default.
public showJsonAttributes ( $show ) : boolean
return boolean

showJsonColumns() public method

Allows you to specify if the actual JSON column housing the attributes should be shown on toArray() and toJson() calls. Set this value in the models constructor (to make sure it is set before newFromBuilder() is called). This is false by default.
public showJsonColumns ( boolean $show ) : boolean
$show boolean
return boolean

Property Details

$jsonOperators public_oe static_oe property

test_column->>'value').
public static array $jsonOperators
return array