2016-09-24 21:26:37 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class Staff extends DataStore {
|
|
|
|
const TABLE = 'staff';
|
|
|
|
|
2016-09-25 06:16:10 +02:00
|
|
|
public static function authenticate($userEmail, $userPassword) {
|
|
|
|
$user = Staff::getUser($userEmail, 'email');
|
|
|
|
|
|
|
|
return ($user && Hashing::verifyPassword($userPassword, $user->password)) ? $user : new NullDataStore();
|
|
|
|
}
|
2016-09-24 21:26:37 +02:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2016-12-07 05:37:18 +01:00
|
|
|
public function toArray() {
|
|
|
|
return [
|
|
|
|
'name'=> $this->name,
|
|
|
|
'email' => $this->email,
|
|
|
|
'profilePic' => $this->profilePic,
|
|
|
|
'level' => $this->level,
|
|
|
|
'departments' => $this->sharedDepartmentList->toArray(),
|
2016-12-08 07:21:37 +01:00
|
|
|
'tickets' => $this->sharedTicketList->toArray()
|
2016-12-07 05:37:18 +01:00
|
|
|
];
|
|
|
|
}
|
2016-09-24 21:26:37 +02:00
|
|
|
}
|