opensupports/server/models/Staff.php

50 lines
1.3 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',
'lastLogin',
'ownStatList'
2016-09-24 21:26:37 +02:00
];
}
public function getDefaultProps() {
return [
'level' => 1,
'ownStatList' => new DataStoreList()
2016-09-24 21:26:37 +02:00
];
}
public static function getUser($value, $property = 'id') {
return parent::getDataStore($value, $property);
}
2016-12-08 18:30:19 +01:00
public function toArray() {
return [
2016-12-08 18:30:19 +01:00
'id' => $this->id,
'name' => $this->name,
'email' => $this->email,
'profilePic' => $this->profilePic,
'level' => $this->level,
'departments' => $this->sharedDepartmentList->toArray(),
'tickets' => $this->sharedTicketList->toArray(),
'lastLogin' => $this->lastLogin
];
}
2016-09-24 21:26:37 +02:00
}