@@ -14,5 +14,5 @@ |
||
| 14 | 14 | use Modules\Authorization\Entities\Permission; |
| 15 | 15 | |
| 16 | 16 | Route::get('/me', 'UserController@show'); |
| 17 | -Route::patch('/{id}', 'UserController@update')->middleware(['permission:'.Permission::ASSIGN_ROLES]); |
|
| 18 | -Route::get('/', 'UserController@index')->middleware(['permission:'.Permission::INDEX_USERS]); |
|
| 17 | +Route::patch('/{id}', 'UserController@update')->middleware([ 'permission:'.Permission::ASSIGN_ROLES ]); |
|
| 18 | +Route::get('/', 'UserController@index')->middleware([ 'permission:'.Permission::INDEX_USERS ]); |
|
@@ -2,14 +2,14 @@ |
||
| 2 | 2 | |
| 3 | 3 | use Modules\User\Entities\User; |
| 4 | 4 | |
| 5 | -$factory->define(User::class, function (Faker\Generator $faker) { |
|
| 5 | +$factory->define(User::class, function(Faker\Generator $faker) { |
|
| 6 | 6 | return [ |
| 7 | 7 | 'identity_id' => (new \MongoDB\BSON\ObjectId())->__toString(), |
| 8 | 8 | 'name' => $faker->name, |
| 9 | 9 | 'username' => $faker->userName, |
| 10 | 10 | 'email' => $faker->unique()->safeEmail, |
| 11 | 11 | 'email_verified' => $faker->boolean, |
| 12 | - 'gender' => get_random_array_element(['male', 'female', 'unknown']), |
|
| 12 | + 'gender' => get_random_array_element([ 'male', 'female', 'unknown' ]), |
|
| 13 | 13 | 'avatar' => 'https://i1.wp.com/cdn.auth0.com/avatars/ad.png', |
| 14 | 14 | 'provider' => 'database', |
| 15 | 15 | ]; |
@@ -51,32 +51,32 @@ |
||
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | if ($unwrap) { |
| 54 | - return json_decode($content, true)['data']; |
|
| 54 | + return json_decode($content, true)[ 'data' ]; |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | return json_decode($content, true); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - protected function http(string $method, string $route, array $payload = []) |
|
| 60 | + protected function http(string $method, string $route, array $payload = [ ]) |
|
| 61 | 61 | { |
| 62 | 62 | return $this->sendRequest($method, $route, $payload, true); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - private function sendRequest(string $method, string $route, array $payload = [], $authenticated = true): \Illuminate\Foundation\Testing\TestResponse |
|
| 65 | + private function sendRequest(string $method, string $route, array $payload = [ ], $authenticated = true): \Illuminate\Foundation\Testing\TestResponse |
|
| 66 | 66 | { |
| 67 | 67 | return $this->json($method, env('API_URL').'/'.$route, $payload, $authenticated ? [ |
| 68 | 68 | 'Authorization' => 'Bearer '.$this->service->getTestUserToken()->id_token, |
| 69 | - ] : []); |
|
| 69 | + ] : [ ]); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - protected function sendRequestWithToken($token, string $method, string $route, array $payload = [], $authenticated = true): \Illuminate\Foundation\Testing\TestResponse |
|
| 72 | + protected function sendRequestWithToken($token, string $method, string $route, array $payload = [ ], $authenticated = true): \Illuminate\Foundation\Testing\TestResponse |
|
| 73 | 73 | { |
| 74 | 74 | return $this->json($method, env('API_URL').'/'.$route, $payload, $authenticated ? [ |
| 75 | 75 | 'Authorization' => 'Bearer '.$token, |
| 76 | - ] : []); |
|
| 76 | + ] : [ ]); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - protected function httpNoAuth(string $method, string $route, array $payload = []) |
|
| 79 | + protected function httpNoAuth(string $method, string $route, array $payload = [ ]) |
|
| 80 | 80 | { |
| 81 | 81 | return $this->sendRequest($method, $route, $payload, false); |
| 82 | 82 | } |
@@ -35,23 +35,23 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | $this->resolver->setDefaultConnection($this->getDatabase()); |
| 37 | 37 | |
| 38 | - Model::unguarded(function () { |
|
| 38 | + Model::unguarded(function() { |
|
| 39 | 39 | $seeders = $this->getSeeders(); |
| 40 | 40 | |
| 41 | - $priorities = []; |
|
| 42 | - $prioritySeeders = []; |
|
| 43 | - $nonPrioritySeeders = []; |
|
| 41 | + $priorities = [ ]; |
|
| 42 | + $prioritySeeders = [ ]; |
|
| 43 | + $nonPrioritySeeders = [ ]; |
|
| 44 | 44 | foreach ($seeders as $seeder) { |
| 45 | 45 | $priority = get_class_property($seeder, 'priority'); |
| 46 | 46 | if (!is_int($priority) && $priority !== null) { |
| 47 | 47 | throw new Exception('Priority on seeder must be integer'); |
| 48 | 48 | } elseif ($priority !== null && in_array($priority, $priorities)) { |
| 49 | - throw new Exception("Duplicate priority on seeder $seeder with $prioritySeeders[$priority]"); |
|
| 49 | + throw new Exception("Duplicate priority on seeder $seeder with $prioritySeeders[ $priority ]"); |
|
| 50 | 50 | } elseif ($priority === null) { |
| 51 | - $nonPrioritySeeders[] = $seeder; |
|
| 51 | + $nonPrioritySeeders[ ] = $seeder; |
|
| 52 | 52 | } else { |
| 53 | - $priorities[] = $priority; |
|
| 54 | - $prioritySeeders[$priority] = $seeder; |
|
| 53 | + $priorities[ ] = $priority; |
|
| 54 | + $prioritySeeders[ $priority ] = $seeder; |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | ksort($prioritySeeders); |
@@ -74,6 +74,6 @@ discard block |
||
| 74 | 74 | { |
| 75 | 75 | $this->service = $this->laravel->make(BootstrapRegistrarService::class); |
| 76 | 76 | |
| 77 | - return $this->service->getSeeders() ?? []; |
|
| 77 | + return $this->service->getSeeders() ?? [ ]; |
|
| 78 | 78 | } |
| 79 | 79 | } |
@@ -179,6 +179,6 @@ |
||
| 179 | 179 | public function testGetClassConstants() |
| 180 | 180 | { |
| 181 | 181 | $this->assertArrayHasKey('TEST_CONSTANT', get_class_constants(static::class)); |
| 182 | - $this->assertEquals(self::TEST_CONSTANT, get_class_constants(static::class)['TEST_CONSTANT']); |
|
| 182 | + $this->assertEquals(self::TEST_CONSTANT, get_class_constants(static::class)[ 'TEST_CONSTANT' ]); |
|
| 183 | 183 | } |
| 184 | 184 | } |
@@ -16,67 +16,67 @@ discard block |
||
| 16 | 16 | $tableNames = config('permission.table_names'); |
| 17 | 17 | $columnNames = config('permission.column_names'); |
| 18 | 18 | |
| 19 | - Schema::create($tableNames['permissions'], function (Blueprint $table) { |
|
| 19 | + Schema::create($tableNames[ 'permissions' ], function(Blueprint $table) { |
|
| 20 | 20 | $table->increments('id'); |
| 21 | 21 | $table->string('name'); |
| 22 | 22 | $table->string('guard_name'); |
| 23 | 23 | $table->timestamps(); |
| 24 | 24 | }); |
| 25 | 25 | |
| 26 | - Schema::create($tableNames['roles'], function (Blueprint $table) { |
|
| 26 | + Schema::create($tableNames[ 'roles' ], function(Blueprint $table) { |
|
| 27 | 27 | $table->increments('id'); |
| 28 | 28 | $table->string('name'); |
| 29 | 29 | $table->string('guard_name'); |
| 30 | 30 | $table->timestamps(); |
| 31 | 31 | }); |
| 32 | 32 | |
| 33 | - Schema::create($tableNames['model_has_permissions'], function (Blueprint $table) use ($tableNames, $columnNames) { |
|
| 33 | + Schema::create($tableNames[ 'model_has_permissions' ], function(Blueprint $table) use ($tableNames, $columnNames) { |
|
| 34 | 34 | $table->unsignedInteger('permission_id'); |
| 35 | 35 | |
| 36 | 36 | $table->string('model_type'); |
| 37 | - $table->unsignedBigInteger($columnNames['model_morph_key']); |
|
| 38 | - $table->index([$columnNames['model_morph_key'], 'model_type', ]); |
|
| 37 | + $table->unsignedBigInteger($columnNames[ 'model_morph_key' ]); |
|
| 38 | + $table->index([ $columnNames[ 'model_morph_key' ], 'model_type', ]); |
|
| 39 | 39 | |
| 40 | 40 | $table->foreign('permission_id') |
| 41 | 41 | ->references('id') |
| 42 | - ->on($tableNames['permissions']) |
|
| 42 | + ->on($tableNames[ 'permissions' ]) |
|
| 43 | 43 | ->onDelete('cascade'); |
| 44 | 44 | |
| 45 | - $table->primary(['permission_id', $columnNames['model_morph_key'], 'model_type'], |
|
| 45 | + $table->primary([ 'permission_id', $columnNames[ 'model_morph_key' ], 'model_type' ], |
|
| 46 | 46 | 'model_has_permissions_permission_model_type_primary'); |
| 47 | 47 | }); |
| 48 | 48 | |
| 49 | - Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames, $columnNames) { |
|
| 49 | + Schema::create($tableNames[ 'model_has_roles' ], function(Blueprint $table) use ($tableNames, $columnNames) { |
|
| 50 | 50 | $table->unsignedInteger('role_id'); |
| 51 | 51 | |
| 52 | 52 | $table->string('model_type'); |
| 53 | - $table->unsignedBigInteger($columnNames['model_morph_key']); |
|
| 54 | - $table->index([$columnNames['model_morph_key'], 'model_type', ]); |
|
| 53 | + $table->unsignedBigInteger($columnNames[ 'model_morph_key' ]); |
|
| 54 | + $table->index([ $columnNames[ 'model_morph_key' ], 'model_type', ]); |
|
| 55 | 55 | |
| 56 | 56 | $table->foreign('role_id') |
| 57 | 57 | ->references('id') |
| 58 | - ->on($tableNames['roles']) |
|
| 58 | + ->on($tableNames[ 'roles' ]) |
|
| 59 | 59 | ->onDelete('cascade'); |
| 60 | 60 | |
| 61 | - $table->primary(['role_id', $columnNames['model_morph_key'], 'model_type'], |
|
| 61 | + $table->primary([ 'role_id', $columnNames[ 'model_morph_key' ], 'model_type' ], |
|
| 62 | 62 | 'model_has_roles_role_model_type_primary'); |
| 63 | 63 | }); |
| 64 | 64 | |
| 65 | - Schema::create($tableNames['role_has_permissions'], function (Blueprint $table) use ($tableNames) { |
|
| 65 | + Schema::create($tableNames[ 'role_has_permissions' ], function(Blueprint $table) use ($tableNames) { |
|
| 66 | 66 | $table->unsignedInteger('permission_id'); |
| 67 | 67 | $table->unsignedInteger('role_id'); |
| 68 | 68 | |
| 69 | 69 | $table->foreign('permission_id') |
| 70 | 70 | ->references('id') |
| 71 | - ->on($tableNames['permissions']) |
|
| 71 | + ->on($tableNames[ 'permissions' ]) |
|
| 72 | 72 | ->onDelete('cascade'); |
| 73 | 73 | |
| 74 | 74 | $table->foreign('role_id') |
| 75 | 75 | ->references('id') |
| 76 | - ->on($tableNames['roles']) |
|
| 76 | + ->on($tableNames[ 'roles' ]) |
|
| 77 | 77 | ->onDelete('cascade'); |
| 78 | 78 | |
| 79 | - $table->primary(['permission_id', 'role_id']); |
|
| 79 | + $table->primary([ 'permission_id', 'role_id' ]); |
|
| 80 | 80 | |
| 81 | 81 | app('cache')->forget('spatie.permission.cache'); |
| 82 | 82 | }); |
@@ -91,10 +91,10 @@ discard block |
||
| 91 | 91 | { |
| 92 | 92 | $tableNames = config('permission.table_names'); |
| 93 | 93 | |
| 94 | - Schema::drop($tableNames['role_has_permissions']); |
|
| 95 | - Schema::drop($tableNames['model_has_roles']); |
|
| 96 | - Schema::drop($tableNames['model_has_permissions']); |
|
| 97 | - Schema::drop($tableNames['roles']); |
|
| 98 | - Schema::drop($tableNames['permissions']); |
|
| 94 | + Schema::drop($tableNames[ 'role_has_permissions' ]); |
|
| 95 | + Schema::drop($tableNames[ 'model_has_roles' ]); |
|
| 96 | + Schema::drop($tableNames[ 'model_has_permissions' ]); |
|
| 97 | + Schema::drop($tableNames[ 'roles' ]); |
|
| 98 | + Schema::drop($tableNames[ 'permissions' ]); |
|
| 99 | 99 | } |
| 100 | 100 | } |
@@ -36,6 +36,6 @@ |
||
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | public function clearPermissionCache() :void{ |
| 39 | - app()['cache']->forget('spatie.permission.cache'); |
|
| 39 | + app()[ 'cache' ]->forget('spatie.permission.cache'); |
|
| 40 | 40 | } |
| 41 | 41 | } |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | */ |
| 26 | 26 | public function register() |
| 27 | 27 | { |
| 28 | - $this->app->bind(NotificationServiceContract::class, function () { |
|
| 28 | + $this->app->bind(NotificationServiceContract::class, function() { |
|
| 29 | 29 | return new NotificationService(new UserService()); |
| 30 | 30 | }); |
| 31 | 31 | } |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | public function up() |
| 15 | 15 | { |
| 16 | - Schema::create('notifications', function (Blueprint $table) { |
|
| 16 | + Schema::create('notifications', function(Blueprint $table) { |
|
| 17 | 17 | $table->uuid('id')->primary(); |
| 18 | 18 | $table->string('type'); |
| 19 | 19 | $table->morphs('notifiable'); |