@@ -9,43 +9,43 @@ |
||
9 | 9 | |
10 | 10 | class ResetPassword extends Notification implements ShouldQueue |
11 | 11 | { |
12 | - use Queueable; |
|
12 | + use Queueable; |
|
13 | 13 | |
14 | - protected $token; |
|
14 | + protected $token; |
|
15 | 15 | |
16 | - /** |
|
17 | - * Init new object. |
|
18 | - * |
|
19 | - * @return void |
|
20 | - */ |
|
21 | - public function __construct($token) |
|
22 | - { |
|
23 | - $this->token = $token; |
|
24 | - } |
|
16 | + /** |
|
17 | + * Init new object. |
|
18 | + * |
|
19 | + * @return void |
|
20 | + */ |
|
21 | + public function __construct($token) |
|
22 | + { |
|
23 | + $this->token = $token; |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * Get the notification's delivery channels. |
|
28 | - * |
|
29 | - * @param mixed $notifiable |
|
30 | - * @return string[] |
|
31 | - */ |
|
32 | - public function via($notifiable) |
|
33 | - { |
|
34 | - return ['mail']; |
|
35 | - } |
|
26 | + /** |
|
27 | + * Get the notification's delivery channels. |
|
28 | + * |
|
29 | + * @param mixed $notifiable |
|
30 | + * @return string[] |
|
31 | + */ |
|
32 | + public function via($notifiable) |
|
33 | + { |
|
34 | + return ['mail']; |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * Get the mail representation of the notification. |
|
39 | - * |
|
40 | - * @param mixed $notifiable |
|
41 | - * @return \Illuminate\Notifications\Messages\MailMessage |
|
42 | - */ |
|
43 | - public function toMail($notifiable) |
|
44 | - { |
|
45 | - return (new MailMessage) |
|
46 | - ->subject('Reset passowrd') |
|
47 | - ->line('Reset passowrd') |
|
48 | - ->line('To reset your password click on the button below') |
|
49 | - ->action('Reset password', config('skeleton.reset_password_url').'/'.$this->token); |
|
50 | - } |
|
37 | + /** |
|
38 | + * Get the mail representation of the notification. |
|
39 | + * |
|
40 | + * @param mixed $notifiable |
|
41 | + * @return \Illuminate\Notifications\Messages\MailMessage |
|
42 | + */ |
|
43 | + public function toMail($notifiable) |
|
44 | + { |
|
45 | + return (new MailMessage) |
|
46 | + ->subject('Reset passowrd') |
|
47 | + ->line('Reset passowrd') |
|
48 | + ->line('To reset your password click on the button below') |
|
49 | + ->action('Reset password', config('skeleton.reset_password_url').'/'.$this->token); |
|
50 | + } |
|
51 | 51 | } |
@@ -5,29 +5,29 @@ |
||
5 | 5 | |
6 | 6 | class SettingRepository extends BaseRepository |
7 | 7 | { |
8 | - /** |
|
9 | - * Init new object. |
|
10 | - * |
|
11 | - * @param Setting $model |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function __construct(Setting $model) |
|
15 | - { |
|
16 | - parent::__construct($model); |
|
17 | - } |
|
8 | + /** |
|
9 | + * Init new object. |
|
10 | + * |
|
11 | + * @param Setting $model |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function __construct(Setting $model) |
|
15 | + { |
|
16 | + parent::__construct($model); |
|
17 | + } |
|
18 | 18 | |
19 | - /** |
|
20 | - * Save list of settings. |
|
21 | - * |
|
22 | - * @param array $data |
|
23 | - * @return void |
|
24 | - */ |
|
25 | - public function saveMany(array $data) |
|
26 | - { |
|
27 | - \DB::transaction(function () use ($data) { |
|
28 | - foreach ($data as $value) { |
|
29 | - $this->save($value); |
|
30 | - } |
|
31 | - }); |
|
32 | - } |
|
19 | + /** |
|
20 | + * Save list of settings. |
|
21 | + * |
|
22 | + * @param array $data |
|
23 | + * @return void |
|
24 | + */ |
|
25 | + public function saveMany(array $data) |
|
26 | + { |
|
27 | + \DB::transaction(function () use ($data) { |
|
28 | + foreach ($data as $value) { |
|
29 | + $this->save($value); |
|
30 | + } |
|
31 | + }); |
|
32 | + } |
|
33 | 33 | } |
@@ -2,15 +2,15 @@ |
||
2 | 2 | |
3 | 3 | interface BaseFactoryInterface |
4 | 4 | { |
5 | - /** |
|
6 | - * Construct the repository class name based on |
|
7 | - * the method name called, search in the |
|
8 | - * given namespaces for the class and |
|
9 | - * return an instance. |
|
10 | - * |
|
11 | - * @param string $name the called method name |
|
12 | - * @param array $arguments the method arguments |
|
13 | - * @return object |
|
14 | - */ |
|
15 | - public function __call($name, $arguments); |
|
5 | + /** |
|
6 | + * Construct the repository class name based on |
|
7 | + * the method name called, search in the |
|
8 | + * given namespaces for the class and |
|
9 | + * return an instance. |
|
10 | + * |
|
11 | + * @param string $name the called method name |
|
12 | + * @param array $arguments the method arguments |
|
13 | + * @return object |
|
14 | + */ |
|
15 | + public function __call($name, $arguments); |
|
16 | 16 | } |
@@ -5,65 +5,65 @@ |
||
5 | 5 | |
6 | 6 | class ReportRepository extends BaseRepository |
7 | 7 | { |
8 | - /** |
|
9 | - * Init new object. |
|
10 | - * |
|
11 | - * @param Report $model |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function __construct(Report $model) |
|
15 | - { |
|
16 | - parent::__construct($model); |
|
17 | - } |
|
8 | + /** |
|
9 | + * Init new object. |
|
10 | + * |
|
11 | + * @param Report $model |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function __construct(Report $model) |
|
15 | + { |
|
16 | + parent::__construct($model); |
|
17 | + } |
|
18 | 18 | |
19 | - /** |
|
20 | - * Render the given report db view based on the given |
|
21 | - * condition. |
|
22 | - * |
|
23 | - * @param string $reportName |
|
24 | - * @param array $conditions |
|
25 | - * @param integer $perPage |
|
26 | - * @param array $relations |
|
27 | - * @param boolean $skipPermission |
|
28 | - * @return object |
|
29 | - */ |
|
30 | - public function getReport($reportName, $conditions = [], $perPage = 0, $relations = [], $skipPermission = false) |
|
31 | - { |
|
32 | - /** |
|
33 | - * Fetch the report from db. |
|
34 | - */ |
|
35 | - $reportConditions = $this->constructConditions(['report_name' => $reportName], $this->model); |
|
36 | - $report = $this->model->with($relations) |
|
37 | - ->whereRaw( |
|
38 | - $reportConditions['conditionString'], |
|
39 | - $reportConditions['conditionValues'] |
|
40 | - )->first(); |
|
19 | + /** |
|
20 | + * Render the given report db view based on the given |
|
21 | + * condition. |
|
22 | + * |
|
23 | + * @param string $reportName |
|
24 | + * @param array $conditions |
|
25 | + * @param integer $perPage |
|
26 | + * @param array $relations |
|
27 | + * @param boolean $skipPermission |
|
28 | + * @return object |
|
29 | + */ |
|
30 | + public function getReport($reportName, $conditions = [], $perPage = 0, $relations = [], $skipPermission = false) |
|
31 | + { |
|
32 | + /** |
|
33 | + * Fetch the report from db. |
|
34 | + */ |
|
35 | + $reportConditions = $this->constructConditions(['report_name' => $reportName], $this->model); |
|
36 | + $report = $this->model->with($relations) |
|
37 | + ->whereRaw( |
|
38 | + $reportConditions['conditionString'], |
|
39 | + $reportConditions['conditionValues'] |
|
40 | + )->first(); |
|
41 | 41 | |
42 | - /** |
|
43 | - * Check report existance and permission. |
|
44 | - */ |
|
45 | - if (! $report) { |
|
46 | - \ErrorHandler::notFound('report'); |
|
47 | - } elseif (! $skipPermission && ! \Core::users()->can($report->view_name, 'reports')) { |
|
48 | - \ErrorHandler::noPermissions(); |
|
49 | - } |
|
42 | + /** |
|
43 | + * Check report existance and permission. |
|
44 | + */ |
|
45 | + if (! $report) { |
|
46 | + \ErrorHandler::notFound('report'); |
|
47 | + } elseif (! $skipPermission && ! \Core::users()->can($report->view_name, 'reports')) { |
|
48 | + \ErrorHandler::noPermissions(); |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * Fetch data from the report based on the given conditions. |
|
53 | - */ |
|
54 | - $report = \DB::table($report->view_name); |
|
55 | - unset($conditions['page']); |
|
56 | - if (count($conditions)) { |
|
57 | - $conditions = $this->constructConditions($conditions, $this->model); |
|
58 | - $report->whereRaw($conditions['conditionString'], $conditions['conditionValues']); |
|
59 | - } |
|
60 | - /** |
|
61 | - * Paginate or all data. |
|
62 | - */ |
|
63 | - if ($perPage) { |
|
64 | - return $report->paginate($perPage); |
|
65 | - } else { |
|
66 | - return $report->get(); |
|
67 | - } |
|
68 | - } |
|
51 | + /** |
|
52 | + * Fetch data from the report based on the given conditions. |
|
53 | + */ |
|
54 | + $report = \DB::table($report->view_name); |
|
55 | + unset($conditions['page']); |
|
56 | + if (count($conditions)) { |
|
57 | + $conditions = $this->constructConditions($conditions, $this->model); |
|
58 | + $report->whereRaw($conditions['conditionString'], $conditions['conditionValues']); |
|
59 | + } |
|
60 | + /** |
|
61 | + * Paginate or all data. |
|
62 | + */ |
|
63 | + if ($perPage) { |
|
64 | + return $report->paginate($perPage); |
|
65 | + } else { |
|
66 | + return $report->get(); |
|
67 | + } |
|
68 | + } |
|
69 | 69 | } |
@@ -6,16 +6,16 @@ |
||
6 | 6 | |
7 | 7 | class NotificationsDatabaseSeeder 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(NotificationsTableSeeder::class); |
|
18 | - $this->call(PushNotificationDevicesTableSeeder::class); |
|
19 | - $this->call(AssignRelationsSeeder::class); |
|
20 | - } |
|
9 | + /** |
|
10 | + * Run the database seeds. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function run() |
|
15 | + { |
|
16 | + $this->call(ClearDataSeeder::class); |
|
17 | + $this->call(NotificationsTableSeeder::class); |
|
18 | + $this->call(PushNotificationDevicesTableSeeder::class); |
|
19 | + $this->call(AssignRelationsSeeder::class); |
|
20 | + } |
|
21 | 21 | } |
@@ -6,46 +6,46 @@ |
||
6 | 6 | |
7 | 7 | class NotificationsTableSeeder 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 | - * notifications model permissions. |
|
23 | - */ |
|
24 | - [ |
|
25 | - 'name' => 'all', |
|
26 | - 'model' => 'notification', |
|
27 | - 'created_at' => \DB::raw('NOW()'), |
|
28 | - 'updated_at' => \DB::raw('NOW()') |
|
29 | - ], |
|
30 | - [ |
|
31 | - 'name' => 'unread', |
|
32 | - 'model' => 'notification', |
|
33 | - 'created_at' => \DB::raw('NOW()'), |
|
34 | - 'updated_at' => \DB::raw('NOW()') |
|
35 | - ], |
|
36 | - [ |
|
37 | - 'name' => 'markAsRead', |
|
38 | - 'model' => 'notification', |
|
39 | - 'created_at' => \DB::raw('NOW()'), |
|
40 | - 'updated_at' => \DB::raw('NOW()') |
|
41 | - ], |
|
42 | - [ |
|
43 | - 'name' => 'markAllAsRead', |
|
44 | - 'model' => 'notification', |
|
45 | - 'created_at' => \DB::raw('NOW()'), |
|
46 | - 'updated_at' => \DB::raw('NOW()') |
|
47 | - ] |
|
48 | - ] |
|
49 | - ); |
|
50 | - } |
|
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 | + * notifications model permissions. |
|
23 | + */ |
|
24 | + [ |
|
25 | + 'name' => 'all', |
|
26 | + 'model' => 'notification', |
|
27 | + 'created_at' => \DB::raw('NOW()'), |
|
28 | + 'updated_at' => \DB::raw('NOW()') |
|
29 | + ], |
|
30 | + [ |
|
31 | + 'name' => 'unread', |
|
32 | + 'model' => 'notification', |
|
33 | + 'created_at' => \DB::raw('NOW()'), |
|
34 | + 'updated_at' => \DB::raw('NOW()') |
|
35 | + ], |
|
36 | + [ |
|
37 | + 'name' => 'markAsRead', |
|
38 | + 'model' => 'notification', |
|
39 | + 'created_at' => \DB::raw('NOW()'), |
|
40 | + 'updated_at' => \DB::raw('NOW()') |
|
41 | + ], |
|
42 | + [ |
|
43 | + 'name' => 'markAllAsRead', |
|
44 | + 'model' => 'notification', |
|
45 | + 'created_at' => \DB::raw('NOW()'), |
|
46 | + 'updated_at' => \DB::raw('NOW()') |
|
47 | + ] |
|
48 | + ] |
|
49 | + ); |
|
50 | + } |
|
51 | 51 | } |
@@ -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', ['notification', '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', ['notification', '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 | } |
@@ -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', ['notification', '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', ['notification', 'pushNotificationDevice']); |
|
17 | + \DB::table('groups_permissions')->whereIn('permission_id', $permissions->pluck('id'))->delete(); |
|
18 | + $permissions->delete(); |
|
19 | + } |
|
20 | 20 | } |
@@ -9,34 +9,34 @@ |
||
9 | 9 | |
10 | 10 | class ReportController extends BaseApiController |
11 | 11 | { |
12 | - /** |
|
13 | - * List of all route actions that the base api controller |
|
14 | - * will skip permissions check for them. |
|
15 | - * @var array |
|
16 | - */ |
|
17 | - protected $skipPermissionCheck = ['getReport']; |
|
12 | + /** |
|
13 | + * List of all route actions that the base api controller |
|
14 | + * will skip permissions check for them. |
|
15 | + * @var array |
|
16 | + */ |
|
17 | + protected $skipPermissionCheck = ['getReport']; |
|
18 | 18 | |
19 | - /** |
|
20 | - * Init new object. |
|
21 | - * |
|
22 | - * @param ReportRepository $repo |
|
23 | - * @param CoreConfig $config |
|
24 | - * @return void |
|
25 | - */ |
|
26 | - public function __construct(ReportRepository $repo, CoreConfig $config) |
|
27 | - { |
|
28 | - parent::__construct($repo, $config, 'App\Modules\Reporting\Http\Resources\Report'); |
|
29 | - } |
|
19 | + /** |
|
20 | + * Init new object. |
|
21 | + * |
|
22 | + * @param ReportRepository $repo |
|
23 | + * @param CoreConfig $config |
|
24 | + * @return void |
|
25 | + */ |
|
26 | + public function __construct(ReportRepository $repo, CoreConfig $config) |
|
27 | + { |
|
28 | + parent::__construct($repo, $config, 'App\Modules\Reporting\Http\Resources\Report'); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * Render the given report name with the given conditions. |
|
33 | - * |
|
34 | - * @param Request $request |
|
35 | - * @param string $reportName Name of the requested report |
|
36 | - * @return \Illuminate\Http\Response |
|
37 | - */ |
|
38 | - public function getReport(Request $request, $reportName) |
|
39 | - { |
|
40 | - return \Response::json($this->repo->getReport($reportName, $request->all(), $request->query('perPage')), 200); |
|
41 | - } |
|
31 | + /** |
|
32 | + * Render the given report name with the given conditions. |
|
33 | + * |
|
34 | + * @param Request $request |
|
35 | + * @param string $reportName Name of the requested report |
|
36 | + * @return \Illuminate\Http\Response |
|
37 | + */ |
|
38 | + public function getReport(Request $request, $reportName) |
|
39 | + { |
|
40 | + return \Response::json($this->repo->getReport($reportName, $request->all(), $request->query('perPage')), 200); |
|
41 | + } |
|
42 | 42 | } |