opensupports/server/models/Staff.php

44 lines
1.1 KiB
PHP
Raw Normal View History

2016-09-24 21:26:37 +02:00
<?php
class Staff extends DataStore {
const TABLE = 'staff';
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);
}
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-09-24 21:26:37 +02:00
}