本文整理汇总了PHP中app\models\Role::whereIn方法的典型用法代码示例。如果您正苦于以下问题:PHP Role::whereIn方法的具体用法?PHP Role::whereIn怎么用?PHP Role::whereIn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Role
的用法示例。
在下文中一共展示了Role::whereIn方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteEventRoles
public static function deleteEventRoles($eventIdList)
{
if (!is_array($eventIdList)) {
$eventIdList = [$eventIdList];
}
$rnames = [];
foreach ($eventIdList as $e) {
$rnames = array_merge($rnames, PermissionNames::AllEventPermissions($e));
$rnames[] = RoleNames::EventManager($e);
}
Role::whereIn('name', $rnames)->delete();
}
示例2: doAccountRoleChange
private function doAccountRoleChange($roleNames, $alterUsing)
{
$roles = Role::whereIn("name", $roleNames)->get();
if (count($roles) != sizeof($roleNames)) {
return false;
}
$alterUsing($roles);
return true;
}
示例3: down
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Permission::whereIn('name', ['view.admin', 'update.application'])->delete();
Role::whereIn('name', ['administrator', 'manager'])->delete();
}
示例4: edit
/**
* Permite crear un registro de usuario
*
* @param Request $request
* @param integer $id
* @return Response View
*/
public function edit(Request $request, $id = 0)
{
$usuario = Usuario::find($id);
$roles = Role::whereIn('id', [1, 2]);
return view('super.usuarios.edit')->withUsuario($usuario)->withRoles($roles);
}
示例5: putRolesUpdate
public function putRolesUpdate($id, Request $request)
{
$user = $this->repo->findOrFail($id);
$this->validate($request, ['roles' => 'array']);
// fetch an id list array of the permissions we need
$roles = Role::whereIn('name', $request->get('roles', []))->get();
$ids = [];
foreach ($roles as $role) {
$ids[] = $role->id;
}
// sync to current user
$user->roles()->sync($ids);
return response()->json(['status' => 'success', 'message' => trans('api.resource_updated', ['resource' => trans('global.user')])])->setStatusCode(200);
}
示例6: CrudCoach
public function CrudCoach()
{
$activo = array(1 => 'Si', 0 => 'No');
$edit = DataEdit::source(new User());
$edit->add('name', 'Nombre', 'text')->rule('required');
$edit->add('last_name', 'Apellidos', 'text')->rule('required');
$edit->add('email', 'Email', 'text')->rule('required');
$edit->add('cuenta_activa', 'Activo', 'select')->options($activo);
$edit->add('roles', 'Roles', 'checkboxgroup')->options(Role::whereIn('id', [2, 5])->lists('display_name', 'id'));
$edit->add('imagen_perfil', 'Imagen', 'image')->rule('mimes:jpeg,png')->move('uploads/users_images/');
$edit->add('rut', 'Rut', 'text')->rule('required');
return $edit->view('coach.crud', compact('edit'));
}