/** * 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; }
/** * @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); }
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); }