@@ -7,40 +7,40 @@ |
||
7 | 7 | |
8 | 8 | class PassportInstallCommand extends Command |
9 | 9 | { |
10 | - /** |
|
11 | - * The name and signature of the console command. |
|
12 | - * |
|
13 | - * @var string |
|
14 | - */ |
|
15 | - protected $signature = 'module:passport:install |
|
10 | + /** |
|
11 | + * The name and signature of the console command. |
|
12 | + * |
|
13 | + * @var string |
|
14 | + */ |
|
15 | + protected $signature = 'module:passport:install |
|
16 | 16 | {--force : Overwrite keys they already exist} |
17 | 17 | {--length=4096 : The length of the private key}'; |
18 | 18 | |
19 | - /** |
|
20 | - * The console command description. |
|
21 | - * |
|
22 | - * @var string |
|
23 | - */ |
|
24 | - protected $description = 'Run the commands necessary to prepare Passport for use'; |
|
19 | + /** |
|
20 | + * The console command description. |
|
21 | + * |
|
22 | + * @var string |
|
23 | + */ |
|
24 | + protected $description = 'Run the commands necessary to prepare Passport for use'; |
|
25 | 25 | |
26 | - /** |
|
27 | - * Execute the console command. |
|
28 | - * |
|
29 | - * @return void |
|
30 | - */ |
|
31 | - public function handle(ClientRepository $client) |
|
32 | - { |
|
33 | - $this->call('passport:keys', ['--force' => $this->option('force'), '--length' => $this->option('length')]); |
|
34 | - $oauthClient = \Core::oauthCLients()->first(['password_client' => 1]); |
|
35 | - if (! $oauthClient) { |
|
36 | - $oauthClient = $client->createPasswordGrantClient( |
|
37 | - null, |
|
38 | - config('app.name'), |
|
39 | - 'http://localhost' |
|
40 | - ); |
|
41 | - } |
|
42 | - \DotenvEditor::setKey('PASSWORD_CLIENT_ID', $oauthClient->id); |
|
43 | - \DotenvEditor::setKey('PASSWORD_CLIENT_SECRET', $oauthClient->secret); |
|
44 | - \DotenvEditor::save(); |
|
45 | - } |
|
26 | + /** |
|
27 | + * Execute the console command. |
|
28 | + * |
|
29 | + * @return void |
|
30 | + */ |
|
31 | + public function handle(ClientRepository $client) |
|
32 | + { |
|
33 | + $this->call('passport:keys', ['--force' => $this->option('force'), '--length' => $this->option('length')]); |
|
34 | + $oauthClient = \Core::oauthCLients()->first(['password_client' => 1]); |
|
35 | + if (! $oauthClient) { |
|
36 | + $oauthClient = $client->createPasswordGrantClient( |
|
37 | + null, |
|
38 | + config('app.name'), |
|
39 | + 'http://localhost' |
|
40 | + ); |
|
41 | + } |
|
42 | + \DotenvEditor::setKey('PASSWORD_CLIENT_ID', $oauthClient->id); |
|
43 | + \DotenvEditor::setKey('PASSWORD_CLIENT_SECRET', $oauthClient->secret); |
|
44 | + \DotenvEditor::save(); |
|
45 | + } |
|
46 | 46 | } |
@@ -32,7 +32,7 @@ |
||
32 | 32 | { |
33 | 33 | $this->call('passport:keys', ['--force' => $this->option('force'), '--length' => $this->option('length')]); |
34 | 34 | $oauthClient = \Core::oauthCLients()->first(['password_client' => 1]); |
35 | - if (! $oauthClient) { |
|
35 | + if ( ! $oauthClient) { |
|
36 | 36 | $oauthClient = $client->createPasswordGrantClient( |
37 | 37 | null, |
38 | 38 | config('app.name'), |
@@ -8,42 +8,42 @@ |
||
8 | 8 | |
9 | 9 | class DummyController extends BaseApiController |
10 | 10 | { |
11 | - /** |
|
12 | - * Path of the sotre form request. |
|
13 | - * |
|
14 | - * @var string |
|
15 | - */ |
|
16 | - protected $storeFormRequest = 'App\Modules\DummyModule\Http\Requests\StoreDummy'; |
|
11 | + /** |
|
12 | + * Path of the sotre form request. |
|
13 | + * |
|
14 | + * @var string |
|
15 | + */ |
|
16 | + protected $storeFormRequest = 'App\Modules\DummyModule\Http\Requests\StoreDummy'; |
|
17 | 17 | |
18 | - /** |
|
19 | - * Path of the model resource |
|
20 | - * |
|
21 | - * @var string |
|
22 | - */ |
|
23 | - protected $modelResource = 'App\Modules\DummyModule\Http\Resources\DummyModel'; |
|
18 | + /** |
|
19 | + * Path of the model resource |
|
20 | + * |
|
21 | + * @var string |
|
22 | + */ |
|
23 | + protected $modelResource = 'App\Modules\DummyModule\Http\Resources\DummyModel'; |
|
24 | 24 | |
25 | - /** |
|
26 | - * List of all route actions that the base api controller |
|
27 | - * will skip permissions check for them. |
|
28 | - * @var array |
|
29 | - */ |
|
30 | - protected $skipPermissionCheck = []; |
|
25 | + /** |
|
26 | + * List of all route actions that the base api controller |
|
27 | + * will skip permissions check for them. |
|
28 | + * @var array |
|
29 | + */ |
|
30 | + protected $skipPermissionCheck = []; |
|
31 | 31 | |
32 | - /** |
|
33 | - * List of all route actions that the base api controller |
|
34 | - * will skip login check for them. |
|
35 | - * @var array |
|
36 | - */ |
|
37 | - protected $skipLoginCheck = []; |
|
32 | + /** |
|
33 | + * List of all route actions that the base api controller |
|
34 | + * will skip login check for them. |
|
35 | + * @var array |
|
36 | + */ |
|
37 | + protected $skipLoginCheck = []; |
|
38 | 38 | |
39 | - /** |
|
40 | - * Init new object. |
|
41 | - * |
|
42 | - * @param DummyService $service |
|
43 | - * @return void |
|
44 | - */ |
|
45 | - public function __construct(DummyService $service) |
|
46 | - { |
|
47 | - parent::__construct($service); |
|
48 | - } |
|
39 | + /** |
|
40 | + * Init new object. |
|
41 | + * |
|
42 | + * @param DummyService $service |
|
43 | + * @return void |
|
44 | + */ |
|
45 | + public function __construct(DummyService $service) |
|
46 | + { |
|
47 | + parent::__construct($service); |
|
48 | + } |
|
49 | 49 | } |
@@ -6,25 +6,25 @@ |
||
6 | 6 | |
7 | 7 | class StoreDummy 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 | - // |
|
28 | - ]; |
|
29 | - } |
|
19 | + /** |
|
20 | + * Get the validation rules that apply to the request. |
|
21 | + * |
|
22 | + * @return array |
|
23 | + */ |
|
24 | + public function rules() |
|
25 | + { |
|
26 | + return [ |
|
27 | + // |
|
28 | + ]; |
|
29 | + } |
|
30 | 30 | } |
@@ -8,16 +8,16 @@ |
||
8 | 8 | |
9 | 9 | class DummyModel extends Model |
10 | 10 | { |
11 | - use SoftDeletes; |
|
12 | - protected $table = 'DummyTableName'; |
|
13 | - protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
14 | - protected $hidden = ['deleted_at']; |
|
15 | - protected $guarded = ['id']; |
|
16 | - public $fillable = []; // Add attributes here |
|
11 | + use SoftDeletes; |
|
12 | + protected $table = 'DummyTableName'; |
|
13 | + protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
14 | + protected $hidden = ['deleted_at']; |
|
15 | + protected $guarded = ['id']; |
|
16 | + public $fillable = []; // Add attributes here |
|
17 | 17 | |
18 | - public static function boot() |
|
19 | - { |
|
20 | - parent::boot(); |
|
21 | - DummyModel::observe(DummyObserver::class); |
|
22 | - } |
|
18 | + public static function boot() |
|
19 | + { |
|
20 | + parent::boot(); |
|
21 | + DummyModel::observe(DummyObserver::class); |
|
22 | + } |
|
23 | 23 | } |
@@ -6,64 +6,64 @@ |
||
6 | 6 | |
7 | 7 | class DummyTableSeeder 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 DummyModelName table. |
|
18 | - */ |
|
19 | - \DB::table('permissions')->insert( |
|
20 | - [ |
|
21 | - /** |
|
22 | - * DummyModelName model permissions. |
|
23 | - */ |
|
24 | - [ |
|
25 | - 'name' => 'index', |
|
26 | - 'model' => 'DummyModelName', |
|
27 | - 'created_at' => \DB::raw('NOW()'), |
|
28 | - 'updated_at' => \DB::raw('NOW()') |
|
29 | - ], |
|
30 | - [ |
|
31 | - 'name' => 'show', |
|
32 | - 'model' => 'DummyModelName', |
|
33 | - 'created_at' => \DB::raw('NOW()'), |
|
34 | - 'updated_at' => \DB::raw('NOW()') |
|
35 | - ], |
|
36 | - [ |
|
37 | - 'name' => 'store', |
|
38 | - 'model' => 'DummyModelName', |
|
39 | - 'created_at' => \DB::raw('NOW()'), |
|
40 | - 'updated_at' => \DB::raw('NOW()') |
|
41 | - ], |
|
42 | - [ |
|
43 | - 'name' => 'update', |
|
44 | - 'model' => 'DummyModelName', |
|
45 | - 'created_at' => \DB::raw('NOW()'), |
|
46 | - 'updated_at' => \DB::raw('NOW()') |
|
47 | - ], |
|
48 | - [ |
|
49 | - 'name' => 'destroy', |
|
50 | - 'model' => 'DummyModelName', |
|
51 | - 'created_at' => \DB::raw('NOW()'), |
|
52 | - 'updated_at' => \DB::raw('NOW()') |
|
53 | - ], |
|
54 | - [ |
|
55 | - 'name' => 'deleted', |
|
56 | - 'model' => 'DummyModelName', |
|
57 | - 'created_at' => \DB::raw('NOW()'), |
|
58 | - 'updated_at' => \DB::raw('NOW()') |
|
59 | - ], |
|
60 | - [ |
|
61 | - 'name' => 'restore', |
|
62 | - 'model' => 'DummyModelName', |
|
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 DummyModelName table. |
|
18 | + */ |
|
19 | + \DB::table('permissions')->insert( |
|
20 | + [ |
|
21 | + /** |
|
22 | + * DummyModelName model permissions. |
|
23 | + */ |
|
24 | + [ |
|
25 | + 'name' => 'index', |
|
26 | + 'model' => 'DummyModelName', |
|
27 | + 'created_at' => \DB::raw('NOW()'), |
|
28 | + 'updated_at' => \DB::raw('NOW()') |
|
29 | + ], |
|
30 | + [ |
|
31 | + 'name' => 'show', |
|
32 | + 'model' => 'DummyModelName', |
|
33 | + 'created_at' => \DB::raw('NOW()'), |
|
34 | + 'updated_at' => \DB::raw('NOW()') |
|
35 | + ], |
|
36 | + [ |
|
37 | + 'name' => 'store', |
|
38 | + 'model' => 'DummyModelName', |
|
39 | + 'created_at' => \DB::raw('NOW()'), |
|
40 | + 'updated_at' => \DB::raw('NOW()') |
|
41 | + ], |
|
42 | + [ |
|
43 | + 'name' => 'update', |
|
44 | + 'model' => 'DummyModelName', |
|
45 | + 'created_at' => \DB::raw('NOW()'), |
|
46 | + 'updated_at' => \DB::raw('NOW()') |
|
47 | + ], |
|
48 | + [ |
|
49 | + 'name' => 'destroy', |
|
50 | + 'model' => 'DummyModelName', |
|
51 | + 'created_at' => \DB::raw('NOW()'), |
|
52 | + 'updated_at' => \DB::raw('NOW()') |
|
53 | + ], |
|
54 | + [ |
|
55 | + 'name' => 'deleted', |
|
56 | + 'model' => 'DummyModelName', |
|
57 | + 'created_at' => \DB::raw('NOW()'), |
|
58 | + 'updated_at' => \DB::raw('NOW()') |
|
59 | + ], |
|
60 | + [ |
|
61 | + 'name' => 'restore', |
|
62 | + 'model' => 'DummyModelName', |
|
63 | + 'created_at' => \DB::raw('NOW()'), |
|
64 | + 'updated_at' => \DB::raw('NOW()') |
|
65 | + ] |
|
66 | + ] |
|
67 | + ); |
|
68 | + } |
|
69 | 69 | } |
@@ -6,41 +6,41 @@ |
||
6 | 6 | |
7 | 7 | class ApiSkeletonServiceProvider extends ServiceProvider |
8 | 8 | { |
9 | - /** |
|
10 | - * Perform post-registration booting of services. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function boot() |
|
15 | - { |
|
16 | - $this->publishes([ |
|
17 | - __DIR__.'/Modules' => app_path('Modules'), |
|
18 | - __DIR__.'/Modules/Core/Resources/Assets' => base_path('public/doc/assets'), |
|
19 | - __DIR__.'/../lang' => base_path('resources/lang'), |
|
20 | - __DIR__.'/../files/Handler.php' => app_path('Exceptions/Handler.php'), |
|
21 | - __DIR__.'/../files/AuthServiceProvider.php' => app_path('Providers/AuthServiceProvider.php'), |
|
22 | - __DIR__.'/../files/BroadcastServiceProvider.php' => app_path('Providers/BroadcastServiceProvider.php'), |
|
23 | - __DIR__.'/../files/Kernel.php' => app_path('Console/Kernel.php'), |
|
24 | - __DIR__.'/../files/HttpKernel.php' => app_path('Http/Kernel.php'), |
|
25 | - __DIR__.'/../files/channels.php' => base_path('routes/channels.php'), |
|
26 | - __DIR__.'/../files/Jenkinsfile' => base_path('/Jenkinsfile'), |
|
27 | - __DIR__.'/../files/phpcs.xml' => base_path('/phpcs.xml'), |
|
28 | - __DIR__.'/../files/docker' => base_path('/docker'), |
|
29 | - __DIR__.'/../files/.dockerignore' => base_path('/.dockerignore'), |
|
30 | - ]); |
|
9 | + /** |
|
10 | + * Perform post-registration booting of services. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function boot() |
|
15 | + { |
|
16 | + $this->publishes([ |
|
17 | + __DIR__.'/Modules' => app_path('Modules'), |
|
18 | + __DIR__.'/Modules/Core/Resources/Assets' => base_path('public/doc/assets'), |
|
19 | + __DIR__.'/../lang' => base_path('resources/lang'), |
|
20 | + __DIR__.'/../files/Handler.php' => app_path('Exceptions/Handler.php'), |
|
21 | + __DIR__.'/../files/AuthServiceProvider.php' => app_path('Providers/AuthServiceProvider.php'), |
|
22 | + __DIR__.'/../files/BroadcastServiceProvider.php' => app_path('Providers/BroadcastServiceProvider.php'), |
|
23 | + __DIR__.'/../files/Kernel.php' => app_path('Console/Kernel.php'), |
|
24 | + __DIR__.'/../files/HttpKernel.php' => app_path('Http/Kernel.php'), |
|
25 | + __DIR__.'/../files/channels.php' => base_path('routes/channels.php'), |
|
26 | + __DIR__.'/../files/Jenkinsfile' => base_path('/Jenkinsfile'), |
|
27 | + __DIR__.'/../files/phpcs.xml' => base_path('/phpcs.xml'), |
|
28 | + __DIR__.'/../files/docker' => base_path('/docker'), |
|
29 | + __DIR__.'/../files/.dockerignore' => base_path('/.dockerignore'), |
|
30 | + ]); |
|
31 | 31 | |
32 | - $this->publishes([ |
|
33 | - __DIR__.'/../files/auth.php' => config_path('auth.php'), |
|
34 | - ], 'config'); |
|
35 | - } |
|
32 | + $this->publishes([ |
|
33 | + __DIR__.'/../files/auth.php' => config_path('auth.php'), |
|
34 | + ], 'config'); |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * Register any package services. |
|
39 | - * |
|
40 | - * @return void |
|
41 | - */ |
|
42 | - public function register() |
|
43 | - { |
|
44 | - // |
|
45 | - } |
|
37 | + /** |
|
38 | + * Register any package services. |
|
39 | + * |
|
40 | + * @return void |
|
41 | + */ |
|
42 | + public function register() |
|
43 | + { |
|
44 | + // |
|
45 | + } |
|
46 | 46 | } |
@@ -66,7 +66,7 @@ |
||
66 | 66 | * |
67 | 67 | * @param collection $users |
68 | 68 | * @param string $notification |
69 | - * @param Variadic $notificationData |
|
69 | + * @param Variadic[] $notificationData |
|
70 | 70 | * @return void |
71 | 71 | */ |
72 | 72 | public function notify($users, $notification, ...$notificationData) |
@@ -7,72 +7,72 @@ |
||
7 | 7 | |
8 | 8 | class NotificationService extends BaseService |
9 | 9 | { |
10 | - /** |
|
11 | - * Init new object. |
|
12 | - * |
|
13 | - * @param NotificationRepository $repo |
|
14 | - * @return void |
|
15 | - */ |
|
16 | - public function __construct(NotificationRepository $repo) |
|
17 | - { |
|
18 | - parent::__construct($repo); |
|
19 | - } |
|
10 | + /** |
|
11 | + * Init new object. |
|
12 | + * |
|
13 | + * @param NotificationRepository $repo |
|
14 | + * @return void |
|
15 | + */ |
|
16 | + public function __construct(NotificationRepository $repo) |
|
17 | + { |
|
18 | + parent::__construct($repo); |
|
19 | + } |
|
20 | 20 | |
21 | - /** |
|
22 | - * Retrieve all notifications of the logged in user. |
|
23 | - * |
|
24 | - * @param integer $perPage |
|
25 | - * @return Collection |
|
26 | - */ |
|
27 | - public function my($perPage) |
|
28 | - { |
|
29 | - return $this->repo->my($perPage); |
|
30 | - } |
|
21 | + /** |
|
22 | + * Retrieve all notifications of the logged in user. |
|
23 | + * |
|
24 | + * @param integer $perPage |
|
25 | + * @return Collection |
|
26 | + */ |
|
27 | + public function my($perPage) |
|
28 | + { |
|
29 | + return $this->repo->my($perPage); |
|
30 | + } |
|
31 | 31 | |
32 | - /** |
|
33 | - * Retrieve unread notifications of the logged in user. |
|
34 | - * |
|
35 | - * @param integer $perPage |
|
36 | - * @return Collection |
|
37 | - */ |
|
38 | - public function unread($perPage) |
|
39 | - { |
|
40 | - return $this->repo->unread($perPage); |
|
41 | - } |
|
32 | + /** |
|
33 | + * Retrieve unread notifications of the logged in user. |
|
34 | + * |
|
35 | + * @param integer $perPage |
|
36 | + * @return Collection |
|
37 | + */ |
|
38 | + public function unread($perPage) |
|
39 | + { |
|
40 | + return $this->repo->unread($perPage); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * Mark the notification as read. |
|
45 | - * |
|
46 | - * @param integer $id |
|
47 | - * @return object |
|
48 | - */ |
|
49 | - public function markAsRead($id) |
|
50 | - { |
|
51 | - return $this->repo->markAsRead($id); |
|
52 | - } |
|
43 | + /** |
|
44 | + * Mark the notification as read. |
|
45 | + * |
|
46 | + * @param integer $id |
|
47 | + * @return object |
|
48 | + */ |
|
49 | + public function markAsRead($id) |
|
50 | + { |
|
51 | + return $this->repo->markAsRead($id); |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * Mark all notifications as read. |
|
56 | - * |
|
57 | - * @return void |
|
58 | - */ |
|
59 | - public function markAllAsRead() |
|
60 | - { |
|
61 | - return $this->repo->markAllAsRead(); |
|
62 | - } |
|
54 | + /** |
|
55 | + * Mark all notifications as read. |
|
56 | + * |
|
57 | + * @return void |
|
58 | + */ |
|
59 | + public function markAllAsRead() |
|
60 | + { |
|
61 | + return $this->repo->markAllAsRead(); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * Notify th given user with the given notification. |
|
66 | - * |
|
67 | - * @param collection $users |
|
68 | - * @param string $notification |
|
69 | - * @param Variadic $notificationData |
|
70 | - * @return void |
|
71 | - */ |
|
72 | - public function notify($users, $notification, ...$notificationData) |
|
73 | - { |
|
74 | - $users = is_array($users) ? $this->userRepo->findBy(['id' => ['op' => 'in', 'val' => $users]]) : $users; |
|
75 | - $notification = 'App\Modules\Notifications\Notifications\\'.$notification; |
|
76 | - \Notification::send($users, new $notification(...$notificationData)); |
|
77 | - } |
|
64 | + /** |
|
65 | + * Notify th given user with the given notification. |
|
66 | + * |
|
67 | + * @param collection $users |
|
68 | + * @param string $notification |
|
69 | + * @param Variadic $notificationData |
|
70 | + * @return void |
|
71 | + */ |
|
72 | + public function notify($users, $notification, ...$notificationData) |
|
73 | + { |
|
74 | + $users = is_array($users) ? $this->userRepo->findBy(['id' => ['op' => 'in', 'val' => $users]]) : $users; |
|
75 | + $notification = 'App\Modules\Notifications\Notifications\\'.$notification; |
|
76 | + \Notification::send($users, new $notification(...$notificationData)); |
|
77 | + } |
|
78 | 78 | } |
@@ -3,9 +3,6 @@ |
||
3 | 3 | namespace App\Modules\PushNotificationDevices\Services; |
4 | 4 | |
5 | 5 | use App\Modules\Core\BaseClasses\BaseService; |
6 | -use LaravelFCM\Message\OptionsBuilder; |
|
7 | -use LaravelFCM\Message\PayloadDataBuilder; |
|
8 | -use LaravelFCM\Message\PayloadNotificationBuilder; |
|
9 | 6 | use App\Modules\PushNotificationDevices\Repositories\PushNotificationDeviceRepository; |
10 | 7 | |
11 | 8 | class PushNotificationDeviceService extends BaseService |
@@ -10,38 +10,38 @@ |
||
10 | 10 | |
11 | 11 | class PushNotificationDeviceService extends BaseService |
12 | 12 | { |
13 | - /** |
|
14 | - * Init new object. |
|
15 | - * |
|
16 | - * @param PushNotificationDeviceRepository $repo |
|
17 | - * @return void |
|
18 | - */ |
|
19 | - public function __construct(PushNotificationDeviceRepository $repo) |
|
20 | - { |
|
21 | - parent::__construct($repo); |
|
22 | - } |
|
13 | + /** |
|
14 | + * Init new object. |
|
15 | + * |
|
16 | + * @param PushNotificationDeviceRepository $repo |
|
17 | + * @return void |
|
18 | + */ |
|
19 | + public function __construct(PushNotificationDeviceRepository $repo) |
|
20 | + { |
|
21 | + parent::__construct($repo); |
|
22 | + } |
|
23 | 23 | |
24 | - /** |
|
25 | - * Register the given device to the logged in user. |
|
26 | - * |
|
27 | - * @param array $data |
|
28 | - * @return void |
|
29 | - */ |
|
30 | - public function registerDevice($data) |
|
31 | - { |
|
32 | - $data['access_token'] = \Auth::user()->token(); |
|
33 | - $data['user_id'] = \Auth::id(); |
|
34 | - $device = $this->repo->first([ |
|
35 | - 'and' => [ |
|
36 | - 'device_token' => $data['device_token'], |
|
37 | - 'user_id' => $data['user_id'] |
|
38 | - ] |
|
39 | - ]); |
|
24 | + /** |
|
25 | + * Register the given device to the logged in user. |
|
26 | + * |
|
27 | + * @param array $data |
|
28 | + * @return void |
|
29 | + */ |
|
30 | + public function registerDevice($data) |
|
31 | + { |
|
32 | + $data['access_token'] = \Auth::user()->token(); |
|
33 | + $data['user_id'] = \Auth::id(); |
|
34 | + $device = $this->repo->first([ |
|
35 | + 'and' => [ |
|
36 | + 'device_token' => $data['device_token'], |
|
37 | + 'user_id' => $data['user_id'] |
|
38 | + ] |
|
39 | + ]); |
|
40 | 40 | |
41 | - if ($device) { |
|
42 | - $data['id'] = $device->id; |
|
43 | - } |
|
41 | + if ($device) { |
|
42 | + $data['id'] = $device->id; |
|
43 | + } |
|
44 | 44 | |
45 | - return $this->repo->save($data); |
|
46 | - } |
|
45 | + return $this->repo->save($data); |
|
46 | + } |
|
47 | 47 | } |
@@ -7,45 +7,45 @@ |
||
7 | 7 | |
8 | 8 | class ReportRepository extends BaseRepository |
9 | 9 | { |
10 | - /** |
|
11 | - * Init new object. |
|
12 | - * |
|
13 | - * @param Report $model |
|
14 | - * @return void |
|
15 | - */ |
|
16 | - public function __construct(Report $model) |
|
17 | - { |
|
18 | - parent::__construct($model); |
|
19 | - } |
|
10 | + /** |
|
11 | + * Init new object. |
|
12 | + * |
|
13 | + * @param Report $model |
|
14 | + * @return void |
|
15 | + */ |
|
16 | + public function __construct(Report $model) |
|
17 | + { |
|
18 | + parent::__construct($model); |
|
19 | + } |
|
20 | 20 | |
21 | - /** |
|
22 | - * Render the given report db view based on the given |
|
23 | - * condition. |
|
24 | - * |
|
25 | - * @param mixed $report |
|
26 | - * @param array $conditions |
|
27 | - * @param integer $perPage |
|
28 | - * @return object |
|
29 | - */ |
|
30 | - public function renderReport($report, $conditions = [], $perPage = 0) |
|
31 | - { |
|
32 | - $report = ! filter_var($report, FILTER_VALIDATE_INT) ? $report : $this->find($report); |
|
33 | - /** |
|
34 | - * Fetch data from the report based on the given conditions. |
|
35 | - */ |
|
36 | - $report = \DB::table($report->view_name); |
|
37 | - unset($conditions['page']); |
|
38 | - if (count($conditions)) { |
|
39 | - $conditions = $this->constructConditions($conditions, $this->model); |
|
40 | - $report->whereRaw($conditions['conditionString'], $conditions['conditionValues']); |
|
41 | - } |
|
42 | - /** |
|
43 | - * Paginate or all data. |
|
44 | - */ |
|
45 | - if ($perPage) { |
|
46 | - return $report->paginate($perPage); |
|
47 | - } else { |
|
48 | - return $report->get(); |
|
49 | - } |
|
50 | - } |
|
21 | + /** |
|
22 | + * Render the given report db view based on the given |
|
23 | + * condition. |
|
24 | + * |
|
25 | + * @param mixed $report |
|
26 | + * @param array $conditions |
|
27 | + * @param integer $perPage |
|
28 | + * @return object |
|
29 | + */ |
|
30 | + public function renderReport($report, $conditions = [], $perPage = 0) |
|
31 | + { |
|
32 | + $report = ! filter_var($report, FILTER_VALIDATE_INT) ? $report : $this->find($report); |
|
33 | + /** |
|
34 | + * Fetch data from the report based on the given conditions. |
|
35 | + */ |
|
36 | + $report = \DB::table($report->view_name); |
|
37 | + unset($conditions['page']); |
|
38 | + if (count($conditions)) { |
|
39 | + $conditions = $this->constructConditions($conditions, $this->model); |
|
40 | + $report->whereRaw($conditions['conditionString'], $conditions['conditionValues']); |
|
41 | + } |
|
42 | + /** |
|
43 | + * Paginate or all data. |
|
44 | + */ |
|
45 | + if ($perPage) { |
|
46 | + return $report->paginate($perPage); |
|
47 | + } else { |
|
48 | + return $report->get(); |
|
49 | + } |
|
50 | + } |
|
51 | 51 | } |