@@ -2,8 +2,8 @@ |
||
2 | 2 | |
3 | 3 | return [ |
4 | 4 | |
5 | - /** |
|
6 | - * Here goes your notification messages. |
|
7 | - */ |
|
5 | + /** |
|
6 | + * Here goes your notification messages. |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | ]; |
@@ -4,65 +4,65 @@ |
||
4 | 4 | |
5 | 5 | class MakeNotificationsCommand extends GeneratorCommand |
6 | 6 | { |
7 | - /** |
|
8 | - * The name and signature of the console command. |
|
9 | - * |
|
10 | - * @var string |
|
11 | - */ |
|
12 | - protected $signature = 'make:module:notification |
|
7 | + /** |
|
8 | + * The name and signature of the console command. |
|
9 | + * |
|
10 | + * @var string |
|
11 | + */ |
|
12 | + protected $signature = 'make:module:notification |
|
13 | 13 | {name : The name of the notification class.}'; |
14 | - /** |
|
15 | - * The console command description. |
|
16 | - * |
|
17 | - * @var string |
|
18 | - */ |
|
19 | - protected $description = 'Create a new module notification class'; |
|
20 | - /** |
|
21 | - * String to store the command type. |
|
22 | - * |
|
23 | - * @var string |
|
24 | - */ |
|
25 | - protected $type = 'Module notification'; |
|
26 | - /** |
|
27 | - * Get the stub file for the generator. |
|
28 | - * |
|
29 | - * @return string |
|
30 | - */ |
|
31 | - protected function getStub() |
|
32 | - { |
|
33 | - return __DIR__.'/stubs/notification.stub'; |
|
34 | - } |
|
35 | - /** |
|
36 | - * Get the destination class path. |
|
37 | - * |
|
38 | - * @param string $name |
|
39 | - * |
|
40 | - * @return string |
|
41 | - */ |
|
42 | - protected function getPath($name) |
|
43 | - { |
|
44 | - return module_path('notifications', 'Notifications/'.$name.'.php'); |
|
45 | - } |
|
46 | - /** |
|
47 | - * Parse the name and format according to the root namespace. |
|
48 | - * |
|
49 | - * @param string $name |
|
50 | - * |
|
51 | - * @return string |
|
52 | - */ |
|
53 | - protected function qualifyClass($name) |
|
54 | - { |
|
55 | - return $name; |
|
56 | - } |
|
57 | - /** |
|
58 | - * Replace namespace in notification stub. |
|
59 | - * |
|
60 | - * @param string $name |
|
61 | - * |
|
62 | - * @return string |
|
63 | - */ |
|
64 | - protected function getNamespace($name) |
|
65 | - { |
|
66 | - return module_class('notifications', 'Notifications'); |
|
67 | - } |
|
14 | + /** |
|
15 | + * The console command description. |
|
16 | + * |
|
17 | + * @var string |
|
18 | + */ |
|
19 | + protected $description = 'Create a new module notification class'; |
|
20 | + /** |
|
21 | + * String to store the command type. |
|
22 | + * |
|
23 | + * @var string |
|
24 | + */ |
|
25 | + protected $type = 'Module notification'; |
|
26 | + /** |
|
27 | + * Get the stub file for the generator. |
|
28 | + * |
|
29 | + * @return string |
|
30 | + */ |
|
31 | + protected function getStub() |
|
32 | + { |
|
33 | + return __DIR__.'/stubs/notification.stub'; |
|
34 | + } |
|
35 | + /** |
|
36 | + * Get the destination class path. |
|
37 | + * |
|
38 | + * @param string $name |
|
39 | + * |
|
40 | + * @return string |
|
41 | + */ |
|
42 | + protected function getPath($name) |
|
43 | + { |
|
44 | + return module_path('notifications', 'Notifications/'.$name.'.php'); |
|
45 | + } |
|
46 | + /** |
|
47 | + * Parse the name and format according to the root namespace. |
|
48 | + * |
|
49 | + * @param string $name |
|
50 | + * |
|
51 | + * @return string |
|
52 | + */ |
|
53 | + protected function qualifyClass($name) |
|
54 | + { |
|
55 | + return $name; |
|
56 | + } |
|
57 | + /** |
|
58 | + * Replace namespace in notification stub. |
|
59 | + * |
|
60 | + * @param string $name |
|
61 | + * |
|
62 | + * @return string |
|
63 | + */ |
|
64 | + protected function getNamespace($name) |
|
65 | + { |
|
66 | + return module_class('notifications', 'Notifications'); |
|
67 | + } |
|
68 | 68 | } |
@@ -6,53 +6,53 @@ |
||
6 | 6 | class NotificationObserver |
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 | } |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $factory->define(App\Modules\Reporting\Report::class, function (Faker\Generator $faker) { |
4 | - return [ |
|
5 | - 'report_name' => $faker->randomElement(['Users Count', 'Low Stock Products', 'Active Users']), |
|
6 | - 'view_name' => $faker->word(), |
|
7 | - 'created_at' => $faker->dateTimeBetween('-1 years', 'now'), |
|
8 | - 'updated_at' => $faker->dateTimeBetween('-1 years', 'now') |
|
9 | - ]; |
|
4 | + return [ |
|
5 | + 'report_name' => $faker->randomElement(['Users Count', 'Low Stock Products', 'Active Users']), |
|
6 | + 'view_name' => $faker->word(), |
|
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\Reporting\Report::class, function (Faker\Generator $faker) { |
|
3 | +$factory->define(App\Modules\Reporting\Report::class, function(Faker\Generator $faker) { |
|
4 | 4 | return [ |
5 | 5 | 'report_name' => $faker->randomElement(['Users Count', 'Low Stock Products', 'Active Users']), |
6 | 6 | 'view_name' => $faker->word(), |
@@ -5,29 +5,29 @@ |
||
5 | 5 | |
6 | 6 | class Reports extends Migration |
7 | 7 | { |
8 | - /** |
|
9 | - * Run the migrations. |
|
10 | - * |
|
11 | - * @return void |
|
12 | - */ |
|
13 | - public function up() |
|
14 | - { |
|
15 | - Schema::create('reports', function (Blueprint $table) { |
|
16 | - $table->increments('id'); |
|
17 | - $table->string('report_name', 100); |
|
18 | - $table->string('view_name', 100); |
|
19 | - $table->softDeletes(); |
|
20 | - $table->timestamps(); |
|
21 | - }); |
|
22 | - } |
|
8 | + /** |
|
9 | + * Run the migrations. |
|
10 | + * |
|
11 | + * @return void |
|
12 | + */ |
|
13 | + public function up() |
|
14 | + { |
|
15 | + Schema::create('reports', function (Blueprint $table) { |
|
16 | + $table->increments('id'); |
|
17 | + $table->string('report_name', 100); |
|
18 | + $table->string('view_name', 100); |
|
19 | + $table->softDeletes(); |
|
20 | + $table->timestamps(); |
|
21 | + }); |
|
22 | + } |
|
23 | 23 | |
24 | - /** |
|
25 | - * Reverse the migrations. |
|
26 | - * |
|
27 | - * @return void |
|
28 | - */ |
|
29 | - public function down() |
|
30 | - { |
|
31 | - Schema::dropIfExists('reports'); |
|
32 | - } |
|
24 | + /** |
|
25 | + * Reverse the migrations. |
|
26 | + * |
|
27 | + * @return void |
|
28 | + */ |
|
29 | + public function down() |
|
30 | + { |
|
31 | + Schema::dropIfExists('reports'); |
|
32 | + } |
|
33 | 33 | } |
@@ -12,7 +12,7 @@ |
||
12 | 12 | */ |
13 | 13 | public function up() |
14 | 14 | { |
15 | - Schema::create('reports', function (Blueprint $table) { |
|
15 | + Schema::create('reports', function(Blueprint $table) { |
|
16 | 16 | $table->increments('id'); |
17 | 17 | $table->string('report_name', 100); |
18 | 18 | $table->string('view_name', 100); |
@@ -6,15 +6,15 @@ |
||
6 | 6 | |
7 | 7 | class ReportingDatabaseSeeder 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(ReportsTableSeeder::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(ReportsTableSeeder::class); |
|
18 | + $this->call(AssignRelationsSeeder::class); |
|
19 | + } |
|
20 | 20 | } |
@@ -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 | } |
@@ -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 | } |
@@ -42,9 +42,9 @@ |
||
42 | 42 | /** |
43 | 43 | * Check report existance and permission. |
44 | 44 | */ |
45 | - if (! $report) { |
|
45 | + if ( ! $report) { |
|
46 | 46 | \ErrorHandler::notFound('report'); |
47 | - } elseif (! $skipPermission && ! \Core::users()->can($report->view_name, 'reports')) { |
|
47 | + } elseif ( ! $skipPermission && ! \Core::users()->can($report->view_name, 'reports')) { |
|
48 | 48 | \ErrorHandler::noPermissions(); |
49 | 49 | } |
50 | 50 |
@@ -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 | } |