Ivan - Add staff DataStore [skip ci]

This commit is contained in:
ivan 2016-09-24 16:26:37 -03:00
parent 060f1b7a12
commit 9fadaa74f0
3 changed files with 54 additions and 0 deletions

View File

@ -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();
}
}

View File

@ -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
View 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);
}
}