本文整理汇总了PHP中app\Permission::all方法的典型用法代码示例。如果您正苦于以下问题:PHP Permission::all方法的具体用法?PHP Permission::all怎么用?PHP Permission::all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Permission
的用法示例。
在下文中一共展示了Permission::all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCreate
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function getCreate(Request $request)
{
// Get all the available permissions
$permissions = $this->permission->all();
// Selected permissions
$selectedPermissions = $request->old('permissions', array());
// Title
$title = 'Create role';
// Show the page
return view('core.admin.roles.create', compact('permissions', 'selectedPermissions', 'title'));
}
示例2: canRefence
/**
* Checking if the given user can reference the given uri.
*
* @param $user
* @param $uri
* @return bool
*/
public function canRefence($user, $uri)
{
$permissions = $this->permission->all();
foreach ($permissions as $permission) {
if ($user->can($permission->name)) {
$routes = $this->permissionRoute->where('permission_id', '=', $permission->id)->get();
foreach ($routes as $route) {
if ($route->route == $uri) {
return true;
}
}
}
}
return false;
}
示例3: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
$role = Role::findOrFail($id);
$permissions = Role::findOrFail($id)->permissions()->get();
$all_permissions = Permission::all();
return view('pages.admin_pages.role')->with('role', $role)->with('all_permissions', $all_permissions)->with('permissions', $permissions);
}
示例4: edit
/**
* edit data page
* @param int id
* @return view
*/
public function edit($id)
{
$role = Role::findOrFail($id);
$role_permission = DB::table('permission_role')->where('role_id', $id)->select('permission_id')->get();
$permission = Permission::all(['id', 'name']);
return view('admin.role.edit', compact('role', 'role_permission', 'permission'));
}
示例5: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Role::create(['name' => 'manager_receive', 'label' => 'Manager of Receive.']);
Role::create(['name' => 'manager_requesition', 'label' => 'Manager of Requesition.']);
Role::create(['name' => 'manager_product_list', 'label' => 'Manager of Product list.']);
Role::create(['name' => 'manager_product', 'label' => 'Manager of Product.']);
Role::create(['name' => 'manager_product_type', 'label' => 'Manager of Product Type.']);
Role::create(['name' => 'manager_unit', 'label' => 'Manager of Unit.']);
Role::create(['name' => 'manager_location', 'label' => 'Manager of Location.']);
Role::create(['name' => 'manager_project', 'label' => 'Manager of Project.']);
Role::create(['name' => 'manager_user', 'label' => 'Manager of User.']);
Permission::create(['name' => 'create_form', 'label' => 'Create of form.']);
Permission::create(['name' => 'update_form', 'label' => 'Update of form.']);
Permission::create(['name' => 'delete_form', 'label' => 'Delete of form.']);
$roles = Role::all();
$permissions = Permission::all();
foreach ($roles as $role) {
foreach ($permissions as $permission) {
$role->givePermissionTo($permission);
}
}
$user = User::whereEmail('n_vasit@hotmail.com')->first();
foreach ($roles as $role) {
$user->assignRole($role->name);
}
$user = User::whereEmail('akarin@mixed.co.th')->first();
foreach ($roles as $role) {
$user->assignRole($role->name);
}
}
示例6: index
/**
* Table of all roles and their permissions
*
* @return \Illuminate\View\View
*/
public function index()
{
$roles = Role::all();
$permissions = Permission::all();
$routes = PermissionRoute::select('route', 'id', 'permission_id')->get();
return view('rbac-gui.roles_permissions.index', compact('roles', 'permissions', 'routes'));
}
示例7: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
//
$usergroup = \App\Usergroup::findOrFail($id);
$permissions = \App\Permission::all();
return view('usergroups.edit', compact('usergroup', 'permissions'));
}
示例8: permissions
public static function permissions($type = null, $data = null)
{
if ($type and $data) {
return Permission::where($type, $data)->get();
}
return Permission::all();
}
示例9: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
$permissions = Permission::all();
$role = Role::find($id);
$permission_role = $role->r_permission;
return View('role.edit', compact('role', 'permissions', 'permission_role'));
}
示例10: permission
public static function permission($permission, $encontristaId)
{
if (!self::guest($permission)) {
return is_null(Permission::all()->where('encontrista_id', '=', $encontristaId)->where('permission', '=', $permission)->first());
}
return true;
}
示例11: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$user;
switch (strtolower($this->option('permission'))) {
case 'admin':
$user = new User();
$user->username = 'admin';
$user->password = Hash::make('admin');
$user->email = 'admin@example.com';
$user->firstname = 'Joshua';
$user->middlename = 'Agagdan';
$user->lastname = 'Tundag';
Permission::first()->users()->save($user);
$user->save();
break;
case 'user':
$user = new User();
$user->username = 'ododz';
$user->password = Hash::make('gwapodz');
$user->email = 'odozd@gwapodz.com';
$user->firstname = 'Ododz';
$user->middlename = 'G';
$user->lastname = 'Gwapodz';
Permission::all()->get(1)->users()->save($user);
$user->save();
break;
}
return $user;
}
示例12: patchIndex
public function patchIndex(Role $role)
{
if (!$this->user->canAdminRoles() || !$this->user->canAdminPermissions()) {
return abort(403);
}
$input = Input::all();
$permissions = Permission::all();
$rolePermissions = [];
$nullPermissions = [];
foreach ($permissions as $permission) {
if ($this->user->can($permission->permission_id)) {
$nullPermissions[] = $permission->permission_id;
foreach ($input as $permission_id => $permission_value) {
$permission_id = str_replace("_", ".", $permission_id);
if ($permission->permission_id == $permission_id) {
switch ($permission_value) {
case "allow":
case "deny":
$rolePermissions[] = ['role_id' => $role->role_id, 'permission_id' => $permission_id, 'value' => $permission_value == "allow"];
break;
}
break;
}
}
}
}
RolePermission::where(['role_id' => $role->role_id])->whereIn('permission_id', $nullPermissions)->delete();
RolePermission::insert($rolePermissions);
return $this->view(static::VIEW_PERMISSIONS, ['role' => $role, 'permissions' => Permission::all()]);
}
示例13: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index(Request $request)
{
$permissions = Permission::all();
if ($permissions) {
return $this->respondWithCollection($permissions, new PermissionTransformer());
}
return $this->errorNotFound('No permissions found');
}
示例14: create
public function create()
{
try {
return view('Admin.roles.create', ['roles' => Rolle::all(), 'permissions' => Permission::all()]);
} catch (Exception $e) {
return redirect()->route('admin::roles::list')->withErrors($e->getMessage());
}
}
示例15: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$role = Role::create(['name' => 'Admin']);
foreach (Permission::all() as $permission) {
$role->permissions()->save($permission);
}
Role::create(['name' => 'User']);
}