Ivan - Add staff DataStore [skip ci]
This commit is contained in:
parent
060f1b7a12
commit
9fadaa74f0
|
@ -15,6 +15,7 @@ class InitSettingsController extends Controller {
|
|||
$this->storeGlobalSettings();
|
||||
$this->storeMailTemplates();
|
||||
$this->storeMockedDepartments();
|
||||
$this->createMockedStaff();
|
||||
|
||||
Response::respondSuccess();
|
||||
} else {
|
||||
|
@ -80,4 +81,18 @@ class InitSettingsController extends Controller {
|
|||
$department->store();
|
||||
}
|
||||
}
|
||||
|
||||
private function createMockedStaff() {
|
||||
$staff = new Staff();
|
||||
$staff->setProperties([
|
||||
'name' => 'Emilia Clarke',
|
||||
'email' => 'staff@opensupports.com',
|
||||
'password' => Hashing::hashPassword('staff'),
|
||||
'profilePic' => 'http://i65.tinypic.com/9bep95.jpg',
|
||||
'level' => 1,
|
||||
'sharedDepartmentList' => Department::getAllDepartments(),
|
||||
'sharedTicketList' => []
|
||||
]);
|
||||
$staff->store();
|
||||
}
|
||||
}
|
|
@ -21,4 +21,15 @@ class Department extends DataStore {
|
|||
|
||||
return $departmentsNameList;
|
||||
}
|
||||
|
||||
public static function getAllDepartments() {
|
||||
$departmentsQuantity = RedBean::count(Department::TABLE);
|
||||
$departmentList = new DataStoreList();
|
||||
|
||||
for ($departmentIndex = 1; $departmentIndex <= $departmentsQuantity; ++$departmentIndex) {
|
||||
$departmentList->add(Department::getDataStore($departmentIndex));
|
||||
}
|
||||
|
||||
return $departmentList;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
class Staff extends DataStore {
|
||||
const TABLE = 'staff';
|
||||
|
||||
|
||||
public static function getProps() {
|
||||
return [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
'profilePic',
|
||||
'level',
|
||||
'sharedDepartmentList',
|
||||
'sharedTicketList'
|
||||
];
|
||||
}
|
||||
|
||||
public function getDefaultProps() {
|
||||
return [
|
||||
'level' => 1
|
||||
];
|
||||
}
|
||||
|
||||
public static function getUser($value, $property = 'id') {
|
||||
return parent::getDataStore($value, $property);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue