@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $factory->define(App\Modules\V1\Core\Settings::class, function (Faker\Generator $faker) { |
4 | - return [ |
|
4 | + return [ |
|
5 | 5 | 'name' => $faker->randomElement(['Company Name', 'Title', 'Header Image']), |
6 | 6 | 'value' => $faker->word(), |
7 | 7 | 'key' => $faker->word(), |
8 | 8 | 'created_at' => $faker->dateTimeBetween('-1 years', 'now'), |
9 | 9 | 'updated_at' => $faker->dateTimeBetween('-1 years', 'now') |
10 | - ]; |
|
10 | + ]; |
|
11 | 11 | }); |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -$factory->define(App\Modules\V1\Core\Settings::class, function (Faker\Generator $faker) { |
|
3 | +$factory->define(App\Modules\V1\Core\Settings::class, function(Faker\Generator $faker) { |
|
4 | 4 | return [ |
5 | 5 | 'name' => $faker->randomElement(['Company Name', 'Title', 'Header Image']), |
6 | 6 | 'value' => $faker->word(), |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $factory->define(App\Modules\V1\Core\Log::class, function (Faker\Generator $faker) { |
4 | - return [ |
|
4 | + return [ |
|
5 | 5 | 'action' => $faker->randomElement(['create', 'delete', 'update']), |
6 | 6 | 'item_name ' => $faker->randomElement(['User', 'Settings', 'Group']), |
7 | 7 | 'item_id' => $faker->randomDigitNotNull(), |
8 | 8 | 'user_id' => $faker->randomDigitNotNull(), |
9 | 9 | 'created_at' => $faker->dateTimeBetween('-1 years', 'now'), |
10 | 10 | 'updated_at' => $faker->dateTimeBetween('-1 years', 'now') |
11 | - ]; |
|
11 | + ]; |
|
12 | 12 | }); |
13 | 13 | \ No newline at end of file |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -$factory->define(App\Modules\V1\Core\Log::class, function (Faker\Generator $faker) { |
|
3 | +$factory->define(App\Modules\V1\Core\Log::class, function(Faker\Generator $faker) { |
|
4 | 4 | return [ |
5 | 5 | 'action' => $faker->randomElement(['create', 'delete', 'update']), |
6 | 6 | 'item_name ' => $faker->randomElement(['User', 'Settings', 'Group']), |
@@ -5,53 +5,53 @@ |
||
5 | 5 | */ |
6 | 6 | class LogObserver { |
7 | 7 | |
8 | - public function saving($model) |
|
9 | - { |
|
10 | - // |
|
11 | - } |
|
12 | - |
|
13 | - public function saved($model) |
|
14 | - { |
|
15 | - // |
|
16 | - } |
|
17 | - |
|
18 | - public function creating($model) |
|
19 | - { |
|
20 | - // |
|
21 | - } |
|
22 | - |
|
23 | - public function created($model) |
|
24 | - { |
|
25 | - // |
|
26 | - } |
|
27 | - |
|
28 | - public function updating($model) |
|
29 | - { |
|
30 | - // |
|
31 | - } |
|
32 | - |
|
33 | - public function updated($model) |
|
34 | - { |
|
35 | - // |
|
36 | - } |
|
37 | - |
|
38 | - public function deleting($model) |
|
39 | - { |
|
40 | - // |
|
41 | - } |
|
42 | - |
|
43 | - public function deleted($model) |
|
44 | - { |
|
45 | - // |
|
46 | - } |
|
47 | - |
|
48 | - public function restoring($model) |
|
49 | - { |
|
50 | - // |
|
51 | - } |
|
52 | - |
|
53 | - public function restored($model) |
|
54 | - { |
|
55 | - // |
|
56 | - } |
|
8 | + public function saving($model) |
|
9 | + { |
|
10 | + // |
|
11 | + } |
|
12 | + |
|
13 | + public function saved($model) |
|
14 | + { |
|
15 | + // |
|
16 | + } |
|
17 | + |
|
18 | + public function creating($model) |
|
19 | + { |
|
20 | + // |
|
21 | + } |
|
22 | + |
|
23 | + public function created($model) |
|
24 | + { |
|
25 | + // |
|
26 | + } |
|
27 | + |
|
28 | + public function updating($model) |
|
29 | + { |
|
30 | + // |
|
31 | + } |
|
32 | + |
|
33 | + public function updated($model) |
|
34 | + { |
|
35 | + // |
|
36 | + } |
|
37 | + |
|
38 | + public function deleting($model) |
|
39 | + { |
|
40 | + // |
|
41 | + } |
|
42 | + |
|
43 | + public function deleted($model) |
|
44 | + { |
|
45 | + // |
|
46 | + } |
|
47 | + |
|
48 | + public function restoring($model) |
|
49 | + { |
|
50 | + // |
|
51 | + } |
|
52 | + |
|
53 | + public function restored($model) |
|
54 | + { |
|
55 | + // |
|
56 | + } |
|
57 | 57 | } |
58 | 58 | \ No newline at end of file |
@@ -5,68 +5,68 @@ |
||
5 | 5 | */ |
6 | 6 | class SettingsObserver { |
7 | 7 | |
8 | - public function saving($model) |
|
9 | - { |
|
10 | - // |
|
11 | - } |
|
8 | + public function saving($model) |
|
9 | + { |
|
10 | + // |
|
11 | + } |
|
12 | 12 | |
13 | - public function saved($model) |
|
14 | - { |
|
15 | - // |
|
16 | - } |
|
13 | + public function saved($model) |
|
14 | + { |
|
15 | + // |
|
16 | + } |
|
17 | 17 | |
18 | - /** |
|
19 | - * Prevent the creating of the settings. |
|
20 | - * |
|
21 | - * @param object $model the model beign created. |
|
22 | - * @return void |
|
23 | - */ |
|
24 | - public function creating($model) |
|
25 | - { |
|
26 | - \ErrorHandler::cannotCreateSetting(); |
|
27 | - } |
|
18 | + /** |
|
19 | + * Prevent the creating of the settings. |
|
20 | + * |
|
21 | + * @param object $model the model beign created. |
|
22 | + * @return void |
|
23 | + */ |
|
24 | + public function creating($model) |
|
25 | + { |
|
26 | + \ErrorHandler::cannotCreateSetting(); |
|
27 | + } |
|
28 | 28 | |
29 | - public function created($model) |
|
30 | - { |
|
31 | - // |
|
32 | - } |
|
29 | + public function created($model) |
|
30 | + { |
|
31 | + // |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * Prevent updating of the setting key. |
|
36 | - * |
|
37 | - * @param object $model the model beign updated. |
|
38 | - * @return void |
|
39 | - */ |
|
40 | - public function updating($model) |
|
41 | - { |
|
42 | - if ($model->getOriginal('key') !== $model->key) |
|
43 | - { |
|
44 | - \ErrorHandler::cannotUpdateSettingKey(); |
|
45 | - } |
|
46 | - } |
|
34 | + /** |
|
35 | + * Prevent updating of the setting key. |
|
36 | + * |
|
37 | + * @param object $model the model beign updated. |
|
38 | + * @return void |
|
39 | + */ |
|
40 | + public function updating($model) |
|
41 | + { |
|
42 | + if ($model->getOriginal('key') !== $model->key) |
|
43 | + { |
|
44 | + \ErrorHandler::cannotUpdateSettingKey(); |
|
45 | + } |
|
46 | + } |
|
47 | 47 | |
48 | - public function updated($model) |
|
49 | - { |
|
50 | - // |
|
51 | - } |
|
48 | + public function updated($model) |
|
49 | + { |
|
50 | + // |
|
51 | + } |
|
52 | 52 | |
53 | - public function deleting($model) |
|
54 | - { |
|
55 | - // |
|
56 | - } |
|
53 | + public function deleting($model) |
|
54 | + { |
|
55 | + // |
|
56 | + } |
|
57 | 57 | |
58 | - public function deleted($model) |
|
59 | - { |
|
60 | - // |
|
61 | - } |
|
58 | + public function deleted($model) |
|
59 | + { |
|
60 | + // |
|
61 | + } |
|
62 | 62 | |
63 | - public function restoring($model) |
|
64 | - { |
|
65 | - // |
|
66 | - } |
|
63 | + public function restoring($model) |
|
64 | + { |
|
65 | + // |
|
66 | + } |
|
67 | 67 | |
68 | - public function restored($model) |
|
69 | - { |
|
70 | - // |
|
71 | - } |
|
68 | + public function restored($model) |
|
69 | + { |
|
70 | + // |
|
71 | + } |
|
72 | 72 | } |
73 | 73 | \ No newline at end of file |
@@ -3,10 +3,10 @@ discard block |
||
3 | 3 | |
4 | 4 | class CoreConfig |
5 | 5 | { |
6 | - public function getConfig() |
|
7 | - { |
|
8 | - return [ |
|
9 | - 'resetLink' => '{{link_here}}', |
|
6 | + public function getConfig() |
|
7 | + { |
|
8 | + return [ |
|
9 | + 'resetLink' => '{{link_here}}', |
|
10 | 10 | /** |
11 | 11 | * Specify what relations should be used for every model. |
12 | 12 | */ |
@@ -180,5 +180,5 @@ discard block |
||
180 | 180 | ] |
181 | 181 | ] |
182 | 182 | ]; |
183 | - } |
|
183 | + } |
|
184 | 184 | } |
185 | 185 | \ No newline at end of file |
@@ -1,7 +1,6 @@ |
||
1 | 1 | <?php namespace App\Modules\V1\Acl; |
2 | 2 | |
3 | 3 | use App\User; |
4 | -use Illuminate\Database\Eloquent\Model; |
|
5 | 4 | use Illuminate\Database\Eloquent\SoftDeletes; |
6 | 5 | use Tymon\JWTAuth\Contracts\JWTSubject as AuthenticatableUserContract; |
7 | 6 |
@@ -7,68 +7,68 @@ |
||
7 | 7 | |
8 | 8 | class AclUser extends User implements AuthenticatableUserContract { |
9 | 9 | |
10 | - use SoftDeletes; |
|
11 | - protected $table = 'users'; |
|
12 | - protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
13 | - protected $hidden = ['password', 'remember_token','deleted_at']; |
|
14 | - protected $guarded = ['id']; |
|
15 | - protected $fillable = ['name', 'email', 'password']; |
|
16 | - public $searchable = ['name', 'email']; |
|
10 | + use SoftDeletes; |
|
11 | + protected $table = 'users'; |
|
12 | + protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
13 | + protected $hidden = ['password', 'remember_token','deleted_at']; |
|
14 | + protected $guarded = ['id']; |
|
15 | + protected $fillable = ['name', 'email', 'password']; |
|
16 | + public $searchable = ['name', 'email']; |
|
17 | 17 | |
18 | - public function getJWTIdentifier() |
|
19 | - { |
|
20 | - return $this->getKey(); |
|
21 | - } |
|
18 | + public function getJWTIdentifier() |
|
19 | + { |
|
20 | + return $this->getKey(); |
|
21 | + } |
|
22 | 22 | |
23 | - public function getJWTCustomClaims() |
|
24 | - { |
|
25 | - return []; |
|
26 | - } |
|
23 | + public function getJWTCustomClaims() |
|
24 | + { |
|
25 | + return []; |
|
26 | + } |
|
27 | 27 | |
28 | - public function getCreatedAtAttribute($value) |
|
29 | - { |
|
30 | - return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString(); |
|
31 | - } |
|
28 | + public function getCreatedAtAttribute($value) |
|
29 | + { |
|
30 | + return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString(); |
|
31 | + } |
|
32 | 32 | |
33 | - public function getUpdatedAtAttribute($value) |
|
34 | - { |
|
35 | - return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString(); |
|
36 | - } |
|
33 | + public function getUpdatedAtAttribute($value) |
|
34 | + { |
|
35 | + return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString(); |
|
36 | + } |
|
37 | 37 | |
38 | - public function getDeletedAtAttribute($value) |
|
39 | - { |
|
40 | - return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString(); |
|
41 | - } |
|
38 | + public function getDeletedAtAttribute($value) |
|
39 | + { |
|
40 | + return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString(); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * Encrypt the password attribute before |
|
45 | - * saving it in the storage. |
|
46 | - * |
|
47 | - * @param string $value |
|
48 | - */ |
|
49 | - public function setPasswordAttribute($value) |
|
50 | - { |
|
51 | - $this->attributes['password'] = bcrypt($value); |
|
52 | - } |
|
43 | + /** |
|
44 | + * Encrypt the password attribute before |
|
45 | + * saving it in the storage. |
|
46 | + * |
|
47 | + * @param string $value |
|
48 | + */ |
|
49 | + public function setPasswordAttribute($value) |
|
50 | + { |
|
51 | + $this->attributes['password'] = bcrypt($value); |
|
52 | + } |
|
53 | 53 | |
54 | - public function logs() |
|
55 | - { |
|
56 | - return $this->hasMany('App\Modules\V1\Core\Log', 'user_id'); |
|
57 | - } |
|
54 | + public function logs() |
|
55 | + { |
|
56 | + return $this->hasMany('App\Modules\V1\Core\Log', 'user_id'); |
|
57 | + } |
|
58 | 58 | |
59 | - public function groups() |
|
60 | - { |
|
61 | - return $this->belongsToMany('\App\Modules\V1\Acl\AclGroup','users_groups','user_id','group_id')->whereNull('users_groups.deleted_at')->withTimestamps(); |
|
62 | - } |
|
59 | + public function groups() |
|
60 | + { |
|
61 | + return $this->belongsToMany('\App\Modules\V1\Acl\AclGroup','users_groups','user_id','group_id')->whereNull('users_groups.deleted_at')->withTimestamps(); |
|
62 | + } |
|
63 | 63 | |
64 | - public function employee() |
|
65 | - { |
|
66 | - return $this->hasOne('App\Modules\V1\Tobacco\Employee', 'user_id'); |
|
67 | - } |
|
64 | + public function employee() |
|
65 | + { |
|
66 | + return $this->hasOne('App\Modules\V1\Tobacco\Employee', 'user_id'); |
|
67 | + } |
|
68 | 68 | |
69 | - public static function boot() |
|
70 | - { |
|
71 | - parent::boot(); |
|
72 | - parent::observe(\App::make('App\Modules\V1\Acl\ModelObservers\AclUserObserver')); |
|
73 | - } |
|
69 | + public static function boot() |
|
70 | + { |
|
71 | + parent::boot(); |
|
72 | + parent::observe(\App::make('App\Modules\V1\Acl\ModelObservers\AclUserObserver')); |
|
73 | + } |
|
74 | 74 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | use SoftDeletes; |
11 | 11 | protected $table = 'users'; |
12 | 12 | protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
13 | - protected $hidden = ['password', 'remember_token','deleted_at']; |
|
13 | + protected $hidden = ['password', 'remember_token', 'deleted_at']; |
|
14 | 14 | protected $guarded = ['id']; |
15 | 15 | protected $fillable = ['name', 'email', 'password']; |
16 | 16 | public $searchable = ['name', 'email']; |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | |
59 | 59 | public function groups() |
60 | 60 | { |
61 | - return $this->belongsToMany('\App\Modules\V1\Acl\AclGroup','users_groups','user_id','group_id')->whereNull('users_groups.deleted_at')->withTimestamps(); |
|
61 | + return $this->belongsToMany('\App\Modules\V1\Acl\AclGroup', 'users_groups', 'user_id', 'group_id')->whereNull('users_groups.deleted_at')->withTimestamps(); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | public function employee() |
@@ -20,6 +20,9 @@ |
||
20 | 20 | /** |
21 | 21 | * Create a new job instance. |
22 | 22 | * |
23 | + * @param \LaravelFCM\Message\Options $option |
|
24 | + * @param \LaravelFCM\Message\PayloadNotification $notification |
|
25 | + * @param \LaravelFCM\Message\PayloadData $data |
|
23 | 26 | * @return void |
24 | 27 | */ |
25 | 28 | public function __construct($option, $notification, $data, $tokens) |
@@ -10,58 +10,58 @@ |
||
10 | 10 | |
11 | 11 | class PushNotifications implements ShouldQueue |
12 | 12 | { |
13 | - use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; |
|
13 | + use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; |
|
14 | 14 | |
15 | - protected $option; |
|
16 | - protected $notification; |
|
17 | - protected $data; |
|
18 | - protected $tokens; |
|
15 | + protected $option; |
|
16 | + protected $notification; |
|
17 | + protected $data; |
|
18 | + protected $tokens; |
|
19 | 19 | |
20 | - /** |
|
21 | - * Create a new job instance. |
|
22 | - * |
|
23 | - * @return void |
|
24 | - */ |
|
25 | - public function __construct($option, $notification, $data, $tokens) |
|
26 | - { |
|
27 | - $this->option = $option; |
|
28 | - $this->notification = $notification; |
|
29 | - $this->data = $data; |
|
30 | - $this->tokens = $tokens; |
|
31 | - } |
|
20 | + /** |
|
21 | + * Create a new job instance. |
|
22 | + * |
|
23 | + * @return void |
|
24 | + */ |
|
25 | + public function __construct($option, $notification, $data, $tokens) |
|
26 | + { |
|
27 | + $this->option = $option; |
|
28 | + $this->notification = $notification; |
|
29 | + $this->data = $data; |
|
30 | + $this->tokens = $tokens; |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * Execute the job. |
|
35 | - * |
|
36 | - * @return void |
|
37 | - */ |
|
38 | - public function handle() |
|
39 | - { |
|
40 | - $this->push($this->tokens); |
|
41 | - } |
|
33 | + /** |
|
34 | + * Execute the job. |
|
35 | + * |
|
36 | + * @return void |
|
37 | + */ |
|
38 | + public function handle() |
|
39 | + { |
|
40 | + $this->push($this->tokens); |
|
41 | + } |
|
42 | 42 | |
43 | - private function push($tokens) |
|
44 | - { |
|
45 | - $downstreamResponse = \FCM::sendTo($tokens, $this->option, $this->notification, $this->data); |
|
43 | + private function push($tokens) |
|
44 | + { |
|
45 | + $downstreamResponse = \FCM::sendTo($tokens, $this->option, $this->notification, $this->data); |
|
46 | 46 | |
47 | - \Core::pushNotificationDevices()->model->whereIn('device_token', $downstreamResponse->tokensToDelete())->forceDelete(); |
|
48 | - \Core::pushNotificationDevices()->model->whereIn('device_token', $downstreamResponse->tokensWithError())->forceDelete(); |
|
47 | + \Core::pushNotificationDevices()->model->whereIn('device_token', $downstreamResponse->tokensToDelete())->forceDelete(); |
|
48 | + \Core::pushNotificationDevices()->model->whereIn('device_token', $downstreamResponse->tokensWithError())->forceDelete(); |
|
49 | 49 | |
50 | - foreach ($downstreamResponse->tokensToModify() as $old => $new) |
|
51 | - { |
|
52 | - if ($oldDevice = \Core::pushNotificationDevices()->model->where('device_token', $old)->first()) |
|
53 | - { |
|
54 | - \Core::pushNotificationDevices()->save([ |
|
55 | - 'id' => $oldDevice->id, |
|
56 | - 'device_token' => $new |
|
57 | - ]); |
|
58 | - } |
|
59 | - } |
|
50 | + foreach ($downstreamResponse->tokensToModify() as $old => $new) |
|
51 | + { |
|
52 | + if ($oldDevice = \Core::pushNotificationDevices()->model->where('device_token', $old)->first()) |
|
53 | + { |
|
54 | + \Core::pushNotificationDevices()->save([ |
|
55 | + 'id' => $oldDevice->id, |
|
56 | + 'device_token' => $new |
|
57 | + ]); |
|
58 | + } |
|
59 | + } |
|
60 | 60 | |
61 | - $retry = $downstreamResponse->tokensToRetry(); |
|
62 | - if (count($retry)) |
|
63 | - { |
|
64 | - $this->push($retry); |
|
65 | - } |
|
66 | - } |
|
61 | + $retry = $downstreamResponse->tokensToRetry(); |
|
62 | + if (count($retry)) |
|
63 | + { |
|
64 | + $this->push($retry); |
|
65 | + } |
|
66 | + } |
|
67 | 67 | } |
@@ -21,9 +21,6 @@ |
||
21 | 21 | /** |
22 | 22 | * Set the notification notified to all. |
23 | 23 | * |
24 | - * @param array $users_ids |
|
25 | - * @param string $title |
|
26 | - * @param string $message |
|
27 | 24 | * @param string $data |
28 | 25 | * @return void |
29 | 26 | */ |
@@ -8,66 +8,66 @@ |
||
8 | 8 | |
9 | 9 | class PushNotificationDeviceRepository extends AbstractRepository |
10 | 10 | { |
11 | - /** |
|
12 | - * Return the model full namespace. |
|
13 | - * |
|
14 | - * @return string |
|
15 | - */ |
|
16 | - protected function getModel() |
|
17 | - { |
|
18 | - return 'App\Modules\V1\Notifications\PushNotificationDevice'; |
|
19 | - } |
|
11 | + /** |
|
12 | + * Return the model full namespace. |
|
13 | + * |
|
14 | + * @return string |
|
15 | + */ |
|
16 | + protected function getModel() |
|
17 | + { |
|
18 | + return 'App\Modules\V1\Notifications\PushNotificationDevice'; |
|
19 | + } |
|
20 | 20 | |
21 | - /** |
|
22 | - * Set the notification notified to all. |
|
23 | - * |
|
24 | - * @param array $users_ids |
|
25 | - * @param string $title |
|
26 | - * @param string $message |
|
27 | - * @param string $data |
|
28 | - * @return void |
|
29 | - */ |
|
30 | - public function registerDevice($data) |
|
31 | - { |
|
32 | - $data['user_id'] = \JWTAuth::parseToken()->authenticate()->id; |
|
33 | - if ($device = $this->model->where('device_token', $data['device_token'])->where('user_id', $data['user_id'])->first()) |
|
34 | - { |
|
35 | - $data['id'] = $device->id; |
|
36 | - } |
|
21 | + /** |
|
22 | + * Set the notification notified to all. |
|
23 | + * |
|
24 | + * @param array $users_ids |
|
25 | + * @param string $title |
|
26 | + * @param string $message |
|
27 | + * @param string $data |
|
28 | + * @return void |
|
29 | + */ |
|
30 | + public function registerDevice($data) |
|
31 | + { |
|
32 | + $data['user_id'] = \JWTAuth::parseToken()->authenticate()->id; |
|
33 | + if ($device = $this->model->where('device_token', $data['device_token'])->where('user_id', $data['user_id'])->first()) |
|
34 | + { |
|
35 | + $data['id'] = $device->id; |
|
36 | + } |
|
37 | 37 | |
38 | - return $this->save($data); |
|
39 | - } |
|
38 | + return $this->save($data); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * Set the notification notified to all. |
|
43 | - * |
|
44 | - * @param array $userIds |
|
45 | - * @param string $title |
|
46 | - * @param string $message |
|
47 | - * @param string $data |
|
48 | - * @return void |
|
49 | - */ |
|
50 | - public function push($userIds, $title, $message, $data = []) |
|
51 | - { |
|
52 | - if (count($userIds)) |
|
53 | - { |
|
54 | - $optionBuilder = new OptionsBuilder(); |
|
55 | - $notificationBuilder = new PayloadNotificationBuilder($title); |
|
56 | - $dataBuilder = new PayloadDataBuilder(); |
|
41 | + /** |
|
42 | + * Set the notification notified to all. |
|
43 | + * |
|
44 | + * @param array $userIds |
|
45 | + * @param string $title |
|
46 | + * @param string $message |
|
47 | + * @param string $data |
|
48 | + * @return void |
|
49 | + */ |
|
50 | + public function push($userIds, $title, $message, $data = []) |
|
51 | + { |
|
52 | + if (count($userIds)) |
|
53 | + { |
|
54 | + $optionBuilder = new OptionsBuilder(); |
|
55 | + $notificationBuilder = new PayloadNotificationBuilder($title); |
|
56 | + $dataBuilder = new PayloadDataBuilder(); |
|
57 | 57 | |
58 | - $optionBuilder->setTimeToLive(60*20); |
|
59 | - $notificationBuilder->setBody($message); |
|
60 | - $dataBuilder->addData($data); |
|
58 | + $optionBuilder->setTimeToLive(60*20); |
|
59 | + $notificationBuilder->setBody($message); |
|
60 | + $dataBuilder->addData($data); |
|
61 | 61 | |
62 | - $option = $optionBuilder->build(); |
|
63 | - $notification = $notificationBuilder->build(); |
|
64 | - $data = $dataBuilder->build(); |
|
65 | - $tokens = $this->model->whereIn('user_id', $userIds)->pluck('device_token')->toArray(); |
|
62 | + $option = $optionBuilder->build(); |
|
63 | + $notification = $notificationBuilder->build(); |
|
64 | + $data = $dataBuilder->build(); |
|
65 | + $tokens = $this->model->whereIn('user_id', $userIds)->pluck('device_token')->toArray(); |
|
66 | 66 | |
67 | - if (count($tokens)) |
|
68 | - { |
|
69 | - dispatch(new PushNotifications($option, $notification, $data, $tokens)); |
|
70 | - } |
|
71 | - } |
|
72 | - } |
|
67 | + if (count($tokens)) |
|
68 | + { |
|
69 | + dispatch(new PushNotifications($option, $notification, $data, $tokens)); |
|
70 | + } |
|
71 | + } |
|
72 | + } |
|
73 | 73 | } |
@@ -55,7 +55,7 @@ |
||
55 | 55 | $notificationBuilder = new PayloadNotificationBuilder($title); |
56 | 56 | $dataBuilder = new PayloadDataBuilder(); |
57 | 57 | |
58 | - $optionBuilder->setTimeToLive(60*20); |
|
58 | + $optionBuilder->setTimeToLive(60 * 20); |
|
59 | 59 | $notificationBuilder->setBody($message); |
60 | 60 | $dataBuilder->addData($data); |
61 | 61 |
@@ -7,43 +7,43 @@ |
||
7 | 7 | |
8 | 8 | class PushNotificationsDevicesController extends BaseApiController |
9 | 9 | { |
10 | - /** |
|
11 | - * The name of the model that is used by the base api controller |
|
12 | - * to preform actions like (add, edit ... etc). |
|
13 | - * @var string |
|
14 | - */ |
|
15 | - protected $model = 'pushNotificationDevices'; |
|
10 | + /** |
|
11 | + * The name of the model that is used by the base api controller |
|
12 | + * to preform actions like (add, edit ... etc). |
|
13 | + * @var string |
|
14 | + */ |
|
15 | + protected $model = 'pushNotificationDevices'; |
|
16 | 16 | |
17 | - /** |
|
18 | - * List of all route actions that the base api controller |
|
19 | - * will skip permissions check for them. |
|
20 | - * @var array |
|
21 | - */ |
|
22 | - protected $skipPermissionCheck = ['registerDevice']; |
|
17 | + /** |
|
18 | + * List of all route actions that the base api controller |
|
19 | + * will skip permissions check for them. |
|
20 | + * @var array |
|
21 | + */ |
|
22 | + protected $skipPermissionCheck = ['registerDevice']; |
|
23 | 23 | |
24 | - /** |
|
25 | - * The validations rules used by the base api controller |
|
26 | - * to check before add. |
|
27 | - * @var array |
|
28 | - */ |
|
29 | - protected $validationRules = [ |
|
30 | - 'device_token' => 'required|string|max:255', |
|
31 | - 'user_id' => 'required|exists:users,id', |
|
32 | - 'active' => 'boolean' |
|
33 | - ]; |
|
24 | + /** |
|
25 | + * The validations rules used by the base api controller |
|
26 | + * to check before add. |
|
27 | + * @var array |
|
28 | + */ |
|
29 | + protected $validationRules = [ |
|
30 | + 'device_token' => 'required|string|max:255', |
|
31 | + 'user_id' => 'required|exists:users,id', |
|
32 | + 'active' => 'boolean' |
|
33 | + ]; |
|
34 | 34 | |
35 | - /** |
|
36 | - * Register the given device to the logged in user. |
|
37 | - * |
|
38 | - * @param \Illuminate\Http\Request $request |
|
39 | - * @return \Illuminate\Http\Response |
|
40 | - */ |
|
41 | - public function registerDevice(Request $request) |
|
42 | - { |
|
43 | - $this->validate($request, [ |
|
44 | - 'device_token' => 'required|string|max:255' |
|
45 | - ]); |
|
35 | + /** |
|
36 | + * Register the given device to the logged in user. |
|
37 | + * |
|
38 | + * @param \Illuminate\Http\Request $request |
|
39 | + * @return \Illuminate\Http\Response |
|
40 | + */ |
|
41 | + public function registerDevice(Request $request) |
|
42 | + { |
|
43 | + $this->validate($request, [ |
|
44 | + 'device_token' => 'required|string|max:255' |
|
45 | + ]); |
|
46 | 46 | |
47 | - return \Response::json(\Core::pushNotificationDevices()->registerDevice($request->all()), 200); |
|
48 | - } |
|
47 | + return \Response::json(\Core::pushNotificationDevices()->registerDevice($request->all()), 200); |
|
48 | + } |
|
49 | 49 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * to preform actions like (add, edit ... etc). |
13 | 13 | * @var string |
14 | 14 | */ |
15 | - protected $model = 'pushNotificationDevices'; |
|
15 | + protected $model = 'pushNotificationDevices'; |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * List of all route actions that the base api controller |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * to check before add. |
27 | 27 | * @var array |
28 | 28 | */ |
29 | - protected $validationRules = [ |
|
29 | + protected $validationRules = [ |
|
30 | 30 | 'device_token' => 'required|string|max:255', |
31 | 31 | 'user_id' => 'required|exists:users,id', |
32 | 32 | 'active' => 'boolean' |