Ejemplo n.º 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'] : '']);
 }