oms-Organization/Models/Department.php
2024-03-20 07:21:23 +00:00

120 lines
2.1 KiB
PHP
Executable File

<?php
/**
* Jingga
*
* PHP Version 8.2
*
* @package Modules\Organization\Models
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\Organization\Models;
/**
* Organization department class.
*
* @package Modules\Organization\Models
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
class Department implements \JsonSerializable
{
/**
* Article ID.
*
* @var int
* @since 1.0.0
*/
public int $id = 0;
/**
* Name.
*
* @var string
* @since 1.0.0
*/
public string $name = '';
/**
* Parent
*
* @var null|self
* @since 1.0.0
*/
public ?self $parent = null;
/**
* Status
*
* @var int
* @since 1.0.0
*/
public int $status = Status::INACTIVE;
/**
* Unit this department belongs to
*
* @var Unit
* @since 1.0.0
*/
public Unit $unit;
/**
* Description.
*
* @var string
* @since 1.0.0
*/
public string $description = '';
/**
* Description.
*
* @var string
* @since 1.0.0
*/
public string $descriptionRaw = '';
/**
* Constructor
*
* @param string $name Department name
*
* @since 1.0.0
*/
public function __construct(string $name = '')
{
$this->name = $name;
$this->unit = new NullUnit();
}
/**
* {@inheritdoc}
*/
public function toArray() : array
{
return [
'id' => $this->id,
'name' => $this->name,
'status' => $this->status,
'description' => $this->description,
'descriptionRaw' => $this->descriptionRaw,
'unit' => $this->unit,
'parent' => $this->parent ?? null,
];
}
/**
* {@inheritdoc}
*/
public function jsonSerialize() : mixed
{
return $this->toArray();
}
}