Skip to content
This repository was archived by the owner on Mar 18, 2022. It is now read-only.

Commit

Permalink
Merge pull request #57 from Kryptonit3/patch-1
Browse files Browse the repository at this point in the history
Add prefix support
  • Loading branch information
romanbican committed Jun 16, 2015
2 parents 71513da + 1b4ab1e commit c89dd6c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Bican/Roles/Traits/HasRoleAndPermission.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ public function rolePermissions()
{
if (!$roles = $this->getRoles()->lists('id')->toArray()) { $roles = []; }

return Permission::select(['permissions.*', 'permission_role.created_at as pivot_created_at', 'permission_role.updated_at as pivot_updated_at'])
->join('permission_role', 'permission_role.permission_id', '=', 'permissions.id')->join('roles', 'roles.id', '=', 'permission_role.role_id')
->whereIn('roles.id', $roles) ->orWhere('roles.level', '<', $this->level())
->groupBy('permissions.id');
return Permission::select([config('roles.prefix') . 'permissions.*', config('roles.prefix') . 'permission_role.created_at as pivot_created_at', config('roles.prefix') . 'permission_role.updated_at as pivot_updated_at'])
->join(config('roles.prefix') . 'permission_role', config('roles.prefix') . 'permission_role.permission_id', '=', config('roles.prefix') . 'permissions.id')->join(config('roles.prefix') . 'roles', config('roles.prefix') . 'roles.id', '=', config('roles.prefix') . 'permission_role.role_id')
->whereIn(config('roles.prefix') . 'roles.id', $roles) ->orWhere(config('roles.prefix') . 'roles.level', '<', $this->level())
->groupBy(config('roles.prefix') . 'permissions.id');
}

/**
Expand Down
11 changes: 11 additions & 0 deletions src/config/roles.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
<?php

return [

/*
|--------------------------------------------------------------------------
| Database Table Prefix
|--------------------------------------------------------------------------
|
| If your tables have a prefix you may specify that here.
|
*/

'prefix' => '',

/*
|--------------------------------------------------------------------------
Expand Down

0 comments on commit c89dd6c

Please sign in to comment.