@@ -6,15 +6,15 @@ |
||
6 | 6 | |
7 | 7 | class ClearDataSeeder extends Seeder |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the database seeds. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function run() |
|
15 | - { |
|
16 | - $permissions = \DB::table('permissions')->whereIn('model', ['pushNotificationDevice']); |
|
17 | - \DB::table('permission_role')->whereIn('permission_id', $permissions->pluck('id'))->delete(); |
|
18 | - $permissions->delete(); |
|
19 | - } |
|
9 | + /** |
|
10 | + * Run the database seeds. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function run() |
|
15 | + { |
|
16 | + $permissions = \DB::table('permissions')->whereIn('model', ['pushNotificationDevice']); |
|
17 | + \DB::table('permission_role')->whereIn('permission_id', $permissions->pluck('id'))->delete(); |
|
18 | + $permissions->delete(); |
|
19 | + } |
|
20 | 20 | } |
@@ -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 | } |
@@ -10,61 +10,61 @@ |
||
10 | 10 | |
11 | 11 | class PushNotificationDeviceController extends BaseApiController |
12 | 12 | { |
13 | - /** |
|
14 | - * Path of the model resource |
|
15 | - * |
|
16 | - * @var string |
|
17 | - */ |
|
18 | - protected $modelResource = 'App\Modules\PushNotificationDevices\Http\Resources\PushNotificationDevice'; |
|
13 | + /** |
|
14 | + * Path of the model resource |
|
15 | + * |
|
16 | + * @var string |
|
17 | + */ |
|
18 | + protected $modelResource = 'App\Modules\PushNotificationDevices\Http\Resources\PushNotificationDevice'; |
|
19 | 19 | |
20 | - /** |
|
21 | - * List of all route actions that the base api controller |
|
22 | - * will skip permissions check for them. |
|
23 | - * @var array |
|
24 | - */ |
|
25 | - protected $skipPermissionCheck = ['registerDevice']; |
|
20 | + /** |
|
21 | + * List of all route actions that the base api controller |
|
22 | + * will skip permissions check for them. |
|
23 | + * @var array |
|
24 | + */ |
|
25 | + protected $skipPermissionCheck = ['registerDevice']; |
|
26 | 26 | |
27 | - /** |
|
28 | - * Init new object. |
|
29 | - * |
|
30 | - * @param PushNotificationDeviceService $service |
|
31 | - * @return void |
|
32 | - */ |
|
33 | - public function __construct(PushNotificationDeviceService $service) |
|
34 | - { |
|
35 | - parent::__construct($service); |
|
36 | - } |
|
27 | + /** |
|
28 | + * Init new object. |
|
29 | + * |
|
30 | + * @param PushNotificationDeviceService $service |
|
31 | + * @return void |
|
32 | + */ |
|
33 | + public function __construct(PushNotificationDeviceService $service) |
|
34 | + { |
|
35 | + parent::__construct($service); |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * Insert the given model to storage. |
|
40 | - * |
|
41 | - * @param InsertPushNotificationDevice $request |
|
42 | - * @return \Illuminate\Http\Response |
|
43 | - */ |
|
44 | - public function insert(InsertPushNotificationDevice $request) |
|
45 | - { |
|
46 | - return new $this->modelResource($this->service->save($request->all())); |
|
47 | - } |
|
38 | + /** |
|
39 | + * Insert the given model to storage. |
|
40 | + * |
|
41 | + * @param InsertPushNotificationDevice $request |
|
42 | + * @return \Illuminate\Http\Response |
|
43 | + */ |
|
44 | + public function insert(InsertPushNotificationDevice $request) |
|
45 | + { |
|
46 | + return new $this->modelResource($this->service->save($request->all())); |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * Update the given model to storage. |
|
51 | - * |
|
52 | - * @param UpdatePushNotificationDevice $request |
|
53 | - * @return \Illuminate\Http\Response |
|
54 | - */ |
|
55 | - public function update(UpdatePushNotificationDevice $request) |
|
56 | - { |
|
57 | - return new $this->modelResource($this->service->save($request->all())); |
|
58 | - } |
|
49 | + /** |
|
50 | + * Update the given model to storage. |
|
51 | + * |
|
52 | + * @param UpdatePushNotificationDevice $request |
|
53 | + * @return \Illuminate\Http\Response |
|
54 | + */ |
|
55 | + public function update(UpdatePushNotificationDevice $request) |
|
56 | + { |
|
57 | + return new $this->modelResource($this->service->save($request->all())); |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * Register the given device to the logged in user. |
|
62 | - * |
|
63 | - * @param RegisterDevice $request |
|
64 | - * @return \Illuminate\Http\Response |
|
65 | - */ |
|
66 | - public function registerDevice(RegisterDevice $request) |
|
67 | - { |
|
68 | - return new $this->modelResource($this->service->registerDevice($request->all())); |
|
69 | - } |
|
60 | + /** |
|
61 | + * Register the given device to the logged in user. |
|
62 | + * |
|
63 | + * @param RegisterDevice $request |
|
64 | + * @return \Illuminate\Http\Response |
|
65 | + */ |
|
66 | + public function registerDevice(RegisterDevice $request) |
|
67 | + { |
|
68 | + return new $this->modelResource($this->service->registerDevice($request->all())); |
|
69 | + } |
|
70 | 70 | } |
@@ -8,63 +8,63 @@ |
||
8 | 8 | |
9 | 9 | class PushNotificationDeviceService extends BaseService |
10 | 10 | { |
11 | - /** |
|
12 | - * Init new object. |
|
13 | - * |
|
14 | - * @param PushNotificationDeviceRepository $repo |
|
15 | - * @return void |
|
16 | - */ |
|
17 | - public function __construct(PushNotificationDeviceRepository $repo) |
|
18 | - { |
|
19 | - parent::__construct($repo); |
|
20 | - } |
|
11 | + /** |
|
12 | + * Init new object. |
|
13 | + * |
|
14 | + * @param PushNotificationDeviceRepository $repo |
|
15 | + * @return void |
|
16 | + */ |
|
17 | + public function __construct(PushNotificationDeviceRepository $repo) |
|
18 | + { |
|
19 | + parent::__construct($repo); |
|
20 | + } |
|
21 | 21 | |
22 | - /** |
|
23 | - * Register the given device to the logged in user. |
|
24 | - * |
|
25 | - * @param array $data |
|
26 | - * @return void |
|
27 | - */ |
|
28 | - public function registerDevice($data) |
|
29 | - { |
|
30 | - $data['access_token'] = \Auth::user()->token(); |
|
31 | - $data['user_id'] = \Auth::id(); |
|
32 | - $device = $this->repo->first([ |
|
33 | - 'and' => [ |
|
34 | - 'device_token' => $data['device_token'], |
|
35 | - 'user_id' => $data['user_id'] |
|
36 | - ] |
|
37 | - ]); |
|
22 | + /** |
|
23 | + * Register the given device to the logged in user. |
|
24 | + * |
|
25 | + * @param array $data |
|
26 | + * @return void |
|
27 | + */ |
|
28 | + public function registerDevice($data) |
|
29 | + { |
|
30 | + $data['access_token'] = \Auth::user()->token(); |
|
31 | + $data['user_id'] = \Auth::id(); |
|
32 | + $device = $this->repo->first([ |
|
33 | + 'and' => [ |
|
34 | + 'device_token' => $data['device_token'], |
|
35 | + 'user_id' => $data['user_id'] |
|
36 | + ] |
|
37 | + ]); |
|
38 | 38 | |
39 | - if ($device) { |
|
40 | - $data['id'] = $device->id; |
|
41 | - } |
|
39 | + if ($device) { |
|
40 | + $data['id'] = $device->id; |
|
41 | + } |
|
42 | 42 | |
43 | - return $this->repo->save($data); |
|
44 | - } |
|
43 | + return $this->repo->save($data); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * Generate the given message data. |
|
48 | - * |
|
49 | - * @param string $title |
|
50 | - * @param string $message |
|
51 | - * @param array $data |
|
52 | - * @return void |
|
53 | - */ |
|
54 | - public function generateMessageData($title, $message, $data = []) |
|
55 | - { |
|
56 | - $optionBuilder = new OptionsBuilder(); |
|
57 | - $notificationBuilder = new PayloadNotificationBuilder($title); |
|
58 | - $dataBuilder = new PayloadDataBuilder(); |
|
46 | + /** |
|
47 | + * Generate the given message data. |
|
48 | + * |
|
49 | + * @param string $title |
|
50 | + * @param string $message |
|
51 | + * @param array $data |
|
52 | + * @return void |
|
53 | + */ |
|
54 | + public function generateMessageData($title, $message, $data = []) |
|
55 | + { |
|
56 | + $optionBuilder = new OptionsBuilder(); |
|
57 | + $notificationBuilder = new PayloadNotificationBuilder($title); |
|
58 | + $dataBuilder = new PayloadDataBuilder(); |
|
59 | 59 | |
60 | - $optionBuilder->setTimeToLive(60 * 20); |
|
61 | - $notificationBuilder->setBody($message); |
|
62 | - $dataBuilder->addData($data); |
|
60 | + $optionBuilder->setTimeToLive(60 * 20); |
|
61 | + $notificationBuilder->setBody($message); |
|
62 | + $dataBuilder->addData($data); |
|
63 | 63 | |
64 | - $options = $optionBuilder->build(); |
|
65 | - $notification = $notificationBuilder->build(); |
|
66 | - $data = $dataBuilder->build(); |
|
64 | + $options = $optionBuilder->build(); |
|
65 | + $notification = $notificationBuilder->build(); |
|
66 | + $data = $dataBuilder->build(); |
|
67 | 67 | |
68 | - return compact('options', 'notification', 'data'); |
|
69 | - } |
|
68 | + return compact('options', 'notification', 'data'); |
|
69 | + } |
|
70 | 70 | } |
@@ -6,27 +6,27 @@ |
||
6 | 6 | |
7 | 7 | class AssignRelationsSeeder extends Seeder |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the database seeds. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function run() |
|
15 | - { |
|
16 | - $adminRoleId = \DB::table('roles')->where('name', 'admin')->select('id')->first()->id; |
|
9 | + /** |
|
10 | + * Run the database seeds. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function run() |
|
15 | + { |
|
16 | + $adminRoleId = \DB::table('roles')->where('name', 'admin')->select('id')->first()->id; |
|
17 | 17 | |
18 | - /** |
|
19 | - * Assign the permissions to the admin role. |
|
20 | - */ |
|
21 | - \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['permission'])->each(function ($permission) use ($adminRoleId) { |
|
22 | - \DB::table('permission_role')->insert( |
|
23 | - [ |
|
24 | - 'permission_id' => $permission->id, |
|
25 | - 'role_id' => $adminRoleId, |
|
26 | - 'created_at' => \DB::raw('NOW()'), |
|
27 | - 'updated_at' => \DB::raw('NOW()') |
|
28 | - ] |
|
29 | - ); |
|
30 | - }); |
|
31 | - } |
|
18 | + /** |
|
19 | + * Assign the permissions to the admin role. |
|
20 | + */ |
|
21 | + \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['permission'])->each(function ($permission) use ($adminRoleId) { |
|
22 | + \DB::table('permission_role')->insert( |
|
23 | + [ |
|
24 | + 'permission_id' => $permission->id, |
|
25 | + 'role_id' => $adminRoleId, |
|
26 | + 'created_at' => \DB::raw('NOW()'), |
|
27 | + 'updated_at' => \DB::raw('NOW()') |
|
28 | + ] |
|
29 | + ); |
|
30 | + }); |
|
31 | + } |
|
32 | 32 | } |
@@ -6,15 +6,15 @@ |
||
6 | 6 | |
7 | 7 | class ClearDataSeeder extends Seeder |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the database seeds. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function run() |
|
15 | - { |
|
16 | - $permissions = \DB::table('permissions')->whereIn('model', ['permission']); |
|
17 | - \DB::table('permission_role')->whereIn('permission_id', $permissions->pluck('id'))->delete(); |
|
18 | - $permissions->delete(); |
|
19 | - } |
|
9 | + /** |
|
10 | + * Run the database seeds. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function run() |
|
15 | + { |
|
16 | + $permissions = \DB::table('permissions')->whereIn('model', ['permission']); |
|
17 | + \DB::table('permission_role')->whereIn('permission_id', $permissions->pluck('id'))->delete(); |
|
18 | + $permissions->delete(); |
|
19 | + } |
|
20 | 20 | } |
@@ -5,41 +5,41 @@ |
||
5 | 5 | |
6 | 6 | class Permissions extends Migration |
7 | 7 | { |
8 | - /** |
|
9 | - * Run the migrations. |
|
10 | - * |
|
11 | - * @return void |
|
12 | - */ |
|
13 | - public function up() |
|
14 | - { |
|
15 | - Schema::create('permissions', function (Blueprint $table) { |
|
16 | - $table->increments('id'); |
|
17 | - $table->string('name', 100); |
|
18 | - $table->string('model', 100); |
|
19 | - $table->softDeletes(); |
|
20 | - $table->timestamps(); |
|
21 | - $table->unique(array('name', 'model')); |
|
22 | - }); |
|
23 | - Schema::create('permission_role', function (Blueprint $table) { |
|
24 | - $table->increments('id'); |
|
25 | - $table->unsignedInteger('role_id'); |
|
26 | - $table->unsignedInteger('permission_id'); |
|
27 | - $table->softDeletes(); |
|
28 | - $table->timestamps(); |
|
8 | + /** |
|
9 | + * Run the migrations. |
|
10 | + * |
|
11 | + * @return void |
|
12 | + */ |
|
13 | + public function up() |
|
14 | + { |
|
15 | + Schema::create('permissions', function (Blueprint $table) { |
|
16 | + $table->increments('id'); |
|
17 | + $table->string('name', 100); |
|
18 | + $table->string('model', 100); |
|
19 | + $table->softDeletes(); |
|
20 | + $table->timestamps(); |
|
21 | + $table->unique(array('name', 'model')); |
|
22 | + }); |
|
23 | + Schema::create('permission_role', function (Blueprint $table) { |
|
24 | + $table->increments('id'); |
|
25 | + $table->unsignedInteger('role_id'); |
|
26 | + $table->unsignedInteger('permission_id'); |
|
27 | + $table->softDeletes(); |
|
28 | + $table->timestamps(); |
|
29 | 29 | |
30 | - $table->foreign('role_id')->references('id')->on('roles'); |
|
31 | - $table->foreign('permission_id')->references('id')->on('permissions'); |
|
32 | - }); |
|
33 | - } |
|
30 | + $table->foreign('role_id')->references('id')->on('roles'); |
|
31 | + $table->foreign('permission_id')->references('id')->on('permissions'); |
|
32 | + }); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * Reverse the migrations. |
|
37 | - * |
|
38 | - * @return void |
|
39 | - */ |
|
40 | - public function down() |
|
41 | - { |
|
42 | - Schema::dropIfExists('permissions'); |
|
43 | - Schema::dropIfExists('permission_role'); |
|
44 | - } |
|
35 | + /** |
|
36 | + * Reverse the migrations. |
|
37 | + * |
|
38 | + * @return void |
|
39 | + */ |
|
40 | + public function down() |
|
41 | + { |
|
42 | + Schema::dropIfExists('permissions'); |
|
43 | + Schema::dropIfExists('permission_role'); |
|
44 | + } |
|
45 | 45 | } |
@@ -7,21 +7,21 @@ |
||
7 | 7 | |
8 | 8 | class PermissionController extends BaseApiController |
9 | 9 | { |
10 | - /** |
|
11 | - * Path of the model resource |
|
12 | - * |
|
13 | - * @var string |
|
14 | - */ |
|
15 | - protected $modelResource = 'App\Modules\Permissions\Http\Resources\Permission'; |
|
10 | + /** |
|
11 | + * Path of the model resource |
|
12 | + * |
|
13 | + * @var string |
|
14 | + */ |
|
15 | + protected $modelResource = 'App\Modules\Permissions\Http\Resources\Permission'; |
|
16 | 16 | |
17 | - /** |
|
18 | - * Init new object. |
|
19 | - * |
|
20 | - * @param PermissionService $service |
|
21 | - * @return void |
|
22 | - */ |
|
23 | - public function __construct(PermissionService $service) |
|
24 | - { |
|
25 | - parent::__construct($service); |
|
26 | - } |
|
17 | + /** |
|
18 | + * Init new object. |
|
19 | + * |
|
20 | + * @param PermissionService $service |
|
21 | + * @return void |
|
22 | + */ |
|
23 | + public function __construct(PermissionService $service) |
|
24 | + { |
|
25 | + parent::__construct($service); |
|
26 | + } |
|
27 | 27 | } |
@@ -5,14 +5,14 @@ |
||
5 | 5 | |
6 | 6 | class PermissionService extends BaseService |
7 | 7 | { |
8 | - /** |
|
9 | - * Init new object. |
|
10 | - * |
|
11 | - * @param PermissionRepository $repo |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function __construct(PermissionRepository $repo) |
|
15 | - { |
|
16 | - parent::__construct($repo); |
|
17 | - } |
|
8 | + /** |
|
9 | + * Init new object. |
|
10 | + * |
|
11 | + * @param PermissionRepository $repo |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function __construct(PermissionRepository $repo) |
|
15 | + { |
|
16 | + parent::__construct($repo); |
|
17 | + } |
|
18 | 18 | } |