@@ -7,24 +7,24 @@ |
||
7 | 7 | |
8 | 8 | class Permission extends JsonResource |
9 | 9 | { |
10 | - /** |
|
11 | - * Transform the resource into an array. |
|
12 | - * |
|
13 | - * @param Request $request |
|
14 | - * @return array |
|
15 | - */ |
|
16 | - public function toArray($request) |
|
17 | - { |
|
18 | - if (! $this->resource) { |
|
19 | - return []; |
|
20 | - } |
|
10 | + /** |
|
11 | + * Transform the resource into an array. |
|
12 | + * |
|
13 | + * @param Request $request |
|
14 | + * @return array |
|
15 | + */ |
|
16 | + public function toArray($request) |
|
17 | + { |
|
18 | + if (! $this->resource) { |
|
19 | + return []; |
|
20 | + } |
|
21 | 21 | |
22 | - return [ |
|
23 | - 'id' => $this->id, |
|
24 | - 'name' => $this->name, |
|
25 | - 'roles' => RoleResource::collection($this->whenLoaded('roles')), |
|
26 | - 'created_at' => $this->created_at, |
|
27 | - 'updated_at' => $this->updated_at, |
|
28 | - ]; |
|
29 | - } |
|
22 | + return [ |
|
23 | + 'id' => $this->id, |
|
24 | + 'name' => $this->name, |
|
25 | + 'roles' => RoleResource::collection($this->whenLoaded('roles')), |
|
26 | + 'created_at' => $this->created_at, |
|
27 | + 'updated_at' => $this->updated_at, |
|
28 | + ]; |
|
29 | + } |
|
30 | 30 | } |
@@ -17,7 +17,7 @@ |
||
17 | 17 | */ |
18 | 18 | public function toArray($request) |
19 | 19 | { |
20 | - if (! $this->resource) { |
|
20 | + if ( ! $this->resource) { |
|
21 | 21 | return []; |
22 | 22 | } |
23 | 23 |
@@ -5,14 +5,14 @@ |
||
5 | 5 | |
6 | 6 | class PermissionRepository extends BaseRepository |
7 | 7 | { |
8 | - /** |
|
9 | - * Init new object. |
|
10 | - * |
|
11 | - * @param Permission $model |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function __construct(Permission $model) |
|
15 | - { |
|
16 | - parent::__construct($model); |
|
17 | - } |
|
8 | + /** |
|
9 | + * Init new object. |
|
10 | + * |
|
11 | + * @param Permission $model |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function __construct(Permission $model) |
|
15 | + { |
|
16 | + parent::__construct($model); |
|
17 | + } |
|
18 | 18 | } |
@@ -6,53 +6,53 @@ |
||
6 | 6 | class PermissionObserver |
7 | 7 | { |
8 | 8 | |
9 | - public function saving($model) |
|
10 | - { |
|
11 | - // |
|
12 | - } |
|
13 | - |
|
14 | - public function saved($model) |
|
15 | - { |
|
16 | - // |
|
17 | - } |
|
18 | - |
|
19 | - public function creating($model) |
|
20 | - { |
|
21 | - // |
|
22 | - } |
|
23 | - |
|
24 | - public function created($model) |
|
25 | - { |
|
26 | - // |
|
27 | - } |
|
28 | - |
|
29 | - public function updating($model) |
|
30 | - { |
|
31 | - // |
|
32 | - } |
|
33 | - |
|
34 | - public function updated($model) |
|
35 | - { |
|
36 | - // |
|
37 | - } |
|
38 | - |
|
39 | - public function deleting($model) |
|
40 | - { |
|
41 | - // |
|
42 | - } |
|
43 | - |
|
44 | - public function deleted($model) |
|
45 | - { |
|
46 | - // |
|
47 | - } |
|
48 | - |
|
49 | - public function restoring($model) |
|
50 | - { |
|
51 | - // |
|
52 | - } |
|
53 | - |
|
54 | - public function restored($model) |
|
55 | - { |
|
56 | - // |
|
57 | - } |
|
9 | + public function saving($model) |
|
10 | + { |
|
11 | + // |
|
12 | + } |
|
13 | + |
|
14 | + public function saved($model) |
|
15 | + { |
|
16 | + // |
|
17 | + } |
|
18 | + |
|
19 | + public function creating($model) |
|
20 | + { |
|
21 | + // |
|
22 | + } |
|
23 | + |
|
24 | + public function created($model) |
|
25 | + { |
|
26 | + // |
|
27 | + } |
|
28 | + |
|
29 | + public function updating($model) |
|
30 | + { |
|
31 | + // |
|
32 | + } |
|
33 | + |
|
34 | + public function updated($model) |
|
35 | + { |
|
36 | + // |
|
37 | + } |
|
38 | + |
|
39 | + public function deleting($model) |
|
40 | + { |
|
41 | + // |
|
42 | + } |
|
43 | + |
|
44 | + public function deleted($model) |
|
45 | + { |
|
46 | + // |
|
47 | + } |
|
48 | + |
|
49 | + public function restoring($model) |
|
50 | + { |
|
51 | + // |
|
52 | + } |
|
53 | + |
|
54 | + public function restored($model) |
|
55 | + { |
|
56 | + // |
|
57 | + } |
|
58 | 58 | } |
@@ -12,7 +12,7 @@ |
||
12 | 12 | */ |
13 | 13 | public function up() |
14 | 14 | { |
15 | - Schema::create('push_notification_devices', function (Blueprint $table) { |
|
15 | + Schema::create('push_notification_devices', function(Blueprint $table) { |
|
16 | 16 | $table->increments('id'); |
17 | 17 | $table->string('device_token'); |
18 | 18 | $table->unsignedInteger('user_id'); |
@@ -5,33 +5,33 @@ |
||
5 | 5 | |
6 | 6 | class PushNotificationDevices extends Migration |
7 | 7 | { |
8 | - /** |
|
9 | - * Run the migrations. |
|
10 | - * |
|
11 | - * @return void |
|
12 | - */ |
|
13 | - public function up() |
|
14 | - { |
|
15 | - Schema::create('push_notification_devices', function (Blueprint $table) { |
|
16 | - $table->increments('id'); |
|
17 | - $table->string('device_token'); |
|
18 | - $table->unsignedInteger('user_id'); |
|
19 | - $table->text('access_token')->nullable(); |
|
20 | - $table->unique(array('device_token', 'user_id')); |
|
21 | - $table->softDeletes(); |
|
22 | - $table->timestamps(); |
|
8 | + /** |
|
9 | + * Run the migrations. |
|
10 | + * |
|
11 | + * @return void |
|
12 | + */ |
|
13 | + public function up() |
|
14 | + { |
|
15 | + Schema::create('push_notification_devices', function (Blueprint $table) { |
|
16 | + $table->increments('id'); |
|
17 | + $table->string('device_token'); |
|
18 | + $table->unsignedInteger('user_id'); |
|
19 | + $table->text('access_token')->nullable(); |
|
20 | + $table->unique(array('device_token', 'user_id')); |
|
21 | + $table->softDeletes(); |
|
22 | + $table->timestamps(); |
|
23 | 23 | |
24 | - $table->foreign('user_id')->references('id')->on('users'); |
|
25 | - }); |
|
26 | - } |
|
24 | + $table->foreign('user_id')->references('id')->on('users'); |
|
25 | + }); |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * Reverse the migrations. |
|
30 | - * |
|
31 | - * @return void |
|
32 | - */ |
|
33 | - public function down() |
|
34 | - { |
|
35 | - Schema::dropIfExists('push_notification_devices'); |
|
36 | - } |
|
28 | + /** |
|
29 | + * Reverse the migrations. |
|
30 | + * |
|
31 | + * @return void |
|
32 | + */ |
|
33 | + public function down() |
|
34 | + { |
|
35 | + Schema::dropIfExists('push_notification_devices'); |
|
36 | + } |
|
37 | 37 | } |
@@ -6,33 +6,33 @@ |
||
6 | 6 | |
7 | 7 | class CreateOauthAuthCodesTable extends Migration |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the migrations. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function up() |
|
15 | - { |
|
16 | - Schema::create('oauth_auth_codes', function (Blueprint $table) { |
|
17 | - $table->string('id', 100)->primary(); |
|
18 | - $table->unsignedInteger('user_id'); |
|
19 | - $table->unsignedInteger('client_id'); |
|
20 | - $table->text('scopes')->nullable(); |
|
21 | - $table->boolean('revoked'); |
|
22 | - $table->dateTime('expires_at')->nullable(); |
|
9 | + /** |
|
10 | + * Run the migrations. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function up() |
|
15 | + { |
|
16 | + Schema::create('oauth_auth_codes', function (Blueprint $table) { |
|
17 | + $table->string('id', 100)->primary(); |
|
18 | + $table->unsignedInteger('user_id'); |
|
19 | + $table->unsignedInteger('client_id'); |
|
20 | + $table->text('scopes')->nullable(); |
|
21 | + $table->boolean('revoked'); |
|
22 | + $table->dateTime('expires_at')->nullable(); |
|
23 | 23 | |
24 | - $table->foreign('user_id')->references('id')->on('users'); |
|
25 | - $table->foreign('client_id')->references('id')->on('oauth_clients'); |
|
26 | - }); |
|
27 | - } |
|
24 | + $table->foreign('user_id')->references('id')->on('users'); |
|
25 | + $table->foreign('client_id')->references('id')->on('oauth_clients'); |
|
26 | + }); |
|
27 | + } |
|
28 | 28 | |
29 | - /** |
|
30 | - * Reverse the migrations. |
|
31 | - * |
|
32 | - * @return void |
|
33 | - */ |
|
34 | - public function down() |
|
35 | - { |
|
36 | - Schema::drop('oauth_auth_codes'); |
|
37 | - } |
|
29 | + /** |
|
30 | + * Reverse the migrations. |
|
31 | + * |
|
32 | + * @return void |
|
33 | + */ |
|
34 | + public function down() |
|
35 | + { |
|
36 | + Schema::drop('oauth_auth_codes'); |
|
37 | + } |
|
38 | 38 | } |
@@ -13,7 +13,7 @@ |
||
13 | 13 | */ |
14 | 14 | public function up() |
15 | 15 | { |
16 | - Schema::create('oauth_auth_codes', function (Blueprint $table) { |
|
16 | + Schema::create('oauth_auth_codes', function(Blueprint $table) { |
|
17 | 17 | $table->string('id', 100)->primary(); |
18 | 18 | $table->unsignedInteger('user_id'); |
19 | 19 | $table->unsignedInteger('client_id'); |
@@ -6,35 +6,35 @@ |
||
6 | 6 | |
7 | 7 | class CreateOauthClientsTable extends Migration |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the migrations. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function up() |
|
15 | - { |
|
16 | - Schema::create('oauth_clients', function (Blueprint $table) { |
|
17 | - $table->increments('id'); |
|
18 | - $table->unsignedInteger('user_id')->nullable(); |
|
19 | - $table->string('name'); |
|
20 | - $table->string('secret', 100); |
|
21 | - $table->text('redirect'); |
|
22 | - $table->boolean('personal_access_client')->default(0); |
|
23 | - $table->boolean('password_client')->default(0); |
|
24 | - $table->boolean('revoked')->default(0); |
|
25 | - $table->timestamps(); |
|
9 | + /** |
|
10 | + * Run the migrations. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function up() |
|
15 | + { |
|
16 | + Schema::create('oauth_clients', function (Blueprint $table) { |
|
17 | + $table->increments('id'); |
|
18 | + $table->unsignedInteger('user_id')->nullable(); |
|
19 | + $table->string('name'); |
|
20 | + $table->string('secret', 100); |
|
21 | + $table->text('redirect'); |
|
22 | + $table->boolean('personal_access_client')->default(0); |
|
23 | + $table->boolean('password_client')->default(0); |
|
24 | + $table->boolean('revoked')->default(0); |
|
25 | + $table->timestamps(); |
|
26 | 26 | |
27 | - $table->foreign('user_id')->references('id')->on('users'); |
|
28 | - }); |
|
29 | - } |
|
27 | + $table->foreign('user_id')->references('id')->on('users'); |
|
28 | + }); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * Reverse the migrations. |
|
33 | - * |
|
34 | - * @return void |
|
35 | - */ |
|
36 | - public function down() |
|
37 | - { |
|
38 | - Schema::drop('oauth_clients'); |
|
39 | - } |
|
31 | + /** |
|
32 | + * Reverse the migrations. |
|
33 | + * |
|
34 | + * @return void |
|
35 | + */ |
|
36 | + public function down() |
|
37 | + { |
|
38 | + Schema::drop('oauth_clients'); |
|
39 | + } |
|
40 | 40 | } |
@@ -13,7 +13,7 @@ |
||
13 | 13 | */ |
14 | 14 | public function up() |
15 | 15 | { |
16 | - Schema::create('oauth_clients', function (Blueprint $table) { |
|
16 | + Schema::create('oauth_clients', function(Blueprint $table) { |
|
17 | 17 | $table->increments('id'); |
18 | 18 | $table->unsignedInteger('user_id')->nullable(); |
19 | 19 | $table->string('name'); |
@@ -6,35 +6,35 @@ |
||
6 | 6 | |
7 | 7 | class CreateOauthAccessTokensTable extends Migration |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the migrations. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function up() |
|
15 | - { |
|
16 | - Schema::create('oauth_access_tokens', function (Blueprint $table) { |
|
17 | - $table->string('id', 100)->primary(); |
|
18 | - $table->unsignedInteger('user_id')->nullable(); |
|
19 | - $table->unsignedInteger('client_id'); |
|
20 | - $table->string('name')->nullable(); |
|
21 | - $table->text('scopes')->nullable(); |
|
22 | - $table->boolean('revoked'); |
|
23 | - $table->timestamps(); |
|
24 | - $table->dateTime('expires_at')->nullable(); |
|
9 | + /** |
|
10 | + * Run the migrations. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function up() |
|
15 | + { |
|
16 | + Schema::create('oauth_access_tokens', function (Blueprint $table) { |
|
17 | + $table->string('id', 100)->primary(); |
|
18 | + $table->unsignedInteger('user_id')->nullable(); |
|
19 | + $table->unsignedInteger('client_id'); |
|
20 | + $table->string('name')->nullable(); |
|
21 | + $table->text('scopes')->nullable(); |
|
22 | + $table->boolean('revoked'); |
|
23 | + $table->timestamps(); |
|
24 | + $table->dateTime('expires_at')->nullable(); |
|
25 | 25 | |
26 | - $table->foreign('user_id')->references('id')->on('users'); |
|
27 | - $table->foreign('client_id')->references('id')->on('oauth_clients'); |
|
28 | - }); |
|
29 | - } |
|
26 | + $table->foreign('user_id')->references('id')->on('users'); |
|
27 | + $table->foreign('client_id')->references('id')->on('oauth_clients'); |
|
28 | + }); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * Reverse the migrations. |
|
33 | - * |
|
34 | - * @return void |
|
35 | - */ |
|
36 | - public function down() |
|
37 | - { |
|
38 | - Schema::drop('oauth_access_tokens'); |
|
39 | - } |
|
31 | + /** |
|
32 | + * Reverse the migrations. |
|
33 | + * |
|
34 | + * @return void |
|
35 | + */ |
|
36 | + public function down() |
|
37 | + { |
|
38 | + Schema::drop('oauth_access_tokens'); |
|
39 | + } |
|
40 | 40 | } |
@@ -13,7 +13,7 @@ |
||
13 | 13 | */ |
14 | 14 | public function up() |
15 | 15 | { |
16 | - Schema::create('oauth_access_tokens', function (Blueprint $table) { |
|
16 | + Schema::create('oauth_access_tokens', function(Blueprint $table) { |
|
17 | 17 | $table->string('id', 100)->primary(); |
18 | 18 | $table->unsignedInteger('user_id')->nullable(); |
19 | 19 | $table->unsignedInteger('client_id'); |
@@ -6,29 +6,29 @@ |
||
6 | 6 | |
7 | 7 | class CreateOauthPersonalAccessClientsTable extends Migration |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the migrations. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function up() |
|
15 | - { |
|
16 | - Schema::create('oauth_personal_access_clients', function (Blueprint $table) { |
|
17 | - $table->increments('id'); |
|
18 | - $table->unsignedInteger('client_id'); |
|
19 | - $table->timestamps(); |
|
9 | + /** |
|
10 | + * Run the migrations. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function up() |
|
15 | + { |
|
16 | + Schema::create('oauth_personal_access_clients', function (Blueprint $table) { |
|
17 | + $table->increments('id'); |
|
18 | + $table->unsignedInteger('client_id'); |
|
19 | + $table->timestamps(); |
|
20 | 20 | |
21 | - $table->foreign('client_id')->references('id')->on('oauth_clients'); |
|
22 | - }); |
|
23 | - } |
|
21 | + $table->foreign('client_id')->references('id')->on('oauth_clients'); |
|
22 | + }); |
|
23 | + } |
|
24 | 24 | |
25 | - /** |
|
26 | - * Reverse the migrations. |
|
27 | - * |
|
28 | - * @return void |
|
29 | - */ |
|
30 | - public function down() |
|
31 | - { |
|
32 | - Schema::drop('oauth_personal_access_clients'); |
|
33 | - } |
|
25 | + /** |
|
26 | + * Reverse the migrations. |
|
27 | + * |
|
28 | + * @return void |
|
29 | + */ |
|
30 | + public function down() |
|
31 | + { |
|
32 | + Schema::drop('oauth_personal_access_clients'); |
|
33 | + } |
|
34 | 34 | } |
@@ -13,7 +13,7 @@ |
||
13 | 13 | */ |
14 | 14 | public function up() |
15 | 15 | { |
16 | - Schema::create('oauth_personal_access_clients', function (Blueprint $table) { |
|
16 | + Schema::create('oauth_personal_access_clients', function(Blueprint $table) { |
|
17 | 17 | $table->increments('id'); |
18 | 18 | $table->unsignedInteger('client_id'); |
19 | 19 | $table->timestamps(); |
@@ -21,7 +21,7 @@ |
||
21 | 21 | * |
22 | 22 | * @param integer $roleId |
23 | 23 | * @param array $permissionIds |
24 | - * @return object |
|
24 | + * @return boolean |
|
25 | 25 | */ |
26 | 26 | public function assignPermissions($roleId, $permissionIds) |
27 | 27 | { |
@@ -7,33 +7,33 @@ |
||
7 | 7 | |
8 | 8 | class RoleService extends BaseService |
9 | 9 | { |
10 | - /** |
|
11 | - * Init new object. |
|
12 | - * |
|
13 | - * @param RoleRepository $repo |
|
14 | - * @return void |
|
15 | - */ |
|
16 | - public function __construct(RoleRepository $repo) |
|
17 | - { |
|
18 | - parent::__construct($repo); |
|
19 | - } |
|
10 | + /** |
|
11 | + * Init new object. |
|
12 | + * |
|
13 | + * @param RoleRepository $repo |
|
14 | + * @return void |
|
15 | + */ |
|
16 | + public function __construct(RoleRepository $repo) |
|
17 | + { |
|
18 | + parent::__construct($repo); |
|
19 | + } |
|
20 | 20 | |
21 | - /** |
|
22 | - * Assign the given permission ids to the given role. |
|
23 | - * |
|
24 | - * @param integer $roleId |
|
25 | - * @param array $permissionIds |
|
26 | - * @return object |
|
27 | - */ |
|
28 | - public function assignPermissions($roleId, $permissionIds) |
|
29 | - { |
|
30 | - $role = false; |
|
31 | - \DB::transaction(function () use ($roleId, $permissionIds, &$role) { |
|
32 | - $role = $this->repo->find($roleId); |
|
33 | - $this->repo->detachPermissions($role); |
|
34 | - $this->repo->attachPermissions($role, $permissionIds); |
|
35 | - }); |
|
21 | + /** |
|
22 | + * Assign the given permission ids to the given role. |
|
23 | + * |
|
24 | + * @param integer $roleId |
|
25 | + * @param array $permissionIds |
|
26 | + * @return object |
|
27 | + */ |
|
28 | + public function assignPermissions($roleId, $permissionIds) |
|
29 | + { |
|
30 | + $role = false; |
|
31 | + \DB::transaction(function () use ($roleId, $permissionIds, &$role) { |
|
32 | + $role = $this->repo->find($roleId); |
|
33 | + $this->repo->detachPermissions($role); |
|
34 | + $this->repo->attachPermissions($role, $permissionIds); |
|
35 | + }); |
|
36 | 36 | |
37 | - return $role; |
|
38 | - } |
|
37 | + return $role; |
|
38 | + } |
|
39 | 39 | } |
@@ -28,7 +28,7 @@ |
||
28 | 28 | public function assignPermissions($roleId, $permissionIds) |
29 | 29 | { |
30 | 30 | $role = false; |
31 | - \DB::transaction(function () use ($roleId, $permissionIds, &$role) { |
|
31 | + \DB::transaction(function() use ($roleId, $permissionIds, &$role) { |
|
32 | 32 | $role = $this->repo->find($roleId); |
33 | 33 | $this->repo->detachPermissions($role); |
34 | 34 | $this->repo->attachPermissions($role, $permissionIds); |