oms-ItemManagement/Models/ItemMapper.php

101 lines
3.5 KiB
PHP
Executable File

<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\ItemManagement\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\ItemManagement\Models;
use Modules\Editor\Models\EditorDocMapper;
use Modules\Media\Models\MediaMapper;
use phpOMS\DataStorage\Database\DataMapperAbstract;
/**
* Item mapper class.
*
* @package Modules\ItemManagement\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class ItemMapper extends DataMapperAbstract
{
/**
* Columns.
*
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
* @since 1.0.0
*/
protected static array $columns = [
'itemmgmt_item_id' => ['name' => 'itemmgmt_item_id', 'type' => 'int', 'internal' => 'id'],
'itemmgmt_item_no' => ['name' => 'itemmgmt_item_no', 'type' => 'string', 'internal' => 'number', 'autocomplete' => true],
'itemmgmt_item_status' => ['name' => 'itemmgmt_item_status', 'type' => 'int', 'internal' => 'status'],
'itemmgmt_item_info' => ['name' => 'itemmgmt_item_info', 'type' => 'string', 'internal' => 'info'],
'itemmgmt_item_salesprice' => ['name' => 'itemmgmt_item_salesprice', 'type' => 'Serializable', 'internal' => 'salesPrice'],
'itemmgmt_item_purchaseprice' => ['name' => 'itemmgmt_item_purchaseprice', 'type' => 'Serializable', 'internal' => 'purchasePrice'],
];
protected static array $conditionals = [
];
/**
* Primary table.
*
* @var string
* @since 1.0.0
*/
protected static string $table = 'itemmgmt_item';
/**
* Primary field name.
*
* @var string
* @since 1.0.0
*/
protected static string $primaryField = 'itemmgmt_item_id';
/**
* Has many relation.
*
* @var array<string, array{mapper:string, table:string, self?:?string, external?:?string, column?:string}>
* @since 1.0.0
*/
protected static array $hasMany = [
'files' => [
'mapper' => MediaMapper::class, /* mapper of the related object */
'table' => 'itemmgmt_item_media', /* table of the related object, null if no relation table is used (many->1) */
'external' => 'itemmgmt_item_media_media',
'self' => 'itemmgmt_item_media_item',
],
'notes' => [
'mapper' => EditorDocMapper::class, /* mapper of the related object */
'table' => 'itemmgmt_item_note', /* table of the related object, null if no relation table is used (many->1) */
'external' => 'itemmgmt_item_note_doc',
'self' => 'itemmgmt_item_note_item',
],
'l11n' => [
'mapper' => ItemL11nMapper::class,
'table' => 'itemmgmt_item_l11n',
'self' => 'itemmgmt_item_l11n_item',
'conditional' => true,
'external' => null,
],
'attributes' => [
'mapper' => ItemAttributeMapper::class,
'table' => 'itemmgmt_item_attr',
'self' => 'itemmgmt_item_attr_item',
'conditional' => true,
'external' => null,
],
];
}