本文整理汇总了PHP中app\models\Role::with方法的典型用法代码示例。如果您正苦于以下问题:PHP Role::with方法的具体用法?PHP Role::with怎么用?PHP Role::with使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Role
的用法示例。
在下文中一共展示了Role::with方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
/**
* Displays the specified role.
*
* @return \Illuminate\View\View
*/
public function show($id)
{
$this->authorize('admin.roles.show');
$role = $this->role->with('users')->findOrFail($id);
$users = $this->presenter->tableUsers($role);
$formUsers = $this->presenter->formUsers($role);
$permissions = $this->presenter->tablePermissions($role);
$formPermissions = $this->presenter->formPermissions($role);
return view('admin.roles.show', compact('role', 'users', 'formUsers', 'permissions', 'formPermissions'));
}
示例2: getAllRoles
/**
* @param string $order_by
* @param string $sort
* @param bool $withPermissions
* @return mixed
*/
public function getAllRoles($order_by = 'id', $sort = 'asc', $withPermissions = false)
{
if ($withPermissions) {
return Role::with('permissions')->orderBy($order_by, $sort)->get();
}
return Role::orderBy($order_by, $sort)->get();
}
示例3: getAllRoles
public function getAllRoles($relationships = null)
{
if (isset($relationships)) {
return Role::with($relationships)->get();
}
return Role::all();
}
示例4: postRegister
/**
* Handle a registration request for the application.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function postRegister(Request $request)
{
$validator = $this->validator($request->all());
if ($validator->fails()) {
$this->throwValidationException($request, $validator);
}
Auth::login($this->create($request->all()));
$roleid = new RoleUser();
$roleid->role_id = 3;
$roleid->user_id = Auth::user()->id;
$roleid->save();
// Log::alert($roleid[0]);
$permit = Role::with('perms')->where('id', $roleid->role_id)->get();
// Log::info($permit[0]->perms);
// Log::alert(json_encode($child));
$menus = [];
foreach ($permit[0]->perms as $detail) {
if ($detail->parent == '0') {
$menu = array();
foreach ($permit[0]->perms as $child) {
if ($child->parent == $detail->id) {
array_push($menu, $child);
}
}
$detail = array_add($detail, 'child', $menu);
array_push($menus, $detail);
}
}
//Log::info($menus);
Session::set('menu', $menus);
return redirect($this->redirectPath());
}
示例5: getUserAuthList
/**
* 获取角色权限组和权限列表
* @param $role_id
* @return mixed
*/
public static function getUserAuthList($role_id)
{
$authGroup = Role::with('roleGroup')->where('role_id', '=', $role_id)->first();
$authList = AuthGroupRelaionship::getAuthGroupRelationshipByGroupLabel($authGroup->roleGroup->group_label);
$data['authGroup'] = $authGroup->roleGroup;
$data['authList'] = $authList;
return $data;
}
示例6: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
if ($result = check_auth_to('JSLB_INDEX')) {
return $result;
}
$site = Config::get('site');
$data['roleList'] = Role::with('roleGroup')->paginate($site['page_size']);
return view('admin.role.index', $data);
}
示例7: postLogin
/**
* Handle a login request to the application.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function postLogin(Request $request)
{
$this->validate($request, [$this->loginUsername() => 'required', 'password' => 'required']);
$throttles = in_array(ThrottlesLogins::class, class_uses_recursive(get_class($this)));
if ($throttles && $this->hasTooManyLoginAttempts($request)) {
return $this->sendLockoutResponse($request);
}
if (Auth::attempt($this->getCredentials($request), $request->has('remember'))) {
if ($throttles) {
$this->clearLoginAttempts($request);
}
// Log::info(Auth::user()->hasRole('admin'));
// Log::info(Auth::user()->can('ui_features'));
$roleid = RoleUser::where('user_id', Auth::user()->id)->get();
// Log::alert($roleid[0]);
$permit = Role::with('perms')->where('id', $roleid[0]->role_id)->get();
// Log::info($permit[0]->perms);
// Log::alert(json_encode($child));
$menus = [];
foreach ($permit[0]->perms as $detail) {
if ($detail->parent == '0') {
$menu = array();
foreach ($permit[0]->perms as $child) {
if ($child->parent == $detail->id) {
array_push($menu, $child);
}
}
$detail = array_add($detail, 'child', $menu);
array_push($menus, $detail);
}
}
//Log::info($menus);
Session::set('menu', $menus);
return redirect()->intended($this->redirectPath());
}
if ($throttles) {
$this->incrementLoginAttempts($request);
}
return redirect($this->loginPath())->withInput($request->only($this->loginUsername(), 'remember'))->withErrors([$this->loginUsername() => $this->getFailedLoginMessage()]);
}
示例8: index
public function index()
{
// Get all Role records for current page.
$roles = Role::with('users')->paginate(25);
return $this->getView()->shares('title', __d('users', 'Roles'))->with('roles', $roles);
}
示例9: index
public function index()
{
// Get all Role records for current page - used with the Extended Auth Driver.
$roles = Role::with('users')->paginate(25);
return $this->getView()->shares('title', __('Roles'))->with('roles', $roles);
}
示例10: manageableRolesForUser
private function manageableRolesForUser()
{
$roles = $this->roleResultToList(Role::with('perms')->get());
if (Entrust::can(PermissionNames::ManageGlobalPermissions())) {
return $roles;
}
//Filter out global permissions
$roles = array_filter($roles, function ($r) {
$globalPerms = PermissionNames::AllGlobalPermissions();
foreach ($r->perms as $p) {
if (in_array($p->name, $globalPerms)) {
return false;
}
}
return true;
});
$confPermNamePart = PermissionNames::normalizePermissionName(PermissionNames::ConferencePermissionManagement(1));
$evtPermNamePart = PermissionNames::normalizePermissionName(PermissionNames::EventPermissionManagement(1));
//Get the permissions this user has which are permissions management
//permissions
$currentPermManagement = Permission::whereHas("roles", function ($query) {
$query->whereHas("users", function ($query) {
//on Account table
$query->where("id", Auth::user()->id);
});
})->where(function ($query) use($confPermNamePart, $evtPermNamePart) {
$query->where('name', 'like', $confPermNamePart . '%');
$query->orWhere('name', 'like', $evtPermNamePart . '%');
})->get();
$conferences = [];
$events = [];
foreach ($currentPermManagement as $perm) {
if (PermissionNames::isConferencePermission($perm->name)) {
$conferences[] = PermissionNames::extractPermissionData($perm->name)->idPart;
} else {
$events[] = PermissionNames::extractPermissionData($perm->name)->idPart;
}
}
$ownedEvents = Event::whereIn('conferenceID', $conferences)->select('id')->get();
$ownedEvents = array_map(function ($e) {
return $e['id'];
}, $ownedEvents->toArray());
$events = array_merge($events, $ownedEvents);
//Filter out permissions not associated with the conferences/events
//this user can control.
$roles = array_filter($roles, function ($r) use($events, $conferences) {
foreach ($r->perms as $p) {
if (PermissionNames::isConferencePermission($p->name)) {
$confId = PermissionNames::extractPermissionData($p->name)->idPart;
if (!in_array($confId, $conferences)) {
return false;
}
} else {
if (PermissionNames::isEventPermission($p->name)) {
$evtId = PermissionNames::extractPermissionData($p->name)->idPart;
if (!in_array($evtId, $events)) {
return false;
}
}
}
return true;
}
});
return $roles;
}
示例11: getShow
public function getShow(Request $request, $id)
{
$includes = $this->getIncludes($request);
$role = Role::with($includes)->findOrFail($id);
return response()->json(['role' => $role]);
}
示例12: getRoleAndPermissions
public function getRoleAndPermissions($role_id)
{
return Role::with('permissions')->where('id', $role_id)->first();
}
示例13: getIndex
public function getIndex()
{
$roles = Role::with('perms')->get();
return $roles;
}
示例14: create
public function create($id)
{
$user = User::with('role_users')->with('role_users.role_id')->with('role_users.permission_roles')->with('role_users.permission_roles.permissions')->find($id);
$role = Role::with('permission_role')->with('permission_role.permissions')->with('permission_role.role_user')->with('permission_role.role_user.user')->get();
return view('admin.user.addPermission', compact('user', 'role'));
}