/** * is_admin Returns true if the logged in user is in group `Admin` * @return [boolean] */ private function is_admin() { try { // Find the Administrator group $admin = Sentry::findGroupByName('admin'); // Check if the user is in the admin group if ($this->user->inGroup($admin)) { // User is in admin group return true; } else { // User is not in Admin group return false; } } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) { // echo 'User was not found.'; return false; } catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e) { // echo 'Group was not found.'; return false; } }
/** * is_client Returns true if the logged in user is in group `Client` * @return [boolean] */ private function is_client() { try { // Find the Administrator group $client = Sentry::findGroupByName('Client'); // Check if the user is in the client group if ($this->user->inGroup($client) || $this->user->isSuperUser()) { // User is in Client group return true; } else { // User is not in Client group return false; } } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) { // echo 'User was not found.'; return false; } catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e) { // echo 'Group was not found.'; return false; } }