FacturaScripts

AtributoValor extends ModelClass
in package
uses ModelTrait

A Value for an article attribute.

Table of Contents

Properties

$codatributo  : string
Code of the related attribute.
$descripcion  : string
Attribute name + value.
$id  : int
Primary key
$orden  : int
Position for visualization and print
$valor  : string
Value of the attribute
$attributes  : array<string|int, mixed>
The model's attributes.
$dataBase  : DataBase
It provides direct access to the database.
$fields  : array<string|int, mixed>
List of fields in the table.
$original  : array<string|int, mixed>
The model's original attributes.

Methods

__construct()  : mixed
__get()  : mixed
__isset()  : bool
__set()  : void
__unset()  : void
addExtension()  : void
all()  : array<string|int, static>
Devuelve todos los registros que cumplen las condiciones.
changeId()  : bool
changePrimaryColumnValue()  : bool
clear()  : void
clearCache()  : void
codeModelAll()  : array<string|int, mixed>
count()  : int
create()  : static|null
delete()  : bool
deleteWhere()  : bool
exists()  : bool
find()  : static|null
findOrCreate()  : static|null
findWhere()  : static|null
findWhereEq()  : static|null
get()  : mixed
getApiFieldsToHide()  : array<string|int, string>
Devuelve los nombres de campos que no deben exponerse en la API (ni en GET, ni en el schema). Los modelos con datos sensibles deben sobrescribir este método.
getAtributo()  : Atributo
getDirty()  : array<string|int, mixed>
Devuelve un array asociativo con los campos modificados y sus valores actuales.
getModelFields()  : array<string|int, mixed>
Returns the list of fields in the table.
getOriginal()  : mixed|null
Devuelve el valor original de un campo, si no se indica campo devuelve todo el array original
hasChanged()  : bool
hasColumn()  : bool
hasExtension()  : bool
id()  : mixed
install()  : string
isDirty()  : bool
Comprueba si los campos del modelo han sido modificados.
load()  : bool
Carga un modelo dada su primary key
loadFromCode()  : bool
Carga un registro del modelo utilizando un código y opcionalmente condiciones adicionales.
loadFromData()  : void
loadWhere()  : bool
Carga el primer registro que coincida con las condiciones especificadas.
loadWhereEq()  : bool
modelClassName()  : string
Returns the name of the class of the model.
newCode()  : mixed
pipe()  : mixed
pipeFalse()  : bool
primaryColumn()  : string
primaryColumnValue()  : mixed
primaryDescription()  : mixed
primaryDescriptionColumn()  : string
reload()  : bool
save()  : bool
Guarda el modelo en la base de datos después de ejecutar las comprobaciones `$this->test()`
syncOriginal()  : void
table()  : DbQuery
tableName()  : string
test()  : bool
Realiza pruebas de validación sobre los campos del modelo antes de guardarlo.
toArray()  : array<string|int, mixed>
Devuelve un array con los campos y valores del modelo.
totalSum()  : float
update()  : bool
Actualiza el modelo con los valores proporcionados en el array
updateOrCreate()  : static|null
url()  : string
Genera una URL para el modelo según el tipo especificado.
belongsTo()  : object|null
Define una relación uno a uno.
db()  : DataBase
hasMany()  : array<string|int, mixed>
Define a one-to-many relationship.
loadModelFields()  : void
onChange()  : bool
Este método se llama antes de guardar (insertar) un nuevo registro en la base de datos.
onDelete()  : void
Este método se llama al eliminar un registro de la base de datos.
onInsert()  : void
Este método se llama al insertar un nuevo registro en la base de datos (saveInsert).
onUpdate()  : void
Este método se llama al insertar un nuevo registro en la base de datos (saveUpdate).
saveInsert()  : bool
saveUpdate()  : bool
Este método se llama al actualizar un registro existente en la base de datos.

Properties

$codatributo

Code of the related attribute.

public string $codatributo

$descripcion

Attribute name + value.

public string $descripcion

$orden

Position for visualization and print

public int $orden

$attributes

The model's attributes.

protected array<string|int, mixed> $attributes = []

