本文整理汇总了PHP中app\models\Role::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Role::get方法的具体用法?PHP Role::get怎么用?PHP Role::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Role
的用法示例。
在下文中一共展示了Role::get方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
/**
* Display linked records of the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
// get all -- USERS -- with this specific role id
$role = Role::find($id);
$heading = 'User Management - Show ' . ucfirst($role->name) . 's';
return view('admin.users', ['users' => $role->users()->get(), 'heading' => $heading, 'roles' => Role::get(), 'instruments' => Instrument::get()]);
}
示例2: show
public function show($id)
{
if (Auth::user()->can('read-group')) {
$data['group'] = Group::find($id);
$data['title'] = "Group \"" . $data['group']->display_name . "\"";
$roles = Role::get();
$roles_in_group = Role::whereHas('groups', function ($q) use($id) {
$q->where('groups.id', $id);
})->get();
$counter = 0;
foreach ($roles as $role) {
$is_in_group = false;
foreach ($roles_in_group as $role_in_group) {
if ($role->id == $role_in_group->id) {
$is_in_group = true;
}
}
$data['roles'][$counter] = $role;
$data['roles'][$counter]['is_in_group'] = $is_in_group;
$counter++;
}
$data['menu_actions'] = [Form::editItem(route('groups.edit', $id), 'Edit This Group', Auth::user()->can('update-group'))];
return view('groups/show', $data);
} else {
return redirect()->back()->withErrors(['Access denied to groups show page']);
}
}
示例3: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
if (Role::get()->count() == 0) {
Role::create(['name' => 'admin', 'display_name' => 'Admin', 'description' => 'User can adminstrate the site']);
Role::create(['name' => 'user', 'display_name' => 'User', 'description' => 'User can navigate the site']);
}
if (User::get()->count() == 0) {
User::create(['name' => env('ROOT_USER_NAME', 'Test User'), 'email' => env('ROOT_USER_EMAIL', 'testuser@test.com'), 'password' => Hash::make(env('ROOT_USER_PASSWORD', 'password'))])->attachRole(Role::where('name', '=', 'admin')->first());
}
}
示例4: show
/**
* Display linked records of the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
// get all -- USERS -- with this specific instrument id
$instrument = Instrument::find($id);
if ($instrument) {
$heading = 'User Management - Users playing ' . ucfirst($instrument->name);
return view('admin.users', ['users' => $instrument->users()->get(), 'heading' => $heading, 'roles' => Role::get(), 'instruments' => Instrument::get()]);
}
$message = 'Error! Instrument with ID "' . $id . '" not found';
return \Redirect::route($this->view_idx)->with(['status' => $message]);
}
示例5: edit
public function edit()
{
$user = User::find(Input::get('id'));
$action = "admin.systemusers.save";
$roles = Role::get(['id', 'display_name'])->toArray();
$roles_name = ["" => "Please Select"];
foreach ($roles as $role) {
$roles_name[$role['id']] = $role['display_name'];
}
return view(Config('constants.adminSystemUsersView') . '.addEdit', compact('user', 'action', 'roles_name'));
}
示例6: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Role::create(['name' => 'Admin', 'display_name' => '超级管理员']);
Role::create(['name' => 'Editor', 'display_name' => '编辑']);
Role::create(['name' => 'Demo', 'display_name' => '演示']);
Role::get()->each(function ($role) {
if ($role->name === 'Admin') {
$permissions = Permission::get()->pluck('id')->all();
$role->perms()->sync($permissions);
}
if ($role->name === 'Editor') {
$permissions = Permission::where('name', 'manage_contents')->first();
$role->perms()->sync([$permissions->id]);
}
});
}
示例7: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(Request $request)
{
// show only active users
// TODO: this currently produces duplicates...
if ($request->has('active')) {
$user1 = Role::find(4)->users()->get();
$users = Role::find(5)->users()->get();
foreach ($user1 as $value) {
$users->prepend($value);
}
$heading = 'Show Active Users';
return view($this->view_all, ['users' => $users, 'heading' => $heading, 'roles' => Role::get(), 'instruments' => Instrument::get()]);
}
// get all users in the requested order (default by id)
$users = User::orderBy(isset($request->orderby) ? $request->orderby : 'id', isset($request->order) ? $request->order : 'asc');
$heading = 'User Management';
// check if user selected a filter
if ($request->has('filterby') && $request->has('filtervalue') && $request->filtervalue != 'all') {
if ($request->filterby == 'role') {
// get all -- USERS -- with this specific role id
$role = Role::find($request->filtervalue);
$users = $role->users();
$heading = 'User Management - Show ' . ucfirst($role->name) . 's';
} else {
if ($request->filterby == 'instrument') {
// get all -- USERS -- with this specific instrument id
$instrument = Instrument::find($request->filtervalue);
$users = $instrument->users();
$heading = 'User Management - Show users playing ' . ucfirst($instrument->name);
} else {
$users = $users->where($request->filterby, $request->filtervalue);
}
}
}
return view($this->view_all, ['users' => $users->get(), 'heading' => $heading, 'roles' => Role::get(), 'instruments' => Instrument::get()]);
}
示例8: EditView
public function EditView($id)
{
if (!is_null($id)) {
if (Auth::check()) {
if (in_array('ADD_EDIT_USER', $this->permission)) {
$user_obj = User::with('getCompany')->find($id);
if (User::isSuperAdmin()) {
$company_obj = Company::all();
$role_obj = Role::get();
} else {
$company_obj = User::with('getCompany')->find(Auth::user()->id);
$role_obj = Role::where('id', '>', 1)->get();
}
return view('user.edit')->with('user_obj', $user_obj)->with('company_obj', $company_obj)->with('role_obj', $role_obj);
}
return \Redirect::back()->withErrors(['success' => false, 'msg' => 'You don\'t have permission']);
}
return Redirect::to(url('user/login'));
}
return \Redirect::back()->withErrors(['success' => false, 'msg' => 'somethings went wrongs']);
}
示例9: assign_per_role
public function assign_per_role()
{
$roles = Role::get(['id', 'name']);
$permissions = Permission::get(['id', 'name']);
return view('assign_per_role', compact('roles', 'permissions'));
}
示例10: index
/**
* Muestra el listado de roles.
*
* @return Response
*/
public function index()
{
$role = Role::get();
return response()->json(["msg" => "Success", "items" => $role], 200);
}