@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $factory->define(App\Modules\PushNotificationDevices\PushNotificationDevice::class, function (Faker\Generator $faker) { |
4 | - return [ |
|
5 | - 'device_token' => $faker->sha1(), |
|
6 | - 'user_id' => $faker->randomDigitNotNull(), |
|
7 | - 'created_at' => $faker->dateTimeBetween('-1 years', 'now'), |
|
8 | - 'updated_at' => $faker->dateTimeBetween('-1 years', 'now') |
|
9 | - ]; |
|
4 | + return [ |
|
5 | + 'device_token' => $faker->sha1(), |
|
6 | + 'user_id' => $faker->randomDigitNotNull(), |
|
7 | + 'created_at' => $faker->dateTimeBetween('-1 years', 'now'), |
|
8 | + 'updated_at' => $faker->dateTimeBetween('-1 years', 'now') |
|
9 | + ]; |
|
10 | 10 | }); |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -$factory->define(App\Modules\PushNotificationDevices\PushNotificationDevice::class, function (Faker\Generator $faker) { |
|
3 | +$factory->define(App\Modules\PushNotificationDevices\PushNotificationDevice::class, function(Faker\Generator $faker) { |
|
4 | 4 | return [ |
5 | 5 | 'device_token' => $faker->sha1(), |
6 | 6 | 'user_id' => $faker->randomDigitNotNull(), |
@@ -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 | - $adminGroupId = \DB::table('groups')->where('name', 'admin')->select('id')->first()->id; |
|
9 | + /** |
|
10 | + * Run the database seeds. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function run() |
|
15 | + { |
|
16 | + $adminGroupId = \DB::table('groups')->where('name', 'admin')->select('id')->first()->id; |
|
17 | 17 | |
18 | - /** |
|
19 | - * Assign the permissions to the admin group. |
|
20 | - */ |
|
21 | - \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['pushNotificationDevice'])->each(function ($permission) use ($adminGroupId) { |
|
22 | - \DB::table('groups_permissions')->insert( |
|
23 | - [ |
|
24 | - 'permission_id' => $permission->id, |
|
25 | - 'group_id' => $adminGroupId, |
|
26 | - 'created_at' => \DB::raw('NOW()'), |
|
27 | - 'updated_at' => \DB::raw('NOW()') |
|
28 | - ] |
|
29 | - ); |
|
30 | - }); |
|
31 | - } |
|
18 | + /** |
|
19 | + * Assign the permissions to the admin group. |
|
20 | + */ |
|
21 | + \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['pushNotificationDevice'])->each(function ($permission) use ($adminGroupId) { |
|
22 | + \DB::table('groups_permissions')->insert( |
|
23 | + [ |
|
24 | + 'permission_id' => $permission->id, |
|
25 | + 'group_id' => $adminGroupId, |
|
26 | + 'created_at' => \DB::raw('NOW()'), |
|
27 | + 'updated_at' => \DB::raw('NOW()') |
|
28 | + ] |
|
29 | + ); |
|
30 | + }); |
|
31 | + } |
|
32 | 32 | } |
@@ -18,7 +18,7 @@ |
||
18 | 18 | /** |
19 | 19 | * Assign the permissions to the admin group. |
20 | 20 | */ |
21 | - \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['pushNotificationDevice'])->each(function ($permission) use ($adminGroupId) { |
|
21 | + \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['pushNotificationDevice'])->each(function($permission) use ($adminGroupId) { |
|
22 | 22 | \DB::table('groups_permissions')->insert( |
23 | 23 | [ |
24 | 24 | 'permission_id' => $permission->id, |
@@ -6,64 +6,64 @@ |
||
6 | 6 | |
7 | 7 | class PushNotificationDevicesTableSeeder extends Seeder |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the database seeds. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function run() |
|
15 | - { |
|
16 | - /** |
|
17 | - * Insert the permissions related to settings table. |
|
18 | - */ |
|
19 | - \DB::table('permissions')->insert( |
|
20 | - [ |
|
21 | - /** |
|
22 | - * pushNotificationDevices model permissions. |
|
23 | - */ |
|
24 | - [ |
|
25 | - 'name' => 'index', |
|
26 | - 'model' => 'pushNotificationDevice', |
|
27 | - 'created_at' => \DB::raw('NOW()'), |
|
28 | - 'updated_at' => \DB::raw('NOW()') |
|
29 | - ], |
|
30 | - [ |
|
31 | - 'name' => 'find', |
|
32 | - 'model' => 'pushNotificationDevice', |
|
33 | - 'created_at' => \DB::raw('NOW()'), |
|
34 | - 'updated_at' => \DB::raw('NOW()') |
|
35 | - ], |
|
36 | - [ |
|
37 | - 'name' => 'insert', |
|
38 | - 'model' => 'pushNotificationDevice', |
|
39 | - 'created_at' => \DB::raw('NOW()'), |
|
40 | - 'updated_at' => \DB::raw('NOW()') |
|
41 | - ], |
|
42 | - [ |
|
43 | - 'name' => 'update', |
|
44 | - 'model' => 'pushNotificationDevice', |
|
45 | - 'created_at' => \DB::raw('NOW()'), |
|
46 | - 'updated_at' => \DB::raw('NOW()') |
|
47 | - ], |
|
48 | - [ |
|
49 | - 'name' => 'delete', |
|
50 | - 'model' => 'pushNotificationDevice', |
|
51 | - 'created_at' => \DB::raw('NOW()'), |
|
52 | - 'updated_at' => \DB::raw('NOW()') |
|
53 | - ], |
|
54 | - [ |
|
55 | - 'name' => 'deleted', |
|
56 | - 'model' => 'pushNotificationDevice', |
|
57 | - 'created_at' => \DB::raw('NOW()'), |
|
58 | - 'updated_at' => \DB::raw('NOW()') |
|
59 | - ], |
|
60 | - [ |
|
61 | - 'name' => 'restore', |
|
62 | - 'model' => 'pushNotificationDevice', |
|
63 | - 'created_at' => \DB::raw('NOW()'), |
|
64 | - 'updated_at' => \DB::raw('NOW()') |
|
65 | - ] |
|
66 | - ] |
|
67 | - ); |
|
68 | - } |
|
9 | + /** |
|
10 | + * Run the database seeds. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function run() |
|
15 | + { |
|
16 | + /** |
|
17 | + * Insert the permissions related to settings table. |
|
18 | + */ |
|
19 | + \DB::table('permissions')->insert( |
|
20 | + [ |
|
21 | + /** |
|
22 | + * pushNotificationDevices model permissions. |
|
23 | + */ |
|
24 | + [ |
|
25 | + 'name' => 'index', |
|
26 | + 'model' => 'pushNotificationDevice', |
|
27 | + 'created_at' => \DB::raw('NOW()'), |
|
28 | + 'updated_at' => \DB::raw('NOW()') |
|
29 | + ], |
|
30 | + [ |
|
31 | + 'name' => 'find', |
|
32 | + 'model' => 'pushNotificationDevice', |
|
33 | + 'created_at' => \DB::raw('NOW()'), |
|
34 | + 'updated_at' => \DB::raw('NOW()') |
|
35 | + ], |
|
36 | + [ |
|
37 | + 'name' => 'insert', |
|
38 | + 'model' => 'pushNotificationDevice', |
|
39 | + 'created_at' => \DB::raw('NOW()'), |
|
40 | + 'updated_at' => \DB::raw('NOW()') |
|
41 | + ], |
|
42 | + [ |
|
43 | + 'name' => 'update', |
|
44 | + 'model' => 'pushNotificationDevice', |
|
45 | + 'created_at' => \DB::raw('NOW()'), |
|
46 | + 'updated_at' => \DB::raw('NOW()') |
|
47 | + ], |
|
48 | + [ |
|
49 | + 'name' => 'delete', |
|
50 | + 'model' => 'pushNotificationDevice', |
|
51 | + 'created_at' => \DB::raw('NOW()'), |
|
52 | + 'updated_at' => \DB::raw('NOW()') |
|
53 | + ], |
|
54 | + [ |
|
55 | + 'name' => 'deleted', |
|
56 | + 'model' => 'pushNotificationDevice', |
|
57 | + 'created_at' => \DB::raw('NOW()'), |
|
58 | + 'updated_at' => \DB::raw('NOW()') |
|
59 | + ], |
|
60 | + [ |
|
61 | + 'name' => 'restore', |
|
62 | + 'model' => 'pushNotificationDevice', |
|
63 | + 'created_at' => \DB::raw('NOW()'), |
|
64 | + 'updated_at' => \DB::raw('NOW()') |
|
65 | + ] |
|
66 | + ] |
|
67 | + ); |
|
68 | + } |
|
69 | 69 | } |
@@ -6,15 +6,15 @@ |
||
6 | 6 | |
7 | 7 | class PushNotificationDevicesDatabaseSeeder extends Seeder |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the database seeds. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function run() |
|
15 | - { |
|
16 | - $this->call(ClearDataSeeder::class); |
|
17 | - $this->call(PushNotificationDevicesTableSeeder::class); |
|
18 | - $this->call(AssignRelationsSeeder::class); |
|
19 | - } |
|
9 | + /** |
|
10 | + * Run the database seeds. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function run() |
|
15 | + { |
|
16 | + $this->call(ClearDataSeeder::class); |
|
17 | + $this->call(PushNotificationDevicesTableSeeder::class); |
|
18 | + $this->call(AssignRelationsSeeder::class); |
|
19 | + } |
|
20 | 20 | } |
@@ -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('groups_permissions')->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('groups_permissions')->whereIn('permission_id', $permissions->pluck('id'))->delete(); |
|
18 | + $permissions->delete(); |
|
19 | + } |
|
20 | 20 | } |
@@ -5,31 +5,31 @@ |
||
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->integer('user_id'); |
|
19 | - $table->text('access_token')->nullable(); |
|
20 | - $table->unique(array('device_token', 'user_id')); |
|
21 | - $table->softDeletes(); |
|
22 | - $table->timestamps(); |
|
23 | - }); |
|
24 | - } |
|
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->integer('user_id'); |
|
19 | + $table->text('access_token')->nullable(); |
|
20 | + $table->unique(array('device_token', 'user_id')); |
|
21 | + $table->softDeletes(); |
|
22 | + $table->timestamps(); |
|
23 | + }); |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * Reverse the migrations. |
|
28 | - * |
|
29 | - * @return void |
|
30 | - */ |
|
31 | - public function down() |
|
32 | - { |
|
33 | - Schema::dropIfExists('push_notifications_devices'); |
|
34 | - } |
|
26 | + /** |
|
27 | + * Reverse the migrations. |
|
28 | + * |
|
29 | + * @return void |
|
30 | + */ |
|
31 | + public function down() |
|
32 | + { |
|
33 | + Schema::dropIfExists('push_notifications_devices'); |
|
34 | + } |
|
35 | 35 | } |
@@ -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->integer('user_id'); |
@@ -7,25 +7,25 @@ |
||
7 | 7 | |
8 | 8 | class PushNotificationDevice 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 | - 'device_token' => $this->device_token, |
|
25 | - 'access_token' => $this->access_token, |
|
26 | - 'user' => new UserResource($this->whenLoaded('user')), |
|
27 | - 'created_at' => $this->created_at, |
|
28 | - 'updated_at' => $this->updated_at, |
|
29 | - ]; |
|
30 | - } |
|
22 | + return [ |
|
23 | + 'id' => $this->id, |
|
24 | + 'device_token' => $this->device_token, |
|
25 | + 'access_token' => $this->access_token, |
|
26 | + 'user' => new UserResource($this->whenLoaded('user')), |
|
27 | + 'created_at' => $this->created_at, |
|
28 | + 'updated_at' => $this->updated_at, |
|
29 | + ]; |
|
30 | + } |
|
31 | 31 | } |
@@ -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 |
@@ -11,55 +11,55 @@ |
||
11 | 11 | |
12 | 12 | class PushNotificationDeviceController extends BaseApiController |
13 | 13 | { |
14 | - /** |
|
15 | - * List of all route actions that the base api controller |
|
16 | - * will skip permissions check for them. |
|
17 | - * @var array |
|
18 | - */ |
|
19 | - protected $skipPermissionCheck = ['registerDevice']; |
|
14 | + /** |
|
15 | + * List of all route actions that the base api controller |
|
16 | + * will skip permissions check for them. |
|
17 | + * @var array |
|
18 | + */ |
|
19 | + protected $skipPermissionCheck = ['registerDevice']; |
|
20 | 20 | |
21 | - /** |
|
22 | - * Init new object. |
|
23 | - * |
|
24 | - * @param PushNotificationDeviceRepository $repo |
|
25 | - * @param CoreConfig $config |
|
26 | - * @return void |
|
27 | - */ |
|
28 | - public function __construct(PushNotificationDeviceRepository $repo, CoreConfig $config) |
|
29 | - { |
|
30 | - parent::__construct($repo, $config, 'App\Modules\PushNotificationDevices\Http\Resources\PushNotificationDevice'); |
|
31 | - } |
|
21 | + /** |
|
22 | + * Init new object. |
|
23 | + * |
|
24 | + * @param PushNotificationDeviceRepository $repo |
|
25 | + * @param CoreConfig $config |
|
26 | + * @return void |
|
27 | + */ |
|
28 | + public function __construct(PushNotificationDeviceRepository $repo, CoreConfig $config) |
|
29 | + { |
|
30 | + parent::__construct($repo, $config, 'App\Modules\PushNotificationDevices\Http\Resources\PushNotificationDevice'); |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * Insert the given model to storage. |
|
35 | - * |
|
36 | - * @param InsertPushNotificationDevice $request |
|
37 | - * @return \Illuminate\Http\Response |
|
38 | - */ |
|
39 | - public function insert(InsertPushNotificationDevice $request) |
|
40 | - { |
|
41 | - return new $this->modelResource($this->repo->save($request->all())); |
|
42 | - } |
|
33 | + /** |
|
34 | + * Insert the given model to storage. |
|
35 | + * |
|
36 | + * @param InsertPushNotificationDevice $request |
|
37 | + * @return \Illuminate\Http\Response |
|
38 | + */ |
|
39 | + public function insert(InsertPushNotificationDevice $request) |
|
40 | + { |
|
41 | + return new $this->modelResource($this->repo->save($request->all())); |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * Update the given model to storage. |
|
46 | - * |
|
47 | - * @param UpdatePushNotificationDevice $request |
|
48 | - * @return \Illuminate\Http\Response |
|
49 | - */ |
|
50 | - public function update(UpdatePushNotificationDevice $request) |
|
51 | - { |
|
52 | - return new $this->modelResource($this->repo->save($request->all())); |
|
53 | - } |
|
44 | + /** |
|
45 | + * Update the given model to storage. |
|
46 | + * |
|
47 | + * @param UpdatePushNotificationDevice $request |
|
48 | + * @return \Illuminate\Http\Response |
|
49 | + */ |
|
50 | + public function update(UpdatePushNotificationDevice $request) |
|
51 | + { |
|
52 | + return new $this->modelResource($this->repo->save($request->all())); |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * Register the given device to the logged in user. |
|
57 | - * |
|
58 | - * @param RegisterDevice $request |
|
59 | - * @return \Illuminate\Http\Response |
|
60 | - */ |
|
61 | - public function registerDevice(RegisterDevice $request) |
|
62 | - { |
|
63 | - return new $this->modelResource($this->repo->registerDevice($request->all())); |
|
64 | - } |
|
55 | + /** |
|
56 | + * Register the given device to the logged in user. |
|
57 | + * |
|
58 | + * @param RegisterDevice $request |
|
59 | + * @return \Illuminate\Http\Response |
|
60 | + */ |
|
61 | + public function registerDevice(RegisterDevice $request) |
|
62 | + { |
|
63 | + return new $this->modelResource($this->repo->registerDevice($request->all())); |
|
64 | + } |
|
65 | 65 | } |
@@ -6,26 +6,26 @@ |
||
6 | 6 | |
7 | 7 | class InsertPushNotificationDevice extends FormRequest |
8 | 8 | { |
9 | - /** |
|
10 | - * Determine if the user is authorized to make this request. |
|
11 | - * |
|
12 | - * @return bool |
|
13 | - */ |
|
14 | - public function authorize() |
|
15 | - { |
|
16 | - return true; |
|
17 | - } |
|
9 | + /** |
|
10 | + * Determine if the user is authorized to make this request. |
|
11 | + * |
|
12 | + * @return bool |
|
13 | + */ |
|
14 | + public function authorize() |
|
15 | + { |
|
16 | + return true; |
|
17 | + } |
|
18 | 18 | |
19 | - /** |
|
20 | - * Get the validation rules that apply to the request. |
|
21 | - * |
|
22 | - * @return array |
|
23 | - */ |
|
24 | - public function rules() |
|
25 | - { |
|
26 | - return [ |
|
27 | - 'device_token' => 'required|string|max:255', |
|
28 | - 'user_id' => 'required|exists:users,id' |
|
29 | - ]; |
|
30 | - } |
|
19 | + /** |
|
20 | + * Get the validation rules that apply to the request. |
|
21 | + * |
|
22 | + * @return array |
|
23 | + */ |
|
24 | + public function rules() |
|
25 | + { |
|
26 | + return [ |
|
27 | + 'device_token' => 'required|string|max:255', |
|
28 | + 'user_id' => 'required|exists:users,id' |
|
29 | + ]; |
|
30 | + } |
|
31 | 31 | } |