示例#1
0
 public function register($name = 'users[]', $attributes = [])
 {
     $user_can_see_environment = cms_is_superadmin();
     if (!$user_can_see_environment) {
         $this->r_user->filterEnvironments([Environments::currentId()]);
     }
     $users = $this->r_user->all(['users.first_name', 'users.last_name', 'users.id']);
     $users_list = [];
     foreach ($users as $user) {
         $users_list[$user->id] = $user->full_name;
     }
     if (array_key_exists('all', $attributes) && $attributes['all']) {
         $users_list = [0 => trans('global.all')] + $users_list;
     }
     return $this->output('app.widgets.usersfields', ['users' => $users_list, 'name' => $name, 'value' => array_key_exists('value', $attributes) ? $attributes['value'] : '', 'old_value' => preg_replace("/[^A-Za-z0-9 ]/", '', $name), 'placeholder' => array_key_exists('placeholder', $attributes) ? trans($attributes['placeholder']) : '', 'class' => array_key_exists('class', $attributes) ? $attributes['class'] : '']);
 }
 /**
  * $> curl --header "X-Authorization: <API_KEY>"
  * http://localhost/api/v1/users?email=&name=
  *
  * @route api/v1/users
  * @type GET
  *
  * @param string name
  * @param string email
  *
  * @return mixed
  */
 public function index(UsersFilteredFormRequest $request)
 {
     $users = [];
     if (Auth::user()->hasRole('admin')) {
         $name = $request->has('name') ? $request->get('name') : null;
         $email = $request->has('email') ? $request->get('email') : null;
         if (!Auth::user()->hasRole(RolesRepositoryEloquent::ADMIN) && !Auth::user()->hasPermission(PermissionsRepositoryEloquent::SEE_ENVIRONMENT)) {
             // Force filter on current environment
             $this->r_users->filterEnvironments([Environments::currentId()]);
         }
         if (!is_null($name)) {
             $this->r_users->filterUserName($name);
         }
         if (!is_null($email)) {
             $this->r_users->filterEmail($email);
         }
         $users = $this->r_users->all();
     }
     return $this->response->withCollection($users, new $this->obj_userTransformer());
 }
示例#3
0
 public function register($name = 'roles[]', $attributes = [])
 {
     $user_can_see_environment = cms_is_superadmin();
     if (!$user_can_see_environment) {
         $this->r_roles->filterEnvironments([Environments::currentId()]);
     }
     $roles = $this->r_roles->all(['roles.display_name', 'roles.id']);
     $roles_list = [];
     foreach ($roles as $role) {
         $roles_list[$role->id] = trans($role->display_name);
     }
     if (array_key_exists('all', $attributes) && $attributes['all']) {
         $roles_list = [0 => trans('global.all')] + $roles_list;
     }
     $value = array_key_exists('value', $attributes) ? $attributes['value'] : '';
     if (array_key_exists('default', $attributes) && $attributes['default']) {
         $value = empty($value) ? [1] : $value;
     }
     return $this->output('app.widgets.rolesfields', ['roles' => $roles_list, 'name' => $name, 'value' => $value, 'old_value' => preg_replace("/[^A-Za-z0-9 ]/", '', $name), 'placeholder' => array_key_exists('placeholder', $attributes) ? trans($attributes['placeholder']) : '', 'class' => array_key_exists('class', $attributes) ? $attributes['class'] : '']);
 }