$dataBase

It provides direct access to the database.

protected static DataBase $dataBase

$fields

List of fields in the table.

protected static array<string|int, mixed> $fields = []

$original

The model's original attributes.

protected array<string|int, mixed> $original = []

Methods

__construct()

public __construct([array<string|int, mixed> $data = [] ]) : mixed
Parameters
$data : array<string|int, mixed> = []

__get()

public __get(string $key) : mixed
Parameters
$key : string

__isset()

public __isset(string $key) : bool
Parameters
$key : string
Return values
bool

__set()

public __set(string $key, mixed $value) : void
Parameters
$key : string
$value : mixed

__unset()

public __unset(string $key) : void
Parameters
$key : string

addExtension()

public abstract static addExtension(mixed $extension[, int $priority = 100 ]) : void
Parameters
$extension : mixed
$priority : int = 100

all()

Devuelve todos los registros que cumplen las condiciones.

public static all([array<string|int, mixed> $where = [] ][, array<string|int, mixed> $order = [] ][, int $offset = 0 ][, int $limit = 0 ]) : array<string|int, static>
Parameters
$where : array<string|int, mixed> = []
$order : array<string|int, mixed> = []
$offset : int = 0
$limit : int = 0
Return values
array<string|int, static>

changeId()

public changeId(mixed $new_id) : bool
Parameters
$new_id : mixed
Return values
bool

changePrimaryColumnValue()

public changePrimaryColumnValue(mixed $new_id) : bool

replace with changeId()

Parameters
$new_id : mixed
Return values
bool

codeModelAll()

public codeModelAll([string $fieldCode = '' ]) : array<string|int, mixed>
Parameters
$fieldCode : string = ''
Return values
array<string|int, mixed>

count()

public static count([array<string|int, mixed> $where = [] ]) : int
Parameters
$where : array<string|int, mixed> = []
Return values
int

create()

public static create(array<string|int, mixed> $data) : static|null
Parameters
$data : array<string|int, mixed>
Return values
static|null

delete()

public delete() : bool
Return values
bool

deleteWhere()

public static deleteWhere(array<string|int, mixed> $where) : bool
Parameters
$where : array<string|int, mixed>
Return values
bool

exists()

public exists() : bool
Return values
bool

find()

public static find(mixed $code) : static|null
Parameters
$code : mixed
Return values
static|null

findOrCreate()

public static findOrCreate(array<string|int, mixed> $where[, array<string|int, mixed> $data = [] ]) : static|null
Parameters
$where : array<string|int, mixed>
$data : array<string|int, mixed> = []
Return values
static|null

findWhere()

public static findWhere(array<string|int, mixed> $where[, array<string|int, mixed> $order = [] ]) : static|null
Parameters
$where : array<string|int, mixed>
$order : array<string|int, mixed> = []
Return values
static|null

findWhereEq()

public static findWhereEq(string $field, mixed $value) : static|null
Parameters
$field : string
$value : mixed
Return values
static|null

get()

public get(mixed $code) : mixed

Use find() instead

Parameters
$code : mixed

getApiFieldsToHide()

Devuelve los nombres de campos que no deben exponerse en la API (ni en GET, ni en el schema). Los modelos con datos sensibles deben sobrescribir este método.

public getApiFieldsToHide() : array<string|int, string>
Return values
array<string|int, string>

getDirty()

Devuelve un array asociativo con los campos modificados y sus valores actuales.

public getDirty() : array<string|int, mixed>
Return values
array<string|int, mixed>

getModelFields()

Returns the list of fields in the table.

public getModelFields() : array<string|int, mixed>
Return values
array<string|int, mixed>

getOriginal()

Devuelve el valor original de un campo, si no se indica campo devuelve todo el array original

public getOriginal([string|null $key = null ]) : mixed|null
Parameters
$key : string|null = null
Return values
mixed|null

Devuelve el valor original del campo o null si no existe

hasChanged()

public hasChanged(string $field) : bool

replace with isDirty()

Parameters
$field : string
Return values
bool

hasColumn()

