本文整理汇总了PHP中app\Role::all方法的典型用法代码示例。如果您正苦于以下问题:PHP Role::all方法的具体用法?PHP Role::all怎么用?PHP Role::all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Role
的用法示例。
在下文中一共展示了Role::all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: roles
public static function roles($type = null, $data = null)
{
if ($type and $data) {
return Role::where($type, $data)->get();
}
return Role::all();
}
示例2: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$users = User::with('roles')->get();
$roles = Role::all();
return view('rbac.user')->with(['users' => $users, 'roles' => $roles]);
// return view('rbac.user');
}
示例3: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
$user = User::find($id);
$roles = $user->roles()->get();
$all_roles = Role::all();
return view('pages.admin_pages.user')->with('user', $user)->with('roles', $roles)->with('all_roles', $all_roles);
}
示例4: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
//
$role = Role::all();
$user = User::find($id);
return view('backend.pages.users.profile', array('user' => $user, 'role' => $role));
}
示例5: roles
public function roles()
{
if (!\Session::get('user')->is_admin()) {
abort(401);
}
return view('roles/index', ['roles' => Role::all()]);
}
示例6: create
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
$mainItems = DB::table('menus')->where('is_main', 1)->get();
// dd($mainItems);
$roles = Role::all();
return view('menu.create', ['roles' => $roles, 'mainItems' => $mainItems]);
}
示例7: index
public function index(Request $request)
{
//SE REGISTRA LA ACTIVIDAD EN LA BITACORA
$this->binnacle("ENTRÓ A LA LISTA DE ROLES", $request);
$roles = Role::all();
return view('role.index', compact('roles'));
}
示例8: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($user = $request->user()) {
//判断是不是管理员
$userRoles = Role::all();
foreach ($userRoles as $r) {
$roles[] = $r->name;
}
if (!$user->hasRole($roles)) {
redirect()->guest('auth/login');
}
//创始人拥有所有权限
if (!$user->hasRole('Founder')) {
$can = Route::currentRouteName();
//当前routeName exp:user.test
$res = $request->user()->can($can);
if (!$res) {
return view('admin.noaccess');
}
}
} else {
return redirect()->guest('auth/login');
}
return $next($request);
}
示例9: editRoles
public function editRoles($userId = null)
{
if (is_null($userId)) {
return editRoles(Auth::id());
}
//if you can't edit roles, abort.
if (!Gate::allows('edit-roles')) {
abort(403);
}
$user = User::find($userId);
//example posted data: adminRole=Add
Role::all()->each(function ($role) {
if (Input::has($role->description . "Role")) {
Input::get($role->description . "Role");
$action = Input::get($inputName);
if ($action === "Add") {
$user->roles()->attach($role);
} elseif ($action === "Remove") {
$user->roles()->detach($role);
} else {
Redirect::to('/error/whatAreYouEvenTryingToDo');
}
}
});
return Redirect::to('/user/' . $user->id);
}
示例10: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$roles = Role::all();
$actions = ActionSchema::getActionSchema($this->module);
//return Feature::test();
return view('backend.role.index')->with('content_title', "Manage Roles")->with('actions', $actions)->with('roles', $roles)->with('module', $this->module);
}
示例11: users
public function users()
{
$users = User::with('organization', 'roles')->get(['id', 'name', 'email', 'organization_id']);
$orgs = Organization::all();
$roles = Role::all();
return Datatables::of($users)->addColumn('organization', function ($user) use($orgs) {
$orgSelect = '<select name="organization" class="form-control organization" data-userid="' . $user->id . '">';
foreach ($orgs as $org) {
$select = "";
if ($org->id == $user->organization_id) {
$select = 'selected';
}
$orgSelect .= '<option value="' . $org->id . '" ' . $select . '>' . $org->name . '</option>';
}
$orgSelect .= '</select>';
//return '<a href="#edit-'.$user->id.'" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> '.$user->organization->name.'</a>';
return $orgSelect;
})->addColumn('role', function ($user) use($roles) {
$roleSelect = '<select name="organization" class="form-control role" data-userid="' . $user->id . '">';
foreach ($roles as $role) {
$select = "";
if ($user->hasRole($role->name)) {
$select = 'selected';
}
$roleSelect .= '<option value="' . $role->id . '" ' . $select . '>' . $role->display_name . '</option>';
}
$roleSelect .= '</select>';
//return '<a href="#edit-'.$user->id.'" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> '.$user->roles[0]->display_name.'</a>';
return $roleSelect;
})->removeColumn('id')->removeColumn('organization_id')->make(true);
}
示例12: index
/**
* Displays the users dashboard.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$roles = Role::all();
$institutionsTeach = Auth::user()->institutions(1)->get();
$institutionsMod = Auth::user()->institutions(2)->get();
return view('user.dashboard')->with('roles', $roles)->with('institutionsTeach', $institutionsTeach)->with('institutionsMod', $institutionsMod);
}
示例13: roleExist
public static function roleExist($role)
{
$allRoles = Role::all();
if (is_string($role)) {
return $allRoles->contains('name', $role);
}
}
示例14: test
public function test(Request $request)
{
// $user = User::find(1);
//
// if($user->hasRole('Founder')){
// return '您是创始人'.'ID:'.$user->id;
// };
if ($request->user()) {
// $userRoles = $request->user()->roles()->get();
// foreach($userRoles as $r){
// $roles[] = $r->name;
// }
// var_dump($roles);
$userRoles = Role::all();
foreach ($userRoles as $r) {
$roles[] = $r->name;
}
if (!$request->user()->hasRole($roles)) {
return redirect()->guest('auth/login');
}
//$can = Route::currentRouteName();//当前route-name exp:user.test
$can = Route::currentRouteAction();
echo $can;
$res = $request->user()->can($can);
echo $res;
}
}
示例15: edit
public function edit($id)
{
$user = User::whereId($id)->firstOrFail();
$roles = Role::all();
$selectedRoles = $user->roles->lists('id')->toArray();
return view('backend.users.edit', compact('user', 'roles', 'selectedRoles'));
}