Merged in OS-67-create-staff-datastore (pull request #52)

Ivan - Add staff DataStore
This commit is contained in:
Ivan Diaz 2016-09-25 01:31:36 -03:00
commit efdbb2c7c8
3 changed files with 54 additions and 0 deletions

View File

@ -15,6 +15,7 @@ class InitSettingsController extends Controller {
$this->storeGlobalSettings(); $this->storeGlobalSettings();
$this->storeMailTemplates(); $this->storeMailTemplates();
$this->storeMockedDepartments(); $this->storeMockedDepartments();
$this->createMockedStaff();
Response::respondSuccess(); Response::respondSuccess();
} else { } else {
@ -80,4 +81,18 @@ class InitSettingsController extends Controller {
$department->store(); $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; 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);
}
}