public hasColumn(string $columnName) : bool
Parameters
$columnName : string
Return values
bool

hasExtension()

public abstract hasExtension(mixed $extension) : bool
Parameters
$extension : mixed
Return values
bool

isDirty()

Comprueba si los campos del modelo han sido modificados.

public isDirty([string|null $key = null ]) : bool

Devuelve true si hay cambios, false en caso contrario.

Si introduces un parámetro key, comprueba solo ese campo

Parameters
$key : string|null = null
Return values
bool

true si ha sido modificado, false en caso contrario

load()

Carga un modelo dada su primary key

public load(mixed $code) : bool
Parameters
$code : mixed

Código o identificador del registro a cargar

Return values
bool

Devuelve true si se encontró y cargó un registro exitosamente.

loadFromCode()

Carga un registro del modelo utilizando un código y opcionalmente condiciones adicionales.

public loadFromCode(mixed $code[, array<string|int, mixed> $where = [] ][, array<string|int, mixed> $order = [] ]) : bool

Usar load() cuando solo se necesita cargar por código, o loadWhere() cuando se requieren condiciones WHERE u ordenamiento adicionales.

IMPORTANTE: Este método está deprecado. Se recomienda usar las alternativas siguientes:

  • Si solo se proporciona $code: usar directamente load($code)
  • Si se proporciona $code junto con $where o $order: usar loadWhere() con las condiciones apropiadas

Este método actúa como wrapper que redirige a load() cuando solo se proporciona el código, o a loadWhere() cuando se incluyen condiciones WHERE u ordenamiento adicionales.

Parameters
$code : mixed

Código o identificador del registro a cargar. Se usa únicamente cuando no se proporcionan condiciones WHERE adicionales.

$where : array<string|int, mixed> = []

Array de instancias de Where o DatabaseWhere que definen condiciones de filtrado adicionales. Si se proporciona, el método delega a loadWhere(). Por defecto es un array vacío.

$order : array<string|int, mixed> = []

Array asociativo que define el ordenamiento de los resultados. Las claves son nombres de columnas y los valores la dirección del ordenamiento. Por defecto es un array vacío.

Return values
bool

Retorna true si se encontró y cargó un registro exitosamente. Retorna false si no se encontró ningún registro.

loadFromData()

public loadFromData([array<string|int, mixed> $data = [] ][, array<string|int, mixed> $exclude = [] ][, bool $sync = true ]) : void
Parameters
$data : array<string|int, mixed> = []
$exclude : array<string|int, mixed> = []
$sync : bool = true

loadWhere()

Carga el primer registro que coincida con las condiciones especificadas.

public loadWhere(array<string|int, mixed> $where[, array<string|int, mixed> $order = [] ]) : bool

Este método consulta la tabla asociada al modelo aplicando las condiciones WHERE proporcionadas y el ordenamiento especificado. Si encuentra un registro, carga sus datos en la instancia actual del modelo. Si no encuentra ningún registro, limpia la instancia y retorna false.

Parameters
$where : array<string|int, mixed>

Array de instancias de Where o DatabaseWhere que definen las condiciones de filtrado para la consulta. Cada elemento representa una condición que debe cumplir el registro a cargar.

$order : array<string|int, mixed> = []

Array asociativo que define el ordenamiento de los resultados. Las claves son nombres de columnas y los valores indican la dirección del ordenamiento (ej: ['id' => 'DESC', 'nombre' => 'ASC']). Por defecto es un array vacío (sin ordenamiento específico).

Return values
bool

Retorna true si se encontró y cargó un registro exitosamente. Retorna false si no se encontró ningún registro que cumpla las condiciones.

loadWhereEq()

public loadWhereEq(string $field, mixed $value) : bool
Parameters
$field : string
$value : mixed
Return values
bool

modelClassName()

Returns the name of the class of the model.

public modelClassName() : string
Return values
string

newCode()

public newCode([string $field = '' ][, array<string|int, mixed> $where = [] ]) : mixed
Parameters
$field : string = ''
$where : array<string|int, mixed> = []

pipe()

