Пример #1
0
 /**
  * Returns a new form for adding permissions to the specified user.
  *
  * @param User $user
  *
  * @return \Orchestra\Contracts\Html\Builder
  */
 public function formPermissions(User $user)
 {
     return $this->form->of('users.permissions', function (FormGrid $form) use($user) {
         $method = 'POST';
         $url = route('admin.users.permissions.store', [$user->getKey()]);
         $form->attributes(compact('method', 'url'));
         $form->with($user);
         $form->layout('admin.components.form-modal');
         $form->submit = 'Save';
         $form->fieldset(function (Fieldset $fieldset) {
             $fieldset->control('input:select', 'permissions[]')->label('Permissions')->options(function (User $user) {
                 // We'll only allow users to select permissions that
                 // aren't apart of the current role.
                 return Permission::whereDoesntHave('users', function (Builder $builder) use($user) {
                     $builder->whereEmail($user->email);
                 })->get()->pluck('label', 'id');
             })->attributes(['class' => 'select-users', 'multiple' => true]);
         });
     });
 }