本文整理汇总了PHP中app\Permission::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Permission::get方法的具体用法?PHP Permission::get怎么用?PHP Permission::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Permission
的用法示例。
在下文中一共展示了Permission::get方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$this->command->info('Seeding permission to role associations.');
$permissions = Permission::get()->modelKeys();
// Insert default permissions.
foreach ($this->slugs() as $role_id => $slugs) {
foreach ($slugs as $slug_key => $slug_value) {
if (!is_numeric($slug_key) && (is_numeric($slug_value) || is_bool($slug_value))) {
$permission_id = $slug_key;
$permission_value = !!$slug_value;
} else {
$permission_id = $slug_value;
$permission_value = true;
}
if (in_array($permission_id, $permissions)) {
RolePermission::firstOrCreate(['role_id' => $role_id, 'permission_id' => $permission_id, 'value' => $permission_value]);
} else {
$this->command->error("Attempting to assign non-existant permission id `{$permission_id}` to role_id `{$role_id}`.");
}
}
}
// Give admin permissions.
if (count($permissions)) {
foreach ($permissions as $permission_id) {
$permission = RolePermission::firstOrNew(['role_id' => Role::ID_ADMIN, 'permission_id' => $permission_id]);
$permission->value = 1;
$permission->save();
}
}
}
示例2: run
public function run()
{
$this->command->info('Seeding permission to role associations.');
$permissions = Permission::get()->modelKeys();
// Insert default permissions.
foreach ($this->slugs() as $role_id => $slugs) {
foreach ($slugs as $slug_key => $slug_value) {
if (!is_numeric($slug_key) && (is_numeric($slug_value) || is_bool($slug_value))) {
$permission_id = $slug_key;
$permission_value = !!$slug_value;
} else {
$permission_id = $slug_value;
$permission_value = true;
}
if (in_array($permission_id, $permissions)) {
} else {
$this->command->error("Attempting to assign non-existant permission id `{$permission_id}` to role_id `{$role_id}`.");
}
}
}
// Give admin permissions.
if (count($permissions)) {
$role = Role::find(Role::ID_ADMIN);
$role->permissions()->detach();
$attachments = [];
foreach ($permissions as $permission_id) {
$attachments[] = ['permission_id' => $permission_id, 'value' => 1];
}
$role->permissions()->attach($attachments);
}
}
示例3: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
$role = Role::findOrFail($id);
$role->load('perms');
$permissions = Permission::get();
$tab = 'roles';
$columnSizes = ['sm' => [4, 8], 'lg' => [2, 10]];
return view('admin.roles.edit', compact('role', 'permissions', 'tab', 'columnSizes'));
}
示例4: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('roles')->insert(['name' => 'admin', 'display_name' => 'Administrator', 'description' => "Complete access of administration.", 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
foreach (Permission::get() as $permission) {
DB::table('permission_role')->insert(['permission_id' => $permission->id, 'role_id' => 1]);
}
DB::table('role_user')->insert(['user_id' => '1', 'role_id' => '1']);
DB::table('role_user')->insert(['user_id' => '2', 'role_id' => '1']);
}
示例5: index
public function index()
{
$tab = 'dashboard';
$users = User::get();
$usersCount = $users->count();
$activeUsers = $users->where('active', 1)->count();
$inactiveUsers = $usersCount - $activeUsers;
$roles = Role::get();
$rolesCount = $roles->count();
$usersWithRole = DB::table('role_user')->count();
$permissionsCount = Permission::get()->count();
return view('admin.dashboard', compact('tab', 'usersCount', 'activeUsers', 'inactiveUsers', 'rolesCount', 'usersWithRole', 'permissionsCount'));
}
示例6: setUp
/**
* Default preparation for each test
*/
public function setUp()
{
parent::setUp();
// Fetch the admin user.
$this->admin = User::whereAdmin()->with('roles')->with('roles.permissions')->take(1)->get()->first();
// Fetch the admin role.
$this->adminRole = Role::where('role_id', '=', Role::ID_ADMIN)->with('permissions')->first();
// Fetch a board owner.
$this->owner = User::whereOwner()->with('roles')->with('roles.permissions')->take(1)->get()->first();
// Fetch the owner role.
$this->ownerRole = $this->owner->roles->where('role', "owner")->first();
// Fetch all permissions.
$this->permissions = Permission::get();
}
示例7:
@extends('admin.layout')
@section('form_footer')
<?php
$all_permissions_arr = \App\Permission::get();
if (!isset($role_permissions_ids_arr)) {
$role_permissions_ids_arr = [];
}
?>
<div class="form-group">
<label>Привилегии</label> - <a href="/admin/permission">перейти к списку привилегий</a>
@foreach($all_permissions_arr as $permission)
<div class="checkbox">
<label>
<input type="checkbox" name="permissions[]" value="{{ $permission->id }}"{{ in_array($permission->id, $role_permissions_ids_arr) ? ' checked' : '' }}>
{{ $permission->name }} - {{ $permission->display_name }}
</label>
</div>
@endforeach
</div>
@endsection
@section('content')
@include('admin.common.edit_form', ['footer_content' => 'role_footer_content'])
@endsection
示例8: run
public function run()
{
$this->command->info('Seeding permission to role associations.');
// Insert default permissions.
foreach ($this->slugs() as $slug) {
RolePermission::firstOrCreate(['role_id' => $slug['role_id'], 'permission_id' => $slug['permission_id'], 'value' => $slug['value']]);
}
// Give admin permissions.
$permissions = Permission::get();
if (count($permissions)) {
foreach ($permissions as $permission) {
$permission = RolePermission::firstOrNew(['role_id' => Role::$ROLE_ADMIN, 'permission_id' => $permission->permission_id]);
$permission->value = 1;
$permission->save();
}
}
}
示例9: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$permissions = Permission::get();
$tab = 'permissions';
return view('admin.permissions.index', compact('permissions', 'tab'));
}
示例10: allPermissions
public function allPermissions()
{
return Permission::get(['id', 'nombre', 'modulo']);
}
示例11: editRole
public function editRole($id)
{
$role = Role::with('permissions')->findOrFail($id);
$permissions = Permission::get(['id', 'name']);
return view('admin.users.editrole', compact('role', 'permissions'));
}
示例12: index
/**
* Show the application dashboard.
*
* @return Response
*/
public function index()
{
$permissions = Permission::get();
return view('entrust.permissions.index', compact('permissions'));
}