From dea6bd0e2edfbcdc91b65085893df8a44ce333d8 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 5 Mar 2016 19:44:23 +0100 Subject: [PATCH] Employee preparation --- Models/Employee.php | 73 +++++---------------------------------- Models/EmployeeMapper.php | 30 ++++++++++------ 2 files changed, 27 insertions(+), 76 deletions(-) diff --git a/Models/Employee.php b/Models/Employee.php index 266501d..35d1fdb 100644 --- a/Models/Employee.php +++ b/Models/Employee.php @@ -28,7 +28,7 @@ use Modules\Admin\Models\Account; * @link http://orange-management.com * @since 1.0.0 */ -class Employee extends Account { +class Employee { /** * Employee ID. @@ -36,73 +36,16 @@ class Employee extends Account { * @var int * @since 1.0.0 */ - private $employeeId = 0; + private $id = 0; - public function getInstance($id) + private $account = null; + + public function setAccount(Account $account) { - if (!isset(self::$instances[$id])) { - self::$instances[$id] = new self($id); - } - - return self::$instances[$id]; + $this->account = $account; } - /** - * {@inheritdoc} - */ - public function init($id) - { - } - - /** - * {@inheritdoc} - */ - public function __clone() - { - } - - public function setUser($id) - { - $this->user = new User($id); - } - - /** - * {@inheritdoc} - */ - public function serialize() - { - // TODO: Implement serialize() method. - } - - /** - * {@inheritdoc} - */ - public function unserialize($serialized) - { - // TODO: Implement unserialize() method. - } - - /** - * {@inheritdoc} - */ - public function delete() - { - // TODO: Implement delete() method. - } - - /** - * {@inheritdoc} - */ - public function create() - { - // TODO: Implement create() method. - } - - /** - * {@inheritdoc} - */ - public function update() - { - // TODO: Implement update() method. + public function getAccount() : Account { + return $this->account; } } diff --git a/Models/EmployeeMapper.php b/Models/EmployeeMapper.php index 4ecb4a5..973f439 100644 --- a/Models/EmployeeMapper.php +++ b/Models/EmployeeMapper.php @@ -17,7 +17,7 @@ namespace Modules\Admin\Models; use phpOMS\DataStorage\Database\DataMapperAbstract; -class EmployeeMapper extends AccountMapper +class EmployeeMapper { /** @@ -27,8 +27,24 @@ class EmployeeMapper extends AccountMapper * @since 1.0.0 */ protected static $columns = [ - 'hr_staff_id' => ['name' => 'account_id', 'type' => 'int', 'internal' => 'id'], - 'hr_staff' => ['name' => 'account_status', 'type' => 'int', 'internal' => 'status'], + 'hr_staff_id' => ['name' => 'hr_staff_id', 'type' => 'int', 'internal' => 'id'], + 'hr_staff' => ['name' => 'hr_staff', 'type' => 'int', 'internal' => 'account'], + ]; + + protected static $ownsOne = [ + 'account' => [ + 'mapper' => '\Modules\Admin\Models\AccountMapper', + 'src' => 'hr_staff', + ], + ]; + + protected static $hasMany = [ + 'position' => [ + 'mapper' => '', + 'table' => '', + 'src' => '', + 'dst' => '', + ], ]; /** @@ -46,12 +62,4 @@ class EmployeeMapper extends AccountMapper * @since 1.0.0 */ protected static $primaryField = 'hr_staff_id'; - - /** - * Overwriting extended - * - * @var bool - * @since 1.0.0 - */ - protected static $overwrite = false; }