本文整理汇总了PHP中app\models\Role::whereDoesntHave方法的典型用法代码示例。如果您正苦于以下问题:PHP Role::whereDoesntHave方法的具体用法?PHP Role::whereDoesntHave怎么用?PHP Role::whereDoesntHave使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Role
的用法示例。
在下文中一共展示了Role::whereDoesntHave方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: formRoles
/**
* Returns a new form for adding roles to the specified permission.
*
* @param Permission $permission
*
* @return \Orchestra\Contracts\Html\Builder
*/
public function formRoles(Permission $permission)
{
return $this->form->of('permissions.roles', function (FormGrid $form) use($permission) {
$method = 'POST';
$url = route('admin.permissions.roles.store', [$permission->id]);
$form->attributes(compact('method', 'url'));
$form->with($permission);
$form->layout('components.form-modal');
$form->submit = 'Save';
$form->fieldset(function (Fieldset $fieldset) {
$fieldset->control('input:select', 'roles[]')->label('Roles')->options(function (Permission $permission) {
// We'll only allow users to select permissions that
// aren't apart of the current role.
return Role::whereDoesntHave('permissions', function (Builder $builder) use($permission) {
$builder->whereName($permission->name);
})->get()->pluck('label', 'id');
})->attributes(['class' => 'select-multiple', 'multiple' => true]);
});
});
}