BaseModel
API reference › Model › BaseModel
1 subclass
Base implementation of ModelInterface.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
add() | Registers a property and its supported types. | BaseModel |
getData() | Returns the raw input retained after loading. | BaseModel |
getModelName() | Returns the model class name used as the default input scope. | BaseModel |
getNames() | Returns property names, expanding nested models with dot notation. | BaseModel |
getTypes() | Returns collected property types indexed by property name. | BaseModel |
getValue() | Returns a property value, including nested model paths. | BaseModel |
has() | Checks whether a property or nested model path exists. | BaseModel |
isEmpty() | Checks whether the loaded raw input is empty. | BaseModel |
isType() | Checks whether a property supports the requested type. | BaseModel |
load() | Assigns scoped or unscoped input and retains its raw keys. | BaseModel |
setValue() | Assigns a property value using its attributes and type metadata. | BaseModel |
setValues() | Assigns input values while excluding the selected property names. | BaseModel |
toArray() | Exports property values with optional top-level snake_case keys. | BaseModel |
Method details
Section titled “Method details”add()
Section titled “add() ”public function add(string $property, string|array $type): voidRegisters a property and its supported types.
Parameters
| Parameter | Type | Description |
|---|---|---|
$property | string | |
$type | string| |
getData()
Section titled “getData() ”public function getData(): arrayReturns the raw input retained after loading.
Returns
array
getModelName()
Section titled “getModelName() ”public function getModelName(): stringReturns the model class name used as the default input scope.
Returns
string
getNames()
Section titled “getNames() ”public function getNames(): arrayReturns property names, expanding nested models with dot notation.
Returns
array
getTypes()
Section titled “getTypes() ”public function getTypes(): arrayReturns collected property types indexed by property name.
Returns
array
getValue()
Section titled “getValue() ”public function getValue(string $property): mixedReturns a property value, including nested model paths.
Parameters
| Parameter | Type | Description |
|---|---|---|
$property | string |
Returns
mixed
has()
Section titled “has() ”public function has(string $property): boolChecks whether a property or nested model path exists.
Parameters
| Parameter | Type | Description |
|---|---|---|
$property | string |
Returns
bool
isEmpty()
Section titled “isEmpty() ”public function isEmpty(): boolChecks whether the loaded raw input is empty.
Returns
bool
isType()
Section titled “isType() ”public function isType(string $property, string $type): boolChecks whether a property supports the requested type.
Parameters
| Parameter | Type | Description |
|---|---|---|
$property | string | |
$type | string |
Returns
bool
load()
Section titled “load() ”public function load(iterable $data, string|null $modelName = null): boolAssigns scoped or unscoped input and retains its raw keys.
Parameters
| Parameter | Type | Description |
|---|---|---|
$data | iterable | |
$modelName | string| |
Returns
bool
setValue()
Section titled “setValue() ”public function setValue(string $property, mixed $value): voidAssigns a property value using its attributes and type metadata.
Parameters
| Parameter | Type | Description |
|---|---|---|
$property | string | |
$value | mixed |
setValues()
Section titled “setValues() ”public function setValues(array $data, array $except = []): voidAssigns input values while excluding the selected property names.
Parameters
| Parameter | Type | Description |
|---|---|---|
$data | array | |
$except | array |
toArray()
Section titled “toArray() ”public function toArray(bool $snakeCase = false, array $exceptProperties = []): arrayExports property values with optional top-level snake_case keys.
Parameters
| Parameter | Type | Description |
|---|---|---|
$snakeCase | bool | |
$exceptProperties | array |
Returns
array