@@ -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', ['DummyModelName']); |
|
17 | - \DB::table('permission_role')->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', ['DummyModelName']); |
|
17 | + \DB::table('permission_role')->whereIn('permission_id', $permissions->pluck('id'))->delete(); |
|
18 | + $permissions->delete(); |
|
19 | + } |
|
20 | 20 | } |
@@ -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 | - $adminRoleId = \DB::table('roles')->where('name', 'admin')->select('id')->first()->id; |
|
9 | + /** |
|
10 | + * Run the database seeds. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function run() |
|
15 | + { |
|
16 | + $adminRoleId = \DB::table('roles')->where('name', 'admin')->select('id')->first()->id; |
|
17 | 17 | |
18 | - /** |
|
19 | - * Assign the permissions to the admin role. |
|
20 | - */ |
|
21 | - \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['setting'])->each(function ($permission) use ($adminRoleId) { |
|
22 | - \DB::table('permission_role')->insert( |
|
23 | - [ |
|
24 | - 'permission_id' => $permission->id, |
|
25 | - 'role_id' => $adminRoleId, |
|
26 | - 'created_at' => \DB::raw('NOW()'), |
|
27 | - 'updated_at' => \DB::raw('NOW()') |
|
28 | - ] |
|
29 | - ); |
|
30 | - }); |
|
31 | - } |
|
18 | + /** |
|
19 | + * Assign the permissions to the admin role. |
|
20 | + */ |
|
21 | + \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['setting'])->each(function ($permission) use ($adminRoleId) { |
|
22 | + \DB::table('permission_role')->insert( |
|
23 | + [ |
|
24 | + 'permission_id' => $permission->id, |
|
25 | + 'role_id' => $adminRoleId, |
|
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', ['setting']); |
|
17 | - \DB::table('permission_role')->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', ['setting']); |
|
17 | + \DB::table('permission_role')->whereIn('permission_id', $permissions->pluck('id'))->delete(); |
|
18 | + $permissions->delete(); |
|
19 | + } |
|
20 | 20 | } |
@@ -8,89 +8,89 @@ |
||
8 | 8 | |
9 | 9 | class BaseApiController extends Controller |
10 | 10 | { |
11 | - /** |
|
12 | - * Array of eager loaded relations. |
|
13 | - * |
|
14 | - * @var array |
|
15 | - */ |
|
16 | - protected $relations; |
|
11 | + /** |
|
12 | + * Array of eager loaded relations. |
|
13 | + * |
|
14 | + * @var array |
|
15 | + */ |
|
16 | + protected $relations; |
|
17 | 17 | |
18 | - /** |
|
19 | - * @var object |
|
20 | - */ |
|
21 | - protected $service; |
|
18 | + /** |
|
19 | + * @var object |
|
20 | + */ |
|
21 | + protected $service; |
|
22 | 22 | |
23 | - /** |
|
24 | - * Path of the model resource. |
|
25 | - * |
|
26 | - * @var string |
|
27 | - */ |
|
28 | - protected $modelResource; |
|
23 | + /** |
|
24 | + * Path of the model resource. |
|
25 | + * |
|
26 | + * @var string |
|
27 | + */ |
|
28 | + protected $modelResource; |
|
29 | 29 | |
30 | - /** |
|
31 | - * Init new object. |
|
32 | - * |
|
33 | - * @param mixed $service |
|
34 | - * @return void |
|
35 | - */ |
|
36 | - public function __construct($service) |
|
37 | - { |
|
38 | - $this->service = $service; |
|
39 | - } |
|
30 | + /** |
|
31 | + * Init new object. |
|
32 | + * |
|
33 | + * @param mixed $service |
|
34 | + * @return void |
|
35 | + */ |
|
36 | + public function __construct($service) |
|
37 | + { |
|
38 | + $this->service = $service; |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * Fetch all records with relations from storage. |
|
43 | - * |
|
44 | - * @param Request $request |
|
45 | - * @return \Illuminate\Http\Response |
|
46 | - */ |
|
47 | - public function index(Request $request) |
|
48 | - { |
|
49 | - return $this->modelResource::collection($this->service->list($request->relations, $request->query(), $request->query('perPage'), $request->query('sortBy'), $request->query('desc'))); |
|
50 | - } |
|
41 | + /** |
|
42 | + * Fetch all records with relations from storage. |
|
43 | + * |
|
44 | + * @param Request $request |
|
45 | + * @return \Illuminate\Http\Response |
|
46 | + */ |
|
47 | + public function index(Request $request) |
|
48 | + { |
|
49 | + return $this->modelResource::collection($this->service->list($request->relations, $request->query(), $request->query('perPage'), $request->query('sortBy'), $request->query('desc'))); |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Fetch the single object with relations from storage. |
|
54 | - * |
|
55 | - * @param Request $request |
|
56 | - * @param integer $id Id of the requested model. |
|
57 | - * @return \Illuminate\Http\Response |
|
58 | - */ |
|
59 | - public function find(Request $request, $id) |
|
60 | - { |
|
61 | - return new $this->modelResource($this->service->find($id, $request->relations)); |
|
62 | - } |
|
52 | + /** |
|
53 | + * Fetch the single object with relations from storage. |
|
54 | + * |
|
55 | + * @param Request $request |
|
56 | + * @param integer $id Id of the requested model. |
|
57 | + * @return \Illuminate\Http\Response |
|
58 | + */ |
|
59 | + public function find(Request $request, $id) |
|
60 | + { |
|
61 | + return new $this->modelResource($this->service->find($id, $request->relations)); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * Delete by the given id from storage. |
|
66 | - * |
|
67 | - * @param integer $id Id of the deleted model. |
|
68 | - * @return \Illuminate\Http\Response |
|
69 | - */ |
|
70 | - public function delete($id) |
|
71 | - { |
|
72 | - return new GeneralResource($this->service->delete($id)); |
|
73 | - } |
|
64 | + /** |
|
65 | + * Delete by the given id from storage. |
|
66 | + * |
|
67 | + * @param integer $id Id of the deleted model. |
|
68 | + * @return \Illuminate\Http\Response |
|
69 | + */ |
|
70 | + public function delete($id) |
|
71 | + { |
|
72 | + return new GeneralResource($this->service->delete($id)); |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * Return the deleted models in pages based on the given conditions. |
|
77 | - * |
|
78 | - * @param Request $request |
|
79 | - * @return \Illuminate\Http\Response |
|
80 | - */ |
|
81 | - public function deleted(Request $request) |
|
82 | - { |
|
83 | - return $this->modelResource::collection($this->service->deleted($request->all(), $request->query('perPage'), $request->query('sortBy'), $request->query('desc'))); |
|
84 | - } |
|
75 | + /** |
|
76 | + * Return the deleted models in pages based on the given conditions. |
|
77 | + * |
|
78 | + * @param Request $request |
|
79 | + * @return \Illuminate\Http\Response |
|
80 | + */ |
|
81 | + public function deleted(Request $request) |
|
82 | + { |
|
83 | + return $this->modelResource::collection($this->service->deleted($request->all(), $request->query('perPage'), $request->query('sortBy'), $request->query('desc'))); |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * Restore the deleted model. |
|
88 | - * |
|
89 | - * @param integer $id Id of the restored model. |
|
90 | - * @return \Illuminate\Http\Response |
|
91 | - */ |
|
92 | - public function restore($id) |
|
93 | - { |
|
94 | - return new GeneralResource($this->service->restore($id)); |
|
95 | - } |
|
86 | + /** |
|
87 | + * Restore the deleted model. |
|
88 | + * |
|
89 | + * @param integer $id Id of the restored model. |
|
90 | + * @return \Illuminate\Http\Response |
|
91 | + */ |
|
92 | + public function restore($id) |
|
93 | + { |
|
94 | + return new GeneralResource($this->service->restore($id)); |
|
95 | + } |
|
96 | 96 | } |
@@ -10,43 +10,43 @@ |
||
10 | 10 | |
11 | 11 | class SettingController extends BaseApiController |
12 | 12 | { |
13 | - /** |
|
14 | - * Path of the model resource |
|
15 | - * |
|
16 | - * @var string |
|
17 | - */ |
|
18 | - protected $modelResource = 'App\Modules\Core\Http\Resources\Setting'; |
|
13 | + /** |
|
14 | + * Path of the model resource |
|
15 | + * |
|
16 | + * @var string |
|
17 | + */ |
|
18 | + protected $modelResource = 'App\Modules\Core\Http\Resources\Setting'; |
|
19 | 19 | |
20 | - /** |
|
21 | - * Init new object. |
|
22 | - * |
|
23 | - * @param SettingService $service |
|
24 | - * @return void |
|
25 | - */ |
|
26 | - public function __construct(SettingService $service) |
|
27 | - { |
|
28 | - parent::__construct($service); |
|
29 | - } |
|
20 | + /** |
|
21 | + * Init new object. |
|
22 | + * |
|
23 | + * @param SettingService $service |
|
24 | + * @return void |
|
25 | + */ |
|
26 | + public function __construct(SettingService $service) |
|
27 | + { |
|
28 | + parent::__construct($service); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * Update the given model to storage. |
|
33 | - * |
|
34 | - * @param UpdateSetting $request |
|
35 | - * @return \Illuminate\Http\Response |
|
36 | - */ |
|
37 | - public function update(UpdateSetting $request) |
|
38 | - { |
|
39 | - return new $this->modelResource($this->service->save($request->all())); |
|
40 | - } |
|
31 | + /** |
|
32 | + * Update the given model to storage. |
|
33 | + * |
|
34 | + * @param UpdateSetting $request |
|
35 | + * @return \Illuminate\Http\Response |
|
36 | + */ |
|
37 | + public function update(UpdateSetting $request) |
|
38 | + { |
|
39 | + return new $this->modelResource($this->service->save($request->all())); |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * Save list of settings. |
|
44 | - * |
|
45 | - * @param Request $request |
|
46 | - * @return \Illuminate\Http\Response |
|
47 | - */ |
|
48 | - public function saveMany(Request $request) |
|
49 | - { |
|
50 | - return new GeneralResource($this->service->saveMany($request->all())); |
|
51 | - } |
|
42 | + /** |
|
43 | + * Save list of settings. |
|
44 | + * |
|
45 | + * @param Request $request |
|
46 | + * @return \Illuminate\Http\Response |
|
47 | + */ |
|
48 | + public function saveMany(Request $request) |
|
49 | + { |
|
50 | + return new GeneralResource($this->service->saveMany($request->all())); |
|
51 | + } |
|
52 | 52 | } |
@@ -6,96 +6,96 @@ |
||
6 | 6 | |
7 | 7 | class ApiDocumentController extends Controller |
8 | 8 | { |
9 | - /** |
|
10 | - * @var ReprotService |
|
11 | - */ |
|
12 | - protected $reportService; |
|
9 | + /** |
|
10 | + * @var ReprotService |
|
11 | + */ |
|
12 | + protected $reportService; |
|
13 | 13 | |
14 | - /** |
|
15 | - * Init new object. |
|
16 | - * |
|
17 | - * @return void |
|
18 | - */ |
|
19 | - public function __construct(ReportService $reportService) |
|
20 | - { |
|
21 | - $this->reportService = $reportService; |
|
22 | - } |
|
14 | + /** |
|
15 | + * Init new object. |
|
16 | + * |
|
17 | + * @return void |
|
18 | + */ |
|
19 | + public function __construct(ReportService $reportService) |
|
20 | + { |
|
21 | + $this->reportService = $reportService; |
|
22 | + } |
|
23 | 23 | |
24 | - public function index() |
|
25 | - { |
|
26 | - $jsonDoc = json_decode(file_get_contents(app_path('Modules/Core/Resources/api.json')), true); |
|
27 | - $modules = $jsonDoc['modules']; |
|
28 | - $reports = $jsonDoc['reports']; |
|
29 | - $errors = $jsonDoc['errors']; |
|
30 | - $models = $jsonDoc['models']; |
|
31 | - $conditions = [ |
|
32 | - [ |
|
33 | - 'title' => 'email equal [email protected]:', |
|
34 | - 'content' => ['email' => '[email protected]'] |
|
35 | - ], |
|
36 | - [ |
|
37 | - 'title' => 'email equal [email protected] and user is blocked:', |
|
38 | - 'content' => ['and' => ['email' => '[email protected]', 'blocked' => 1]] |
|
39 | - ], |
|
40 | - [ |
|
41 | - 'title' => 'email equal [email protected] or user is blocked:', |
|
42 | - 'content' => ['or' => ['email' => '[email protected]', 'blocked' => 1]] |
|
43 | - ], |
|
44 | - [ |
|
45 | - 'title' => 'email contain John:', |
|
46 | - 'content' => ['email' => ['op' => 'like', 'val' => '%John%']] |
|
47 | - ], |
|
48 | - [ |
|
49 | - 'title' => 'user created after 2016-10-25:', |
|
50 | - 'content' => ['created_at' => ['op' => '>', 'val' => '2016-10-25']] |
|
51 | - ], |
|
52 | - [ |
|
53 | - 'title' => 'user created between 2016-10-20 and 2016-10-25:', |
|
54 | - 'content' => ['created_at' => ['op' => 'between', 'val1' => '2016-10-20', 'val2' => '2016-10-25']] |
|
55 | - ], |
|
56 | - [ |
|
57 | - 'title' => 'user id in 1,2,3:', |
|
58 | - 'content' => ['id' => ['op' => 'in', 'val' => [1, 2, 3]]] |
|
59 | - ], |
|
60 | - [ |
|
61 | - 'title' => 'user name is null:', |
|
62 | - 'content' => ['name' => ['op' => 'null']] |
|
63 | - ], |
|
64 | - [ |
|
65 | - 'title' => 'user name is not null:', |
|
66 | - 'content' => ['name' => ['op' => 'not null']] |
|
67 | - ], |
|
68 | - [ |
|
69 | - 'title' => 'user has role admin:', |
|
70 | - 'content' => ['roles' => ['op' => 'has', 'val' => ['name' => 'Admin']]] |
|
71 | - ] |
|
72 | - ]; |
|
24 | + public function index() |
|
25 | + { |
|
26 | + $jsonDoc = json_decode(file_get_contents(app_path('Modules/Core/Resources/api.json')), true); |
|
27 | + $modules = $jsonDoc['modules']; |
|
28 | + $reports = $jsonDoc['reports']; |
|
29 | + $errors = $jsonDoc['errors']; |
|
30 | + $models = $jsonDoc['models']; |
|
31 | + $conditions = [ |
|
32 | + [ |
|
33 | + 'title' => 'email equal [email protected]:', |
|
34 | + 'content' => ['email' => '[email protected]'] |
|
35 | + ], |
|
36 | + [ |
|
37 | + 'title' => 'email equal [email protected] and user is blocked:', |
|
38 | + 'content' => ['and' => ['email' => '[email protected]', 'blocked' => 1]] |
|
39 | + ], |
|
40 | + [ |
|
41 | + 'title' => 'email equal [email protected] or user is blocked:', |
|
42 | + 'content' => ['or' => ['email' => '[email protected]', 'blocked' => 1]] |
|
43 | + ], |
|
44 | + [ |
|
45 | + 'title' => 'email contain John:', |
|
46 | + 'content' => ['email' => ['op' => 'like', 'val' => '%John%']] |
|
47 | + ], |
|
48 | + [ |
|
49 | + 'title' => 'user created after 2016-10-25:', |
|
50 | + 'content' => ['created_at' => ['op' => '>', 'val' => '2016-10-25']] |
|
51 | + ], |
|
52 | + [ |
|
53 | + 'title' => 'user created between 2016-10-20 and 2016-10-25:', |
|
54 | + 'content' => ['created_at' => ['op' => 'between', 'val1' => '2016-10-20', 'val2' => '2016-10-25']] |
|
55 | + ], |
|
56 | + [ |
|
57 | + 'title' => 'user id in 1,2,3:', |
|
58 | + 'content' => ['id' => ['op' => 'in', 'val' => [1, 2, 3]]] |
|
59 | + ], |
|
60 | + [ |
|
61 | + 'title' => 'user name is null:', |
|
62 | + 'content' => ['name' => ['op' => 'null']] |
|
63 | + ], |
|
64 | + [ |
|
65 | + 'title' => 'user name is not null:', |
|
66 | + 'content' => ['name' => ['op' => 'not null']] |
|
67 | + ], |
|
68 | + [ |
|
69 | + 'title' => 'user has role admin:', |
|
70 | + 'content' => ['roles' => ['op' => 'has', 'val' => ['name' => 'Admin']]] |
|
71 | + ] |
|
72 | + ]; |
|
73 | 73 | |
74 | - $paginateObject = [ |
|
75 | - 'data' => ['Array of model objects'], |
|
76 | - "links" => [ |
|
77 | - "first" => "apiUrl?page=1", |
|
78 | - "last" => "apiUrl?page=3", |
|
79 | - "prev" => "apiUrl?page=2", |
|
80 | - "next" => "apiUrl?page=3" |
|
81 | - ], |
|
82 | - "meta" => [ |
|
83 | - "current_page" => 2, |
|
84 | - "from" => 6, |
|
85 | - "last_page" => 3, |
|
86 | - "path" => "apiUrl", |
|
87 | - "per_page" => 5, |
|
88 | - "to" => 10, |
|
89 | - "total" => 15 |
|
90 | - ] |
|
91 | - ]; |
|
74 | + $paginateObject = [ |
|
75 | + 'data' => ['Array of model objects'], |
|
76 | + "links" => [ |
|
77 | + "first" => "apiUrl?page=1", |
|
78 | + "last" => "apiUrl?page=3", |
|
79 | + "prev" => "apiUrl?page=2", |
|
80 | + "next" => "apiUrl?page=3" |
|
81 | + ], |
|
82 | + "meta" => [ |
|
83 | + "current_page" => 2, |
|
84 | + "from" => 6, |
|
85 | + "last_page" => 3, |
|
86 | + "path" => "apiUrl", |
|
87 | + "per_page" => 5, |
|
88 | + "to" => 10, |
|
89 | + "total" => 15 |
|
90 | + ] |
|
91 | + ]; |
|
92 | 92 | |
93 | - $responseObject = [ |
|
94 | - 'data' => ['The model object'] |
|
95 | - ]; |
|
93 | + $responseObject = [ |
|
94 | + 'data' => ['The model object'] |
|
95 | + ]; |
|
96 | 96 | |
97 | - $avaialableReports = $this->reportService->all(); |
|
97 | + $avaialableReports = $this->reportService->all(); |
|
98 | 98 | |
99 | - return view('core::doc', ['modules' => $modules, 'reports' => $reports, 'errors' => $errors, 'conditions' => $conditions, 'models' => $models, 'paginateObject' => json_encode($paginateObject, JSON_PRETTY_PRINT), 'responseObject' => json_encode($responseObject, JSON_PRETTY_PRINT), 'avaialableReports' => $avaialableReports]); |
|
100 | - } |
|
99 | + return view('core::doc', ['modules' => $modules, 'reports' => $reports, 'errors' => $errors, 'conditions' => $conditions, 'models' => $models, 'paginateObject' => json_encode($paginateObject, JSON_PRETTY_PRINT), 'responseObject' => json_encode($responseObject, JSON_PRETTY_PRINT), 'avaialableReports' => $avaialableReports]); |
|
100 | + } |
|
101 | 101 | } |
@@ -5,29 +5,29 @@ |
||
5 | 5 | |
6 | 6 | class SettingService extends BaseService |
7 | 7 | { |
8 | - /** |
|
9 | - * Init new object. |
|
10 | - * |
|
11 | - * @param SettingRepository $repo |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function __construct(SettingRepository $repo) |
|
15 | - { |
|
16 | - parent::__construct($repo); |
|
17 | - } |
|
8 | + /** |
|
9 | + * Init new object. |
|
10 | + * |
|
11 | + * @param SettingRepository $repo |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function __construct(SettingRepository $repo) |
|
15 | + { |
|
16 | + parent::__construct($repo); |
|
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->repo->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->repo->save($value); |
|
30 | + } |
|
31 | + }); |
|
32 | + } |
|
33 | 33 | } |
@@ -5,45 +5,45 @@ |
||
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 mixed $report |
|
24 | - * @param array $conditions |
|
25 | - * @param integer $perPage |
|
26 | - * @return object |
|
27 | - */ |
|
28 | - public function renderReport($report, $conditions = [], $perPage = 0) |
|
29 | - { |
|
30 | - $report = ! is_int($report) ? $report : $this->find($report); |
|
31 | - /** |
|
32 | - * Fetch data from the report based on the given conditions. |
|
33 | - */ |
|
34 | - $report = \DB::table($report->view_name); |
|
35 | - unset($conditions['page']); |
|
36 | - if (count($conditions)) { |
|
37 | - $conditions = $this->constructConditions($conditions, $this->model); |
|
38 | - $report->whereRaw($conditions['conditionString'], $conditions['conditionValues']); |
|
39 | - } |
|
40 | - /** |
|
41 | - * Paginate or all data. |
|
42 | - */ |
|
43 | - if ($perPage) { |
|
44 | - return $report->paginate($perPage); |
|
45 | - } else { |
|
46 | - return $report->get(); |
|
47 | - } |
|
48 | - } |
|
19 | + /** |
|
20 | + * Render the given report db view based on the given |
|
21 | + * condition. |
|
22 | + * |
|
23 | + * @param mixed $report |
|
24 | + * @param array $conditions |
|
25 | + * @param integer $perPage |
|
26 | + * @return object |
|
27 | + */ |
|
28 | + public function renderReport($report, $conditions = [], $perPage = 0) |
|
29 | + { |
|
30 | + $report = ! is_int($report) ? $report : $this->find($report); |
|
31 | + /** |
|
32 | + * Fetch data from the report based on the given conditions. |
|
33 | + */ |
|
34 | + $report = \DB::table($report->view_name); |
|
35 | + unset($conditions['page']); |
|
36 | + if (count($conditions)) { |
|
37 | + $conditions = $this->constructConditions($conditions, $this->model); |
|
38 | + $report->whereRaw($conditions['conditionString'], $conditions['conditionValues']); |
|
39 | + } |
|
40 | + /** |
|
41 | + * Paginate or all data. |
|
42 | + */ |
|
43 | + if ($perPage) { |
|
44 | + return $report->paginate($perPage); |
|
45 | + } else { |
|
46 | + return $report->get(); |
|
47 | + } |
|
48 | + } |
|
49 | 49 | } |
@@ -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 | - $adminRoleId = \DB::table('roles')->where('name', 'admin')->select('id')->first()->id; |
|
9 | + /** |
|
10 | + * Run the database seeds. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function run() |
|
15 | + { |
|
16 | + $adminRoleId = \DB::table('roles')->where('name', 'admin')->select('id')->first()->id; |
|
17 | 17 | |
18 | - /** |
|
19 | - * Assign the permissions to the admin role. |
|
20 | - */ |
|
21 | - \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['report'])->each(function ($permission) use ($adminRoleId) { |
|
22 | - \DB::table('permission_role')->insert( |
|
23 | - [ |
|
24 | - 'permission_id' => $permission->id, |
|
25 | - 'role_id' => $adminRoleId, |
|
26 | - 'created_at' => \DB::raw('NOW()'), |
|
27 | - 'updated_at' => \DB::raw('NOW()') |
|
28 | - ] |
|
29 | - ); |
|
30 | - }); |
|
31 | - } |
|
18 | + /** |
|
19 | + * Assign the permissions to the admin role. |
|
20 | + */ |
|
21 | + \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['report'])->each(function ($permission) use ($adminRoleId) { |
|
22 | + \DB::table('permission_role')->insert( |
|
23 | + [ |
|
24 | + 'permission_id' => $permission->id, |
|
25 | + 'role_id' => $adminRoleId, |
|
26 | + 'created_at' => \DB::raw('NOW()'), |
|
27 | + 'updated_at' => \DB::raw('NOW()') |
|
28 | + ] |
|
29 | + ); |
|
30 | + }); |
|
31 | + } |
|
32 | 32 | } |