Variante extends ModelClass Uses ModelTrait, ProductRelationTrait
Define method and attributes of table variantes.
Table of Contents
$codbarras | Barcode. Maximum 20 characters. | string |
---|---|---|
$coste | Cost price. | int|float |
$idatributovalor1 | Foreign key of table atributo_valores. | int |
$idatributovalor2 | Foreign key of table atributo_valores. | int |
$idatributovalor3 | Foreign key of table atributo_valores. | int |
$idatributovalor4 | Foreign key of table atributo_valores. | int |
$idvariante | Primary Key, autoincremental. | int |
$margen | float | |
$precio | Price of the variant. Without tax. | int|float |
$referencia | Reference of the variant. Maximum 30 characters. | string |
$stockfis | Physical stock. | float|int |
$fields | List of fields in the table. | array |
$idproducto | Product identifier. | int |
$checkedTables | List of already tested tables. | array |
$dataBase | It provides direct access to the database. | DataBase |
clear() | mixed | |
codeModelSearch() | Allows to use this model as source in CodeModel special model. | \FacturaScripts\Core\Model\CodeModel[] |
description() | string | |
delete() | Remove the model data from the database. | bool |
getAttributeDescription() | string | |
getImages() | \FacturaScripts\Core\Model\ProductoImagen[] | |
install() | string | |
priceWithTax() | float | |
primaryColumn() | string | |
primaryDescriptionColumn() | Returns the name of the column that describes the model, such as name, description. | string |
save() | Stores the model data in the database. | bool |
setPriceWithTax() | mixed | |
tableName() | string | |
test() | Returns true if there are no errors in the values of the model properties. | bool |
url() | Returns the url where to see / modify the data. | string |
saveInsert() | Insert the model data in the database. | bool |
getModelFields() | Returns the list of fields in the table. | array |
modelClassName() | Returns the name of the class of the model. | string |
modelName() | Returns the name of the model. | string |
loadModelFields() | Loads table fields if is necessary. | mixed |
getProducto() | Returns related product. | Producto |
all() | Returns all models that correspond to the selected filters. | static[] |
codeModelAll() | Allows to use this model as source in CodeModel special model. | \FacturaScripts\Dinamic\Model\CodeModel[] |
codeModelSearch() | Allows to use this model as source in CodeModel special model. | \FacturaScripts\Dinamic\Model\CodeModel[] |
count() | Returns the number of records in the model that meet the condition. | int |
delete() | Remove the model data from the database. | bool |
exists() | Returns true if the model data is stored in the database. | bool |
get() | Returns the model whose primary column corresponds to the value $cod | static|bool |
loadFromCode() | Fill the class with the registry values whose primary column corresponds to the value $cod, or according to the condition where indicated, if value is not reported in $cod. | bool |
newCode() | Returns the following code for the reported field or the primary key of the model. | int |
primaryDescriptionColumn() | Returns the name of the column that describes the model, such as name, description. | string |
primaryDescription() | Descriptive identifier for humans of the data record | string |
save() | Stores the model data in the database. | bool |
test() | Returns true if there are no errors in the values of the model properties. | bool |
url() | Returns the url where to see / modify the data. | string |
saveInsert() | Insert the model data in the database. | bool |
saveUpdate() | Update the model data in the database. | bool |
getOrderBy() | Convert an array of filters order by in string. | string |
getRecord() | Read the record whose primary column corresponds to the value $cod or the first that meets the indicated condition. | array |
addExtension() | Adds an extension to this model. | mixed |
pipe() | Executes all $name methods added from the extensions. | mixed |
pipeFalse() | Executes all $name methods added from the extensions until someone returns false. | bool |
primaryColumn() | Returns the name of the column that is the model's primary key. | string |
tableName() | Returns the name of the table that uses this model. | string |
__construct() | ModelClass constructor. | mixed |
changePrimaryColumnValue() | Change the value of the primary column in the model and the database. | bool |
clear() | Reset the values of all model properties. | mixed |
install() | This function is called when creating the model table. Returns the SQL that will be executed after the creation of the table. Useful to insert values default. | string |
loadFromData() | Assign the values of the $data array to the model properties. | mixed |
primaryColumnValue() | Returns the current value of the main column of the model. | mixed |
toArray() | Returns an array with the model fields values. | array |
checkTable() | Checks and updates the structure of the table if necessary. | bool |
getBoolValueForField() | Returns the boolean value for the field. | bool|null |
getFloatValueForField() | Returns the float value for the field. | float|null |
getIntegerValueForField() | Returns the integer value by controlling special cases for the PK and FK. | int|null |
toolBox() | ToolBox |
Properties
$codbarras
Barcode. Maximum 20 characters.
public
string
$codbarras
$coste
Cost price.
public
int|float
$coste
$idatributovalor1
Foreign key of table atributo_valores.
public
int
$idatributovalor1
$idatributovalor2
Foreign key of table atributo_valores.
public
int
$idatributovalor2
$idatributovalor3
Foreign key of table atributo_valores.
public
int
$idatributovalor3
$idatributovalor4
Foreign key of table atributo_valores.
public
int
$idatributovalor4
$idvariante
Primary Key, autoincremental.
public
int
$idvariante
$margen
public
float
$margen
$precio
Price of the variant. Without tax.
public
int|float
$precio
$referencia
Reference of the variant. Maximum 30 characters.
public
string
$referencia
$stockfis
Physical stock.
public
float|int
$stockfis
$fields
List of fields in the table.
protected
static array
$fields
= []
$idproducto
Product identifier.
public
int
$idproducto
$checkedTables
List of already tested tables.
private
static array
$checkedTables
= []
$dataBase
It provides direct access to the database.
protected
static DataBase
$dataBase
Methods
clear()
public
clear(
)
: mixed
Return values
mixedcodeModelSearch()
Allows to use this model as source in CodeModel special model.
public
codeModelSearch(
$query :
string
[, $fieldCode :
string
= '' ]
[, $where :
\FacturaScripts\Core\Base\DataBase\DataBaseWhere[]
= [] ]
)
: \FacturaScripts\Core\Model\CodeModel[]
Parameters
- $query : string
- $fieldCode : string = ''
- $where : \FacturaScripts\Core\Base\DataBase\DataBaseWhere[] = []
Return values
\FacturaScripts\Core\Model\CodeModel[]description()
public
description(
[ $onlyAttributes :
bool
= false ]
)
: string
Parameters
- $onlyAttributes : bool = false
Return values
stringdelete()
Remove the model data from the database.
public
delete(
)
: bool
Return values
boolgetAttributeDescription()
protected
getAttributeDescription(
$idAttVal1 :
int
, $idAttVal2 :
int
, $idAttVal3 :
int
, $idAttVal4 :
int
[, $description :
string
= '' ]
[, $separator1 :
string
= "\n" ]
[, $separator2 :
string
= ', ' ]
)
: string
Parameters
- $idAttVal1 : int
- $idAttVal2 : int
- $idAttVal3 : int
- $idAttVal4 : int
- $description : string = ''
- $separator1 : string = "\n"
- $separator2 : string = ', '
Return values
stringgetImages()
public
getImages(
)
: \FacturaScripts\Core\Model\ProductoImagen[]
Return values
\FacturaScripts\Core\Model\ProductoImagen[]install()
public
install(
)
: string
Return values
stringpriceWithTax()
public
priceWithTax(
)
: float
Return values
floatprimaryColumn()
public
static primaryColumn(
)
: string
Return values
stringprimaryDescriptionColumn()
Returns the name of the column that describes the model, such as name, description.
public
primaryDescriptionColumn(
)
: string
..
Return values
stringsave()
Stores the model data in the database.
public
save(
)
: bool
Return values
boolsetPriceWithTax()
public
setPriceWithTax(
$price :
float
)
: mixed
Parameters
- $price : float
Return values
mixedtableName()
public
static tableName(
)
: string
Return values
stringtest()
Returns true if there are no errors in the values of the model properties.
public
test(
)
: bool
It runs inside the save method.
Return values
boolurl()
Returns the url where to see / modify the data.
public
url(
[ $type :
string
= 'auto' ]
[, $list :
string
= 'List' ]
)
: string
Parameters
- $type : string = 'auto'
- $list : string = 'List'
Return values
stringsaveInsert()
Insert the model data in the database.
protected
saveInsert(
[ $values :
array
= [] ]
)
: bool
Parameters
- $values : array = []
Return values
boolgetModelFields()
Returns the list of fields in the table.
public
abstract getModelFields(
)
: array
Return values
arraymodelClassName()
Returns the name of the class of the model.
public
abstract modelClassName(
)
: string
Return values
stringmodelName()
Returns the name of the model.
protected
abstract modelName(
)
: string
Return values
stringloadModelFields()
Loads table fields if is necessary.
protected
abstract loadModelFields(
&$dataBase :
DataBase
, $tableName :
string
)
: mixed
Parameters
- $dataBase : DataBase
- $tableName : string
Return values
mixedgetProducto()
Returns related product.
public
getProducto(
)
: Producto
Return values
Productoall()
Returns all models that correspond to the selected filters.
public
all(
[ $where :
array
= [] ]
[, $order :
array
= [] ]
, $offset :
int
[, $limit :
int
= 50 ]
)
: static[]
Parameters
- $where : array = []
filters to apply to model records.
- $order : array = []
fields to use in the sorting. For example ['code' => 'ASC']
- $offset : int
- $limit : int = 50
Return values
static[]codeModelAll()
Allows to use this model as source in CodeModel special model.
public
codeModelAll(
[ $fieldCode :
string
= '' ]
)
: \FacturaScripts\Dinamic\Model\CodeModel[]
Parameters
- $fieldCode : string = ''
Return values
\FacturaScripts\Dinamic\Model\CodeModel[]codeModelSearch()
Allows to use this model as source in CodeModel special model.
public
codeModelSearch(
$query :
string
[, $fieldCode :
string
= '' ]
[, $where :
\FacturaScripts\Core\Base\DataBase\DataBaseWhere[]
= [] ]
)
: \FacturaScripts\Dinamic\Model\CodeModel[]
Parameters
- $query : string
- $fieldCode : string = ''
- $where : \FacturaScripts\Core\Base\DataBase\DataBaseWhere[] = []
Return values
\FacturaScripts\Dinamic\Model\CodeModel[]count()
Returns the number of records in the model that meet the condition.
public
count(
[ $where :
\FacturaScripts\Core\Base\DataBase\DataBaseWhere[]
= [] ]
)
: int
Parameters
- $where : \FacturaScripts\Core\Base\DataBase\DataBaseWhere[] = []
filters to apply to model records.
Return values
intdelete()
Remove the model data from the database.
public
delete(
)
: bool
Return values
boolexists()
Returns true if the model data is stored in the database.
public
exists(
)
: bool
Return values
boolget()
Returns the model whose primary column corresponds to the value $cod
public
get(
$code :
string
)
: static|bool
Parameters
- $code : string
Return values
static|boolloadFromCode()
Fill the class with the registry values whose primary column corresponds to the value $cod, or according to the condition where indicated, if value is not reported in $cod.
public
loadFromCode(
$code :
string
[, $where :
array
= [] ]
[, $order :
array
= [] ]
)
: bool
Initializes the values of the class if there is no record that meet the above conditions. Returns True if the record exists and False otherwise.
Parameters
- $code : string
- $where : array = []
- $order : array = []
Return values
boolnewCode()
Returns the following code for the reported field or the primary key of the model.
public
newCode(
[ $field :
string
= '' ]
[, $where :
array
= [] ]
)
: int
Parameters
- $field : string = ''
- $where : array = []
Return values
intprimaryDescriptionColumn()
Returns the name of the column that describes the model, such as name, description.
public
primaryDescriptionColumn(
)
: string
..
Return values
stringprimaryDescription()
Descriptive identifier for humans of the data record
public
primaryDescription(
)
: string
Return values
stringsave()
Stores the model data in the database.
public
save(
)
: bool
Return values
booltest()
Returns true if there are no errors in the values of the model properties.
public
test(
)
: bool
It runs inside the save method.
Return values
boolurl()
Returns the url where to see / modify the data.
public
url(
[ $type :
string
= 'auto' ]
[, $list :
string
= 'List' ]
)
: string
Parameters
- $type : string = 'auto'
- $list : string = 'List'
Return values
stringsaveInsert()
Insert the model data in the database.
protected
saveInsert(
[ $values :
array
= [] ]
)
: bool
Parameters
- $values : array = []
Return values
boolsaveUpdate()
Update the model data in the database.
protected
saveUpdate(
[ $values :
array
= [] ]
)
: bool
Parameters
- $values : array = []
Return values
boolgetOrderBy()
Convert an array of filters order by in string.
private
getOrderBy(
$order :
array
)
: string
Parameters
- $order : array
Return values
stringgetRecord()
Read the record whose primary column corresponds to the value $cod or the first that meets the indicated condition.
private
getRecord(
$code :
string
[, $where :
array
= [] ]
[, $order :
array
= [] ]
)
: array
Parameters
- $code : string
- $where : array = []
- $order : array = []
Return values
arrayaddExtension()
Adds an extension to this model.
public
abstract static addExtension(
$extension :
mixed
)
: mixed
Parameters
- $extension : mixed
Return values
mixedpipe()
Executes all $name methods added from the extensions.
public
abstract pipe(
$name :
string
, ...$arguments :
array
)
: mixed
Parameters
- $name : string
- $arguments : array
Return values
mixedpipeFalse()
Executes all $name methods added from the extensions until someone returns false.
public
abstract pipeFalse(
$name :
string
, ...$arguments :
array
)
: bool
Parameters
- $name : string
- $arguments : array
Return values
boolprimaryColumn()
Returns the name of the column that is the model's primary key.
public
abstract static primaryColumn(
)
: string
Return values
stringtableName()
Returns the name of the table that uses this model.
public
abstract static tableName(
)
: string
Return values
string__construct()
ModelClass constructor.
public
__construct(
[ $data :
array
= [] ]
)
: mixed
Parameters
- $data : array = []
Return values
mixedchangePrimaryColumnValue()
Change the value of the primary column in the model and the database.
public
changePrimaryColumnValue(
$newValue :
mixed
)
: bool
Parameters
- $newValue : mixed
Return values
boolclear()
Reset the values of all model properties.
public
clear(
)
: mixed
Return values
mixedinstall()
This function is called when creating the model table. Returns the SQL that will be executed after the creation of the table. Useful to insert values default.
public
install(
)
: string
Return values
stringloadFromData()
Assign the values of the $data array to the model properties.
public
loadFromData(
[ $data :
array
= [] ]
[, $exclude :
array
= [] ]
)
: mixed
Parameters
- $data : array = []
- $exclude : array = []
Return values
mixedprimaryColumnValue()
Returns the current value of the main column of the model.
public
primaryColumnValue(
)
: mixed
Return values
mixedtoArray()
Returns an array with the model fields values.
public
toArray(
)
: array
Return values
arraycheckTable()
Checks and updates the structure of the table if necessary.
private
checkTable(
)
: bool
Return values
boolgetBoolValueForField()
Returns the boolean value for the field.
private
getBoolValueForField(
$field :
array
, $value :
mixed
)
: bool|null
Parameters
- $field : array
- $value : mixed
Return values
bool|nullgetFloatValueForField()
Returns the float value for the field.
private
getFloatValueForField(
$field :
array
, $value :
string
)
: float|null
Parameters
- $field : array
- $value : string
Return values
float|nullgetIntegerValueForField()
Returns the integer value by controlling special cases for the PK and FK.
private
getIntegerValueForField(
$field :
array
, $value :
string
)
: int|null
Parameters
- $field : array
- $value : string
Return values
int|nulltoolBox()
protected
static toolBox(
)
: ToolBox