public abstract pipe(mixed $name, mixed ...$arguments) : mixed
Parameters
$name : mixed
$arguments : mixed

pipeFalse()

public abstract pipeFalse(mixed $name, mixed ...$arguments) : bool
Parameters
$name : mixed
$arguments : mixed
Return values
bool

primaryColumn()

public abstract static primaryColumn() : string
Return values
string

primaryColumnValue()

public primaryColumnValue() : mixed

Use id() instead

Attributes
#[Deprecated]
$reason: 'Use id() instead'
$replacement: '%class%->id()'

primaryDescription()

public primaryDescription() : mixed

primaryDescriptionColumn()

public primaryDescriptionColumn() : string
Return values
string

reload()

public reload() : bool
Return values
bool

save()

Guarda el modelo en la base de datos después de ejecutar las comprobaciones `$this->test()`

public save() : bool
Return values
bool

Devuelve true si se ha guardado correctamente, false en caso contrario

tableName()

public static tableName() : string
Return values
string

test()

Realiza pruebas de validación sobre los campos del modelo antes de guardarlo.

public test() : bool
Return values
bool

Devuelve true si todas las pruebas pasan, false en caso contrario

toArray()

Devuelve un array con los campos y valores del modelo.

public toArray([bool $dynamic_attributes = false ]) : array<string|int, mixed>
Parameters
$dynamic_attributes : bool = false

Si es true, añade también los atributos dinámicos al array resultante

Return values
array<string|int, mixed>

Array asociativo con los campos y valores del modelo

totalSum()

public static totalSum(string $field[, array<string|int, mixed> $where = [] ]) : float
Parameters
$field : string
$where : array<string|int, mixed> = []
Return values
float

update()

Actualiza el modelo con los valores proporcionados en el array

public update(array<string|int, mixed> $values) : bool
Parameters
$values : array<string|int, mixed>

Array asociativo con los campos y valores a actualizar

Return values
bool

Devuelve true si la actualización se ha realizado correctamente, false en caso

updateOrCreate()

public static updateOrCreate(array<string|int, mixed> $where, array<string|int, mixed> $data) : static|null
Parameters
$where : array<string|int, mixed>
$data : array<string|int, mixed>
Return values
static|null

url()

Genera una URL para el modelo según el tipo especificado.

public url([string $type = 'auto' ][, string $list = 'ListAtributo' ]) : string
Parameters
$type : string = 'auto'

Tipo de URL a generar. Puede ser 'auto', 'edit', 'list' o 'new'.

$list : string = 'ListAtributo'

Nombre de la lista a utilizar en la URL cuando el tipo es 'list' o 'auto'.

Return values
string

URL generada para el modelo

belongsTo()

Define una relación uno a uno.

protected belongsTo(string $modelName, string $foreignKey) : object|null
Parameters
$modelName : string
$foreignKey : string
Return values
object|null

hasMany()

Define a one-to-many relationship.

protected hasMany(string $modelName, string $foreignKey[, array<string|int, mixed> $where = [] ][, array<string|int, mixed> $order = [] ]) : array<string|int, mixed>
Parameters
$modelName : string
$foreignKey : string
$where : array<string|int, mixed> = []
$order : array<string|int, mixed> = []
Return values
array<string|int, mixed>

loadModelFields()

protected loadModelFields() : void

onChange()

Este método se llama antes de guardar (insertar) un nuevo registro en la base de datos.

protected onChange(string $field) : bool
Parameters
$field : string
Return values
bool

onDelete()

Este método se llama al eliminar un registro de la base de datos.

protected onDelete() : void

onInsert()

Este método se llama al insertar un nuevo registro en la base de datos (saveInsert).

protected onInsert() : void

onUpdate()

Este método se llama al insertar un nuevo registro en la base de datos (saveUpdate).

protected onUpdate() : void

saveInsert()

protected saveInsert() : bool
Return values
bool

saveUpdate()

Este método se llama al actualizar un registro existente en la base de datos.

protected saveUpdate() : bool
Return values
bool

Devuelve true si la actualización se realizó correctamente, false en caso contrario


        
On this page

Search results