@@ -6,27 +6,27 @@ |
||
6 | 6 | |
7 | 7 | class ModuleServiceProvider extends ServiceProvider |
8 | 8 | { |
9 | - /** |
|
10 | - * Bootstrap the module services. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function boot() |
|
15 | - { |
|
16 | - $this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'reporting'); |
|
17 | - $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'reporting'); |
|
9 | + /** |
|
10 | + * Bootstrap the module services. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function boot() |
|
15 | + { |
|
16 | + $this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'reporting'); |
|
17 | + $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'reporting'); |
|
18 | 18 | |
19 | - $factory = app('Illuminate\Database\Eloquent\Factory'); |
|
20 | - $factory->load(__DIR__.'/../Database/Factories'); |
|
21 | - } |
|
19 | + $factory = app('Illuminate\Database\Eloquent\Factory'); |
|
20 | + $factory->load(__DIR__.'/../Database/Factories'); |
|
21 | + } |
|
22 | 22 | |
23 | - /** |
|
24 | - * Register the module services. |
|
25 | - * |
|
26 | - * @return void |
|
27 | - */ |
|
28 | - public function register() |
|
29 | - { |
|
30 | - $this->app->register(RouteServiceProvider::class); |
|
31 | - } |
|
23 | + /** |
|
24 | + * Register the module services. |
|
25 | + * |
|
26 | + * @return void |
|
27 | + */ |
|
28 | + public function register() |
|
29 | + { |
|
30 | + $this->app->register(RouteServiceProvider::class); |
|
31 | + } |
|
32 | 32 | } |
@@ -7,73 +7,73 @@ |
||
7 | 7 | |
8 | 8 | class RouteServiceProvider extends ServiceProvider |
9 | 9 | { |
10 | - /** |
|
11 | - * This namespace is applied to your controller routes. |
|
12 | - * |
|
13 | - * In addition, it is set as the URL generator's root namespace. |
|
14 | - * |
|
15 | - * @var string |
|
16 | - */ |
|
17 | - protected $namespace = 'App\Modules\Reporting\Http\Controllers'; |
|
10 | + /** |
|
11 | + * This namespace is applied to your controller routes. |
|
12 | + * |
|
13 | + * In addition, it is set as the URL generator's root namespace. |
|
14 | + * |
|
15 | + * @var string |
|
16 | + */ |
|
17 | + protected $namespace = 'App\Modules\Reporting\Http\Controllers'; |
|
18 | 18 | |
19 | - /** |
|
20 | - * Define your route model bindings, pattern filters, etc. |
|
21 | - * |
|
22 | - * @return void |
|
23 | - */ |
|
24 | - public function boot() |
|
25 | - { |
|
26 | - // |
|
19 | + /** |
|
20 | + * Define your route model bindings, pattern filters, etc. |
|
21 | + * |
|
22 | + * @return void |
|
23 | + */ |
|
24 | + public function boot() |
|
25 | + { |
|
26 | + // |
|
27 | 27 | |
28 | - parent::boot(); |
|
29 | - } |
|
28 | + parent::boot(); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * Define the routes for the module. |
|
33 | - * |
|
34 | - * @return void |
|
35 | - */ |
|
36 | - public function map() |
|
37 | - { |
|
38 | - $this->mapWebRoutes(); |
|
31 | + /** |
|
32 | + * Define the routes for the module. |
|
33 | + * |
|
34 | + * @return void |
|
35 | + */ |
|
36 | + public function map() |
|
37 | + { |
|
38 | + $this->mapWebRoutes(); |
|
39 | 39 | |
40 | - $this->mapApiRoutes(); |
|
40 | + $this->mapApiRoutes(); |
|
41 | 41 | |
42 | - // |
|
43 | - } |
|
42 | + // |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * Define the "web" routes for the module. |
|
47 | - * |
|
48 | - * These routes all receive session state, CSRF protection, etc. |
|
49 | - * |
|
50 | - * @return void |
|
51 | - */ |
|
52 | - protected function mapWebRoutes() |
|
53 | - { |
|
54 | - Route::group([ |
|
55 | - 'middleware' => 'web', |
|
56 | - 'namespace' => $this->namespace, |
|
57 | - ], function ($router) { |
|
58 | - require module_path('reporting', 'Routes/web.php'); |
|
59 | - }); |
|
60 | - } |
|
45 | + /** |
|
46 | + * Define the "web" routes for the module. |
|
47 | + * |
|
48 | + * These routes all receive session state, CSRF protection, etc. |
|
49 | + * |
|
50 | + * @return void |
|
51 | + */ |
|
52 | + protected function mapWebRoutes() |
|
53 | + { |
|
54 | + Route::group([ |
|
55 | + 'middleware' => 'web', |
|
56 | + 'namespace' => $this->namespace, |
|
57 | + ], function ($router) { |
|
58 | + require module_path('reporting', 'Routes/web.php'); |
|
59 | + }); |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * Define the "api" routes for the module. |
|
64 | - * |
|
65 | - * These routes are typically stateless. |
|
66 | - * |
|
67 | - * @return void |
|
68 | - */ |
|
69 | - protected function mapApiRoutes() |
|
70 | - { |
|
71 | - Route::group([ |
|
72 | - 'middleware' => 'api', |
|
73 | - 'namespace' => $this->namespace, |
|
74 | - 'prefix' => 'api', |
|
75 | - ], function ($router) { |
|
76 | - require module_path('reporting', 'Routes/api.php'); |
|
77 | - }); |
|
78 | - } |
|
62 | + /** |
|
63 | + * Define the "api" routes for the module. |
|
64 | + * |
|
65 | + * These routes are typically stateless. |
|
66 | + * |
|
67 | + * @return void |
|
68 | + */ |
|
69 | + protected function mapApiRoutes() |
|
70 | + { |
|
71 | + Route::group([ |
|
72 | + 'middleware' => 'api', |
|
73 | + 'namespace' => $this->namespace, |
|
74 | + 'prefix' => 'api', |
|
75 | + ], function ($router) { |
|
76 | + require module_path('reporting', 'Routes/api.php'); |
|
77 | + }); |
|
78 | + } |
|
79 | 79 | } |
@@ -6,32 +6,32 @@ |
||
6 | 6 | class Report extends Model |
7 | 7 | { |
8 | 8 | |
9 | - use SoftDeletes; |
|
10 | - protected $table = 'reports'; |
|
11 | - protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
12 | - protected $hidden = ['deleted_at']; |
|
13 | - protected $guarded = ['id']; |
|
14 | - protected $fillable = ['report_name', 'view_name']; |
|
15 | - public $searchable = ['report_name', 'view_name']; |
|
9 | + use SoftDeletes; |
|
10 | + protected $table = 'reports'; |
|
11 | + protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
12 | + protected $hidden = ['deleted_at']; |
|
13 | + protected $guarded = ['id']; |
|
14 | + protected $fillable = ['report_name', 'view_name']; |
|
15 | + public $searchable = ['report_name', 'view_name']; |
|
16 | 16 | |
17 | - public function getCreatedAtAttribute($value) |
|
18 | - { |
|
19 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
20 | - } |
|
17 | + public function getCreatedAtAttribute($value) |
|
18 | + { |
|
19 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
20 | + } |
|
21 | 21 | |
22 | - public function getUpdatedAtAttribute($value) |
|
23 | - { |
|
24 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
25 | - } |
|
22 | + public function getUpdatedAtAttribute($value) |
|
23 | + { |
|
24 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
25 | + } |
|
26 | 26 | |
27 | - public function getDeletedAtAttribute($value) |
|
28 | - { |
|
29 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
30 | - } |
|
27 | + public function getDeletedAtAttribute($value) |
|
28 | + { |
|
29 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
30 | + } |
|
31 | 31 | |
32 | - public static function boot() |
|
33 | - { |
|
34 | - parent::boot(); |
|
35 | - Report::observe(\App::make('App\Modules\Reporting\ModelObservers\ReprotObserver')); |
|
36 | - } |
|
32 | + public static function boot() |
|
33 | + { |
|
34 | + parent::boot(); |
|
35 | + Report::observe(\App::make('App\Modules\Reporting\ModelObservers\ReprotObserver')); |
|
36 | + } |
|
37 | 37 | } |
@@ -13,15 +13,15 @@ |
||
13 | 13 | |
14 | 14 | Route::group(['prefix' => 'reporting'], function () { |
15 | 15 | |
16 | - Route::group(['prefix' => 'reports'], function () { |
|
16 | + Route::group(['prefix' => 'reports'], function () { |
|
17 | 17 | |
18 | - Route::get('list/{sortBy?}/{desc?}', 'ReportsController@index'); |
|
19 | - Route::get('find/{id}', 'ReportsController@find'); |
|
20 | - Route::get('search/{query?}/{perPage?}/{sortBy?}/{desc?}', 'ReportsController@search'); |
|
21 | - Route::get('paginate/{perPage?}/{sortBy?}/{desc?}', 'ReportsController@paginate'); |
|
22 | - Route::post('first', 'ReportsController@first'); |
|
23 | - Route::post('findby/{sortBy?}/{desc?}', 'ReportsController@findby'); |
|
24 | - Route::post('paginateby/{perPage?}/{sortBy?}/{desc?}', 'ReportsController@paginateby'); |
|
25 | - Route::post('get/{reportName}/{perPage?}', 'ReportsController@getReport'); |
|
26 | - }); |
|
18 | + Route::get('list/{sortBy?}/{desc?}', 'ReportsController@index'); |
|
19 | + Route::get('find/{id}', 'ReportsController@find'); |
|
20 | + Route::get('search/{query?}/{perPage?}/{sortBy?}/{desc?}', 'ReportsController@search'); |
|
21 | + Route::get('paginate/{perPage?}/{sortBy?}/{desc?}', 'ReportsController@paginate'); |
|
22 | + Route::post('first', 'ReportsController@first'); |
|
23 | + Route::post('findby/{sortBy?}/{desc?}', 'ReportsController@findby'); |
|
24 | + Route::post('paginateby/{perPage?}/{sortBy?}/{desc?}', 'ReportsController@paginateby'); |
|
25 | + Route::post('get/{reportName}/{perPage?}', 'ReportsController@getReport'); |
|
26 | + }); |
|
27 | 27 | }); |
@@ -6,53 +6,53 @@ |
||
6 | 6 | class ReprotObserver |
7 | 7 | { |
8 | 8 | |
9 | - public function saving($model) |
|
10 | - { |
|
11 | - // |
|
12 | - } |
|
13 | - |
|
14 | - public function saved($model) |
|
15 | - { |
|
16 | - // |
|
17 | - } |
|
18 | - |
|
19 | - public function creating($model) |
|
20 | - { |
|
21 | - // |
|
22 | - } |
|
23 | - |
|
24 | - public function created($model) |
|
25 | - { |
|
26 | - // |
|
27 | - } |
|
28 | - |
|
29 | - public function updating($model) |
|
30 | - { |
|
31 | - // |
|
32 | - } |
|
33 | - |
|
34 | - public function updated($model) |
|
35 | - { |
|
36 | - // |
|
37 | - } |
|
38 | - |
|
39 | - public function deleting($model) |
|
40 | - { |
|
41 | - // |
|
42 | - } |
|
43 | - |
|
44 | - public function deleted($model) |
|
45 | - { |
|
46 | - // |
|
47 | - } |
|
48 | - |
|
49 | - public function restoring($model) |
|
50 | - { |
|
51 | - // |
|
52 | - } |
|
53 | - |
|
54 | - public function restored($model) |
|
55 | - { |
|
56 | - // |
|
57 | - } |
|
9 | + public function saving($model) |
|
10 | + { |
|
11 | + // |
|
12 | + } |
|
13 | + |
|
14 | + public function saved($model) |
|
15 | + { |
|
16 | + // |
|
17 | + } |
|
18 | + |
|
19 | + public function creating($model) |
|
20 | + { |
|
21 | + // |
|
22 | + } |
|
23 | + |
|
24 | + public function created($model) |
|
25 | + { |
|
26 | + // |
|
27 | + } |
|
28 | + |
|
29 | + public function updating($model) |
|
30 | + { |
|
31 | + // |
|
32 | + } |
|
33 | + |
|
34 | + public function updated($model) |
|
35 | + { |
|
36 | + // |
|
37 | + } |
|
38 | + |
|
39 | + public function deleting($model) |
|
40 | + { |
|
41 | + // |
|
42 | + } |
|
43 | + |
|
44 | + public function deleted($model) |
|
45 | + { |
|
46 | + // |
|
47 | + } |
|
48 | + |
|
49 | + public function restoring($model) |
|
50 | + { |
|
51 | + // |
|
52 | + } |
|
53 | + |
|
54 | + public function restored($model) |
|
55 | + { |
|
56 | + // |
|
57 | + } |
|
58 | 58 | } |
@@ -4,66 +4,66 @@ |
||
4 | 4 | |
5 | 5 | class ReportRepository extends AbstractRepository |
6 | 6 | { |
7 | - /** |
|
8 | - * Return the model full namespace. |
|
9 | - * |
|
10 | - * @return string |
|
11 | - */ |
|
12 | - protected function getModel() |
|
13 | - { |
|
14 | - return 'App\Modules\Reporting\Report'; |
|
15 | - } |
|
7 | + /** |
|
8 | + * Return the model full namespace. |
|
9 | + * |
|
10 | + * @return string |
|
11 | + */ |
|
12 | + protected function getModel() |
|
13 | + { |
|
14 | + return 'App\Modules\Reporting\Report'; |
|
15 | + } |
|
16 | 16 | |
17 | - /** |
|
18 | - * Render the given report db view based on the given |
|
19 | - * condition. |
|
20 | - * |
|
21 | - * @param string $reportName |
|
22 | - * @param array $conditions |
|
23 | - * @param integer $perPage |
|
24 | - * @param array $relations |
|
25 | - * @param boolean $skipPermission |
|
26 | - * @return object |
|
27 | - */ |
|
28 | - public function getReport($reportName, $conditions = [], $perPage = 0, $relations = [], $skipPermission = false) |
|
29 | - { |
|
30 | - /** |
|
31 | - * Fetch the report from db. |
|
32 | - */ |
|
33 | - $reportConditions = $this->constructConditions(['report_name' => $reportName], $this->model); |
|
34 | - $report = call_user_func_array( |
|
35 | - "{$this->getModel()}::with", |
|
36 | - array($relations) |
|
37 | - )->whereRaw( |
|
38 | - $reportConditions['conditionString'], |
|
39 | - $reportConditions['conditionValues'] |
|
40 | - )->first(); |
|
17 | + /** |
|
18 | + * Render the given report db view based on the given |
|
19 | + * condition. |
|
20 | + * |
|
21 | + * @param string $reportName |
|
22 | + * @param array $conditions |
|
23 | + * @param integer $perPage |
|
24 | + * @param array $relations |
|
25 | + * @param boolean $skipPermission |
|
26 | + * @return object |
|
27 | + */ |
|
28 | + public function getReport($reportName, $conditions = [], $perPage = 0, $relations = [], $skipPermission = false) |
|
29 | + { |
|
30 | + /** |
|
31 | + * Fetch the report from db. |
|
32 | + */ |
|
33 | + $reportConditions = $this->constructConditions(['report_name' => $reportName], $this->model); |
|
34 | + $report = call_user_func_array( |
|
35 | + "{$this->getModel()}::with", |
|
36 | + array($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 | } |
@@ -1,9 +1,9 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $factory->define(App\Modules\Acl\AclGroup::class, function (Faker\Generator $faker) { |
4 | - return [ |
|
5 | - 'name' => $faker->unique->word(), |
|
6 | - 'created_at' => $faker->dateTimeBetween('-1 years', 'now'), |
|
7 | - 'updated_at' => $faker->dateTimeBetween('-1 years', 'now') |
|
8 | - ]; |
|
4 | + return [ |
|
5 | + 'name' => $faker->unique->word(), |
|
6 | + 'created_at' => $faker->dateTimeBetween('-1 years', 'now'), |
|
7 | + 'updated_at' => $faker->dateTimeBetween('-1 years', 'now') |
|
8 | + ]; |
|
9 | 9 | }); |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $factory->define(App\Modules\Acl\AclPermission::class, function (Faker\Generator $faker) { |
4 | - return [ |
|
5 | - 'name' => $faker->randomElement(['save', 'delete', 'find', 'paginate']), |
|
6 | - 'model' => $faker->randomElement(['users', 'groups', 'settings', 'notifications']), |
|
7 | - 'created_at' => $faker->dateTimeBetween('-1 years', 'now'), |
|
8 | - 'updated_at' => $faker->dateTimeBetween('-1 years', 'now') |
|
9 | - ]; |
|
4 | + return [ |
|
5 | + 'name' => $faker->randomElement(['save', 'delete', 'find', 'paginate']), |
|
6 | + 'model' => $faker->randomElement(['users', 'groups', 'settings', 'notifications']), |
|
7 | + 'created_at' => $faker->dateTimeBetween('-1 years', 'now'), |
|
8 | + 'updated_at' => $faker->dateTimeBetween('-1 years', 'now') |
|
9 | + ]; |
|
10 | 10 | }); |
@@ -1,15 +1,15 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $factory->define(App\Modules\Acl\OauthClient::class, function (Faker\Generator $faker) { |
4 | - return [ |
|
5 | - 'user_id' => $faker->randomDigit(), |
|
6 | - 'name' => $faker->name(), |
|
7 | - 'secret' => \Illuminate\Support\Str::random(40), |
|
8 | - 'redirect' => $faker->url(), |
|
9 | - 'personal_access_client' => 0, |
|
10 | - 'password_client' => 0, |
|
11 | - 'revoked' => $faker->boolean(), |
|
12 | - 'created_at' => $faker->dateTimeBetween('-1 years', 'now'), |
|
13 | - 'updated_at' => $faker->dateTimeBetween('-1 years', 'now') |
|
14 | - ]; |
|
4 | + return [ |
|
5 | + 'user_id' => $faker->randomDigit(), |
|
6 | + 'name' => $faker->name(), |
|
7 | + 'secret' => \Illuminate\Support\Str::random(40), |
|
8 | + 'redirect' => $faker->url(), |
|
9 | + 'personal_access_client' => 0, |
|
10 | + 'password_client' => 0, |
|
11 | + 'revoked' => $faker->boolean(), |
|
12 | + 'created_at' => $faker->dateTimeBetween('-1 years', 'now'), |
|
13 | + 'updated_at' => $faker->dateTimeBetween('-1 years', 'now') |
|
14 | + ]; |
|
15 | 15 | }); |