opensupports/server/controllers/user/get-user.php

31 lines
877 B
PHP
Raw Normal View History

2016-11-30 18:13:57 +01:00
<?php
use Respect\Validation\Validator as DataValidator;
DataValidator::with('CustomValidations', true);
2016-11-30 21:30:00 +01:00
class GetUserByIdController extends Controller {
2016-11-30 18:13:57 +01:00
const PATH = '/get-user';
public function validations() {
return [
'permission' => 'staff_2',
'requestData' => [
'userId' => [
'validation' => DataValidator::dataStoreId('user'),
'error' => ERRORS::INVALID_USER
]
]
];
}
public function handler() {
$userId = Controller::request('userId');
$user = User::getDataStore($userId);
Response::respondSuccess([
'name' => $user->name,
'email' => $user->email,
'signupDate' => $user->signupDate,
'tickets' => $user->sharedTicketList->toArray()
]);
}
}