@@ -5,7 +5,6 @@ |
||
| 5 | 5 | use EmilMoe\Guardian\Http\Models\Role; |
| 6 | 6 | use EmilMoe\Guardian\Support\Guardian; |
| 7 | 7 | use EmilMoe\Guardian\Http\Models\Permission; |
| 8 | - |
|
| 9 | 8 | use Illuminate\Support\Facades\DB; |
| 10 | 9 | use Illuminate\Support\Collection; |
| 11 | 10 | use Illuminate\Support\Facades\Auth; |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | private function hasLocalAccess($permission, $id) |
| 110 | 110 | { |
| 111 | - if (! $id) |
|
| 111 | + if (!$id) |
|
| 112 | 112 | return false; |
| 113 | 113 | |
| 114 | 114 | $permission = Permission::where('name', $permission); |
@@ -138,11 +138,11 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | private function hasInheritAccess($permission, $id) |
| 140 | 140 | { |
| 141 | - if (! $id) |
|
| 141 | + if (!$id) |
|
| 142 | 142 | return false; |
| 143 | 143 | |
| 144 | - if (method_exists(Auth::user(), $permission .'Privilege')) |
|
| 145 | - return Auth::user()->{$permission .'Privilege'}($id); |
|
| 144 | + if (method_exists(Auth::user(), $permission.'Privilege')) |
|
| 145 | + return Auth::user()->{$permission.'Privilege'}($id); |
|
| 146 | 146 | |
| 147 | 147 | return false; |
| 148 | 148 | } |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | public function up() |
| 16 | 16 | { |
| 17 | - Schema::create(config('guardian.table.permission'), function (Blueprint $table) { |
|
| 17 | + Schema::create(config('guardian.table.permission'), function(Blueprint $table) { |
|
| 18 | 18 | $table->increments('id'); |
| 19 | 19 | $table->string('name')->unique(); |
| 20 | 20 | $table->string('table'); |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | $table->timestamps(); |
| 24 | 24 | }); |
| 25 | 25 | |
| 26 | - Schema::create(config('guardian.table.role'), function (Blueprint $table) { |
|
| 26 | + Schema::create(config('guardian.table.role'), function(Blueprint $table) { |
|
| 27 | 27 | $table->increments('id'); |
| 28 | 28 | $table->string('name'); |
| 29 | 29 | $table->boolean('locked')->default(false); |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | ->onDelete('cascade'); |
| 41 | 41 | }); |
| 42 | 42 | |
| 43 | - Schema::create(config('guardian.table.role') .'_'. config('guardian.table.permission'), function (Blueprint $table) { |
|
| 43 | + Schema::create(config('guardian.table.role').'_'.config('guardian.table.permission'), function(Blueprint $table) { |
|
| 44 | 44 | $table->integer('permission_id')->unsigned(); |
| 45 | 45 | $table->integer('role_id')->unsigned(); |
| 46 | 46 | $table->timestamps(); |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | $table->foreign('role_id')->references('id')->on(config('guardian.table.role'))->onDelete('cascade'); |
| 49 | 49 | }); |
| 50 | 50 | |
| 51 | - Schema::create(Guardian::getUserTable() .'_'. config('guardian.table.role'), function (Blueprint $table) { |
|
| 51 | + Schema::create(Guardian::getUserTable().'_'.config('guardian.table.role'), function(Blueprint $table) { |
|
| 52 | 52 | $table->integer('user_id')->unsigned(); |
| 53 | 53 | $table->integer('role_id')->unsigned(); |
| 54 | 54 | $table->timestamps(); |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | public function down() |
| 66 | 66 | { |
| 67 | - Schema::drop(config('guardian.table.permission') .'_'. config('guardian.table.role')); |
|
| 67 | + Schema::drop(config('guardian.table.permission').'_'.config('guardian.table.role')); |
|
| 68 | 68 | Schema::drop(config('guardian.table.role')); |
| 69 | 69 | Schema::drop(config('guardian.table.permission')); |
| 70 | 70 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | public static function getClientColumn() |
| 57 | 57 | { |
| 58 | - return self::getClientTable() .'_'. self::getClientKey(); |
|
| 58 | + return self::getClientTable().'_'.self::getClientKey(); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | public static function getRolesPermissionsTable() |
| 78 | 78 | { |
| 79 | - return config('guardian.table.role') .'_'. config('guardian.table.permission'); |
|
| 79 | + return config('guardian.table.role').'_'.config('guardian.table.permission'); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | /** |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | public static function getUsersRolesTable() |
| 86 | 86 | { |
| 87 | - return self::getUserTable() .'_'. config('guardian.table.role'); |
|
| 87 | + return self::getUserTable().'_'.config('guardian.table.role'); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | { |
| 23 | 23 | $this->toCollection($permission); |
| 24 | 24 | |
| 25 | - if (! $this->hasAccess($request, $permission)) |
|
| 25 | + if (!$this->hasAccess($request, $permission)) |
|
| 26 | 26 | return Guardian::restricted(); |
| 27 | 27 | |
| 28 | 28 | return $next($request); |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | private function hasAccess($request, $permission) |
| 52 | 52 | { |
| 53 | - if (! Auth::check()) |
|
| 53 | + if (!Auth::check()) |
|
| 54 | 54 | return false; |
| 55 | 55 | |
| 56 | 56 | if ($this->hasGlobalAccess($permission) || $this->hasLocalAccess($request, $permission)) |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | if (Guardian::getClientId() != $this->{Guardian::getClientColumn()}) |
| 112 | 112 | return; |
| 113 | 113 | |
| 114 | - if (! $this->users()->get()->contains($userid)) |
|
| 114 | + if (!$this->users()->get()->contains($userid)) |
|
| 115 | 115 | $this->users()->attach($userid); |
| 116 | 116 | } |
| 117 | 117 | |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | |
| 155 | 155 | $id = Permission::where('name', $permission)->first()->id; |
| 156 | 156 | |
| 157 | - if (! $this->permissions()->get()->contains($id)) |
|
| 157 | + if (!$this->permissions()->get()->contains($id)) |
|
| 158 | 158 | $this->permissions()->attach($id); |
| 159 | 159 | } |
| 160 | 160 | |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | */ |
| 189 | 189 | public function scopeClient($query) |
| 190 | 190 | { |
| 191 | - if (! Guardian::hasClients()) |
|
| 191 | + if (!Guardian::hasClients()) |
|
| 192 | 192 | return $query; |
| 193 | 193 | |
| 194 | 194 | return $query->where('client_id', Guardian::getClientId()); |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | */ |
| 26 | 26 | public function __construct() |
| 27 | 27 | { |
| 28 | - $this->rules = ['name' => 'required|unique:'. Guardian::getPermissionTable()]; |
|
| 28 | + $this->rules = ['name' => 'required|unique:'.Guardian::getPermissionTable()]; |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -1,22 +1,22 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | Route::resource('permissions', 'PermissionsController', ['only' => ['store', 'index', 'update', 'destroy', 'show']]); |
| 4 | -Route::resource('roles', 'RolesController', ['only' => ['store', 'index', 'update', 'destroy', 'show']]); |
|
| 4 | +Route::resource('roles', 'RolesController', ['only' => ['store', 'index', 'update', 'destroy', 'show']]); |
|
| 5 | 5 | |
| 6 | 6 | Route::group([ |
| 7 | 7 | 'prefix' => 'roles/{roles}/permissions', |
| 8 | 8 | 'namespace' => 'Roles', |
| 9 | - 'as' => str_replace('/', '.', config('guardian.api.url')) .'.roles.permissions.' |
|
| 9 | + 'as' => str_replace('/', '.', config('guardian.api.url')).'.roles.permissions.' |
|
| 10 | 10 | ], function() { |
| 11 | - Route::patch('add/{permissions}', ['as' => 'add', 'uses' => 'PermissionsController@add']); |
|
| 11 | + Route::patch('add/{permissions}', ['as' => 'add', 'uses' => 'PermissionsController@add']); |
|
| 12 | 12 | Route::patch('remove/{permissions}', ['as' => 'remove', 'uses' => 'PermissionsController@remove']); |
| 13 | 13 | }); |
| 14 | 14 | |
| 15 | 15 | Route::group([ |
| 16 | 16 | 'prefix' => 'roles/{roles}/users', |
| 17 | 17 | 'namespace' => 'Roles', |
| 18 | - 'as' => str_replace('/', '.', config('guardian.api.url')) .'.roles.users.' |
|
| 18 | + 'as' => str_replace('/', '.', config('guardian.api.url')).'.roles.users.' |
|
| 19 | 19 | ], function() { |
| 20 | - Route::patch('add/{users}', ['as' => 'add', 'uses' => 'UsersController@add']); |
|
| 20 | + Route::patch('add/{users}', ['as' => 'add', 'uses' => 'UsersController@add']); |
|
| 21 | 21 | Route::patch('remove/{users}', ['as' => 'remove', 'uses' => 'UsersController@remove']); |
| 22 | 22 | }); |
| 23 | 23 | \ No newline at end of file |
@@ -15,14 +15,14 @@ discard block |
||
| 15 | 15 | public function boot() |
| 16 | 16 | { |
| 17 | 17 | $this->publishes([ |
| 18 | - __DIR__ .'/config/guardian.php' => config_path('guardian.php'), |
|
| 18 | + __DIR__.'/config/guardian.php' => config_path('guardian.php'), |
|
| 19 | 19 | 'config']); |
| 20 | 20 | |
| 21 | 21 | $this->publishes([ |
| 22 | - __DIR__ .'/database/migrations/' => database_path('migrations'), |
|
| 22 | + __DIR__.'/database/migrations/' => database_path('migrations'), |
|
| 23 | 23 | 'migrations']); |
| 24 | 24 | |
| 25 | - $this->mergeConfigFrom(__DIR__ .'/config/guardian.php', 'guardian'); |
|
| 25 | + $this->mergeConfigFrom(__DIR__.'/config/guardian.php', 'guardian'); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | /** |
@@ -40,8 +40,8 @@ discard block |
||
| 40 | 40 | 'namespace' => 'EmilMoe\Guardian\Http\Controllers', |
| 41 | 41 | 'prefix' => config('guardian.api.url'), |
| 42 | 42 | 'middleware' => 'auth' |
| 43 | - ], function () { |
|
| 44 | - require __DIR__ .'/Http/routes.php'; |
|
| 43 | + ], function() { |
|
| 44 | + require __DIR__.'/Http/routes.php'; |
|
| 45 | 45 | }); |
| 46 | 46 | } |
| 47 | 47 | } |
| 48 | 48 | \ No newline at end of file |