Attribute-mapped Active Record ORM for MariaDB/MySQL over PDO. - Attribute-driven metadata: TableName, PrimaryKey, AutoIncrement, Column, Guarded, Ignore, Required, Enum, Nullable, Length, Precision, Unique, UniqueGroup, Index, MaxLength. - Relationship mapping: BelongsTo, HasOne, HasMany, BelongsToMany with batched eager loading and a 3-level depth limit. - Orm entry point with fromArray, fromPdo, fromEnv and nested transactions. - Immutable Query with Cond operators and GroupCond grouping. - Repository read and write API, pagination, and typed exception hierarchy. - Declares PHP >=8.3; Mago and PHPStan pin the parser to 8.3. - MIT license.
33 lines
774 B
PHP
33 lines
774 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Camelia\Orm\Tests\Fixture;
|
|
|
|
use Camelia\Orm\Attribute\AutoIncrement;
|
|
use Camelia\Orm\Attribute\BelongsTo;
|
|
use Camelia\Orm\Attribute\Column;
|
|
use Camelia\Orm\Attribute\HasMany;
|
|
use Camelia\Orm\Attribute\PrimaryKey;
|
|
use Camelia\Orm\Attribute\TableName;
|
|
use Camelia\Orm\Model;
|
|
|
|
#[TableName('facturas')]
|
|
final class Factura extends Model
|
|
{
|
|
#[PrimaryKey, AutoIncrement]
|
|
public ?int $codigo = null;
|
|
|
|
public int $usuarioCodigo = 0;
|
|
|
|
#[Column('importe_total')]
|
|
public float $total = 0.0;
|
|
|
|
#[BelongsTo(Usuario::class, foreignKey: 'usuarioCodigo')]
|
|
public ?Usuario $usuario = null;
|
|
|
|
/** @var array<int, Detalle> */
|
|
#[HasMany(Detalle::class, foreignKey: 'facturaCodigo')]
|
|
public array $detalles = [];
|
|
}
|