Пример #1
0
 /**
  * Display name (convert user id to name if not custom)
  * @param string $content
  * @param array $options
  * @return int|mixed|string
  */
 public function display($content, $options = [])
 {
     if (is_numeric($content)) {
         $user = User::find($content);
     }
     return !empty($user) && $user->getName() ? $user->getName() : $content;
 }
Пример #2
0
 /**
  * @param array $action
  * @param array $options
  * @return bool
  */
 public function action($action, $options = [])
 {
     if (!empty($options['user_id'])) {
         $user = User::find($options['user_id']);
     } else {
         /** @var User $user */
         $user = $this->user();
         $options['user_id'] = $user->id;
     }
     return !empty($user) && $user->role->check_action($action, $options);
 }
Пример #3
0
 public function postDelete($userId = 0)
 {
     $error = 'User with ID ' . $userId . ' not found';
     if ($user = User::find($userId)) {
         if (Auth::user()->role->admin >= $user->role->admin && Auth::user()->id != $user->id) {
             return json_encode($user->delete());
         }
         $error = 'Can\'t remove super admin or your own account';
     }
     return Response::make($error, 500);
 }