mirror of
https://github.com/opensupports/opensupports.git
synced 2025-07-27 15:54:23 +02:00
Merged in OS-67-create-staff-datastore (pull request #52)
Ivan - Add staff DataStore
This commit is contained in:
commit
efdbb2c7c8
@ -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;
|
||||
}
|
||||
}
|
28
server/models/Staff.php
Normal file
28
server/models/Staff.php
Normal file
@ -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…
x
Reference in New Issue
Block a user