@@ -18,7 +18,7 @@ |
||
18 | 18 | $table->string('view_name',100); |
19 | 19 | $table->softDeletes(); |
20 | 20 | $table->timestamps(); |
21 | - }); |
|
21 | + }); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | |
6 | 6 | class Report extends Model{ |
7 | 7 | |
8 | - use SoftDeletes; |
|
8 | + use SoftDeletes; |
|
9 | 9 | protected $table = 'reports'; |
10 | 10 | protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
11 | 11 | protected $hidden = ['deleted_at']; |
@@ -13,22 +13,22 @@ discard block |
||
13 | 13 | protected $fillable = ['report_name', 'view_name']; |
14 | 14 | |
15 | 15 | public function getCreatedAtAttribute($value) |
16 | - { |
|
17 | - return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString(); |
|
18 | - } |
|
16 | + { |
|
17 | + return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString(); |
|
18 | + } |
|
19 | 19 | |
20 | - public function getUpdatedAtAttribute($value) |
|
21 | - { |
|
22 | - return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString(); |
|
23 | - } |
|
20 | + public function getUpdatedAtAttribute($value) |
|
21 | + { |
|
22 | + return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString(); |
|
23 | + } |
|
24 | 24 | |
25 | - public function getDeletedAtAttribute($value) |
|
26 | - { |
|
27 | - return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString(); |
|
28 | - } |
|
25 | + public function getDeletedAtAttribute($value) |
|
26 | + { |
|
27 | + return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString(); |
|
28 | + } |
|
29 | 29 | |
30 | - public static function boot() |
|
31 | - { |
|
32 | - parent::boot(); |
|
33 | - } |
|
30 | + public static function boot() |
|
31 | + { |
|
32 | + parent::boot(); |
|
33 | + } |
|
34 | 34 | } |
@@ -12,77 +12,77 @@ |
||
12 | 12 | */ |
13 | 13 | public function up() |
14 | 14 | { |
15 | - /** |
|
16 | - * Delete previous permissions. |
|
17 | - */ |
|
15 | + /** |
|
16 | + * Delete previous permissions. |
|
17 | + */ |
|
18 | 18 | DB::table('permissions')->whereIn('model', ['notifications'])->delete(); |
19 | 19 | |
20 | 20 | /** |
21 | - * Insert the permissions related to this module. |
|
22 | - */ |
|
23 | - DB::table('permissions')->insert( |
|
24 | - [ |
|
25 | - /** |
|
26 | - * Logs model permissions. |
|
27 | - */ |
|
28 | - [ |
|
29 | - 'name' => 'find', |
|
30 | - 'model' => 'notifications', |
|
31 | - 'created_at' => \DB::raw('NOW()'), |
|
32 | - 'updated_at' => \DB::raw('NOW()') |
|
33 | - ], |
|
34 | - [ |
|
35 | - 'name' => 'search', |
|
36 | - 'model' => 'notifications', |
|
37 | - 'created_at' => \DB::raw('NOW()'), |
|
38 | - 'updated_at' => \DB::raw('NOW()') |
|
39 | - ], |
|
40 | - [ |
|
41 | - 'name' => 'list', |
|
42 | - 'model' => 'notifications', |
|
43 | - 'created_at' => \DB::raw('NOW()'), |
|
44 | - 'updated_at' => \DB::raw('NOW()') |
|
45 | - ], |
|
46 | - [ |
|
47 | - 'name' => 'findby', |
|
48 | - 'model' => 'notifications', |
|
49 | - 'created_at' => \DB::raw('NOW()'), |
|
50 | - 'updated_at' => \DB::raw('NOW()') |
|
51 | - ], |
|
52 | - [ |
|
53 | - 'name' => 'first', |
|
54 | - 'model' => 'notifications', |
|
55 | - 'created_at' => \DB::raw('NOW()'), |
|
56 | - 'updated_at' => \DB::raw('NOW()') |
|
57 | - ], |
|
58 | - [ |
|
59 | - 'name' => 'paginate', |
|
60 | - 'model' => 'notifications', |
|
61 | - 'created_at' => \DB::raw('NOW()'), |
|
62 | - 'updated_at' => \DB::raw('NOW()') |
|
63 | - ], |
|
64 | - [ |
|
65 | - 'name' => 'paginateby', |
|
66 | - 'model' => 'notifications', |
|
67 | - 'created_at' => \DB::raw('NOW()'), |
|
68 | - 'updated_at' => \DB::raw('NOW()') |
|
69 | - ], |
|
70 | - [ |
|
71 | - 'name' => 'notified', |
|
72 | - 'model' => 'notifications', |
|
73 | - 'created_at' => \DB::raw('NOW()'), |
|
74 | - 'updated_at' => \DB::raw('NOW()') |
|
75 | - ], |
|
76 | - [ |
|
77 | - 'name' => 'notifyall', |
|
78 | - 'model' => 'notifications', |
|
79 | - 'created_at' => \DB::raw('NOW()'), |
|
80 | - 'updated_at' => \DB::raw('NOW()') |
|
81 | - ], |
|
82 | - ] |
|
83 | - ); |
|
21 | + * Insert the permissions related to this module. |
|
22 | + */ |
|
23 | + DB::table('permissions')->insert( |
|
24 | + [ |
|
25 | + /** |
|
26 | + * Logs model permissions. |
|
27 | + */ |
|
28 | + [ |
|
29 | + 'name' => 'find', |
|
30 | + 'model' => 'notifications', |
|
31 | + 'created_at' => \DB::raw('NOW()'), |
|
32 | + 'updated_at' => \DB::raw('NOW()') |
|
33 | + ], |
|
34 | + [ |
|
35 | + 'name' => 'search', |
|
36 | + 'model' => 'notifications', |
|
37 | + 'created_at' => \DB::raw('NOW()'), |
|
38 | + 'updated_at' => \DB::raw('NOW()') |
|
39 | + ], |
|
40 | + [ |
|
41 | + 'name' => 'list', |
|
42 | + 'model' => 'notifications', |
|
43 | + 'created_at' => \DB::raw('NOW()'), |
|
44 | + 'updated_at' => \DB::raw('NOW()') |
|
45 | + ], |
|
46 | + [ |
|
47 | + 'name' => 'findby', |
|
48 | + 'model' => 'notifications', |
|
49 | + 'created_at' => \DB::raw('NOW()'), |
|
50 | + 'updated_at' => \DB::raw('NOW()') |
|
51 | + ], |
|
52 | + [ |
|
53 | + 'name' => 'first', |
|
54 | + 'model' => 'notifications', |
|
55 | + 'created_at' => \DB::raw('NOW()'), |
|
56 | + 'updated_at' => \DB::raw('NOW()') |
|
57 | + ], |
|
58 | + [ |
|
59 | + 'name' => 'paginate', |
|
60 | + 'model' => 'notifications', |
|
61 | + 'created_at' => \DB::raw('NOW()'), |
|
62 | + 'updated_at' => \DB::raw('NOW()') |
|
63 | + ], |
|
64 | + [ |
|
65 | + 'name' => 'paginateby', |
|
66 | + 'model' => 'notifications', |
|
67 | + 'created_at' => \DB::raw('NOW()'), |
|
68 | + 'updated_at' => \DB::raw('NOW()') |
|
69 | + ], |
|
70 | + [ |
|
71 | + 'name' => 'notified', |
|
72 | + 'model' => 'notifications', |
|
73 | + 'created_at' => \DB::raw('NOW()'), |
|
74 | + 'updated_at' => \DB::raw('NOW()') |
|
75 | + ], |
|
76 | + [ |
|
77 | + 'name' => 'notifyall', |
|
78 | + 'model' => 'notifications', |
|
79 | + 'created_at' => \DB::raw('NOW()'), |
|
80 | + 'updated_at' => \DB::raw('NOW()') |
|
81 | + ], |
|
82 | + ] |
|
83 | + ); |
|
84 | 84 | |
85 | - /** |
|
85 | + /** |
|
86 | 86 | * Assign the permissions to the admin group. |
87 | 87 | */ |
88 | 88 | $permissionIds = DB::table('permissions')->whereIn('model', ['notifications'])->select('id')->lists('id'); |
@@ -11,28 +11,28 @@ |
||
11 | 11 | */ |
12 | 12 | protected function getModel() |
13 | 13 | { |
14 | - $apiVersion = \Request::header('api-version') ?: 1; |
|
14 | + $apiVersion = \Request::header('api-version') ?: 1; |
|
15 | 15 | return 'App\Modules\Notifications\Notification'; |
16 | 16 | } |
17 | 17 | |
18 | 18 | /** |
19 | - * Set the notification notified to true. |
|
20 | - * |
|
21 | - * @param integer $id |
|
22 | - * @return object |
|
23 | - */ |
|
24 | - public function notified($id) |
|
25 | - { |
|
26 | - return $this->save(['id' => $id, 'notified' => 1]); |
|
27 | - } |
|
19 | + * Set the notification notified to true. |
|
20 | + * |
|
21 | + * @param integer $id |
|
22 | + * @return object |
|
23 | + */ |
|
24 | + public function notified($id) |
|
25 | + { |
|
26 | + return $this->save(['id' => $id, 'notified' => 1]); |
|
27 | + } |
|
28 | 28 | |
29 | - /** |
|
30 | - * Set the notification notified to all. |
|
31 | - * |
|
32 | - * @return void |
|
33 | - */ |
|
34 | - public function notifyAll() |
|
35 | - { |
|
36 | - \Core::notifications()->update(false, ['notified' => 1], 'notified'); |
|
37 | - } |
|
29 | + /** |
|
30 | + * Set the notification notified to all. |
|
31 | + * |
|
32 | + * @return void |
|
33 | + */ |
|
34 | + public function notifyAll() |
|
35 | + { |
|
36 | + \Core::notifications()->update(false, ['notified' => 1], 'notified'); |
|
37 | + } |
|
38 | 38 | } |
@@ -8,16 +8,16 @@ |
||
8 | 8 | class ReportsController extends BaseApiController |
9 | 9 | { |
10 | 10 | /** |
11 | - * The name of the model that is used by the base api controller |
|
12 | - * to preform actions like (add, edit ... etc). |
|
13 | - * @var string |
|
14 | - */ |
|
15 | - protected $model = 'reports'; |
|
11 | + * The name of the model that is used by the base api controller |
|
12 | + * to preform actions like (add, edit ... etc). |
|
13 | + * @var string |
|
14 | + */ |
|
15 | + protected $model = 'reports'; |
|
16 | 16 | |
17 | - /** |
|
18 | - * List of all route actions that the base api controller |
|
19 | - * will skip permissions check for them. |
|
20 | - * @var array |
|
21 | - */ |
|
22 | - protected $skipPermissionCheck = ['find', 'first']; |
|
17 | + /** |
|
18 | + * List of all route actions that the base api controller |
|
19 | + * will skip permissions check for them. |
|
20 | + * @var array |
|
21 | + */ |
|
22 | + protected $skipPermissionCheck = ['find', 'first']; |
|
23 | 23 | } |
@@ -12,191 +12,191 @@ discard block |
||
12 | 12 | */ |
13 | 13 | public function up() |
14 | 14 | { |
15 | - /** |
|
16 | - * Delete previous permissions. |
|
17 | - */ |
|
15 | + /** |
|
16 | + * Delete previous permissions. |
|
17 | + */ |
|
18 | 18 | DB::table('permissions')->whereIn('model', ['users', 'permissions', 'groups'])->delete(); |
19 | 19 | |
20 | 20 | /** |
21 | - * Insert the permissions related to this module. |
|
22 | - */ |
|
23 | - DB::table('permissions')->insert( |
|
24 | - [ |
|
25 | - /** |
|
26 | - * Users model permissions. |
|
27 | - */ |
|
28 | - [ |
|
29 | - 'name' => 'save', |
|
30 | - 'model' => 'users', |
|
31 | - 'created_at' => \DB::raw('NOW()'), |
|
32 | - 'updated_at' => \DB::raw('NOW()') |
|
33 | - ], |
|
34 | - [ |
|
35 | - 'name' => 'delete', |
|
36 | - 'model' => 'users', |
|
37 | - 'created_at' => \DB::raw('NOW()'), |
|
38 | - 'updated_at' => \DB::raw('NOW()') |
|
39 | - ], |
|
40 | - [ |
|
41 | - 'name' => 'find', |
|
42 | - 'model' => 'users', |
|
43 | - 'created_at' => \DB::raw('NOW()'), |
|
44 | - 'updated_at' => \DB::raw('NOW()') |
|
45 | - ], |
|
46 | - [ |
|
47 | - 'name' => 'list', |
|
48 | - 'model' => 'users', |
|
49 | - 'created_at' => \DB::raw('NOW()'), |
|
50 | - 'updated_at' => \DB::raw('NOW()') |
|
51 | - ], |
|
52 | - [ |
|
53 | - 'name' => 'search', |
|
54 | - 'model' => 'users', |
|
55 | - 'created_at' => \DB::raw('NOW()'), |
|
56 | - 'updated_at' => \DB::raw('NOW()') |
|
57 | - ], |
|
58 | - [ |
|
59 | - 'name' => 'findby', |
|
60 | - 'model' => 'users', |
|
61 | - 'created_at' => \DB::raw('NOW()'), |
|
62 | - 'updated_at' => \DB::raw('NOW()') |
|
63 | - ], |
|
64 | - [ |
|
65 | - 'name' => 'first', |
|
66 | - 'model' => 'users', |
|
67 | - 'created_at' => \DB::raw('NOW()'), |
|
68 | - 'updated_at' => \DB::raw('NOW()') |
|
69 | - ], |
|
70 | - [ |
|
71 | - 'name' => 'paginate', |
|
72 | - 'model' => 'users', |
|
73 | - 'created_at' => \DB::raw('NOW()'), |
|
74 | - 'updated_at' => \DB::raw('NOW()') |
|
75 | - ], |
|
76 | - [ |
|
77 | - 'name' => 'paginateby', |
|
78 | - 'model' => 'users', |
|
79 | - 'created_at' => \DB::raw('NOW()'), |
|
80 | - 'updated_at' => \DB::raw('NOW()') |
|
81 | - ], |
|
82 | - [ |
|
83 | - 'name' => 'assigngroups', |
|
84 | - 'model' => 'users', |
|
85 | - 'created_at' => \DB::raw('NOW()'), |
|
86 | - 'updated_at' => \DB::raw('NOW()') |
|
87 | - ], |
|
21 | + * Insert the permissions related to this module. |
|
22 | + */ |
|
23 | + DB::table('permissions')->insert( |
|
24 | + [ |
|
25 | + /** |
|
26 | + * Users model permissions. |
|
27 | + */ |
|
28 | + [ |
|
29 | + 'name' => 'save', |
|
30 | + 'model' => 'users', |
|
31 | + 'created_at' => \DB::raw('NOW()'), |
|
32 | + 'updated_at' => \DB::raw('NOW()') |
|
33 | + ], |
|
34 | + [ |
|
35 | + 'name' => 'delete', |
|
36 | + 'model' => 'users', |
|
37 | + 'created_at' => \DB::raw('NOW()'), |
|
38 | + 'updated_at' => \DB::raw('NOW()') |
|
39 | + ], |
|
40 | + [ |
|
41 | + 'name' => 'find', |
|
42 | + 'model' => 'users', |
|
43 | + 'created_at' => \DB::raw('NOW()'), |
|
44 | + 'updated_at' => \DB::raw('NOW()') |
|
45 | + ], |
|
46 | + [ |
|
47 | + 'name' => 'list', |
|
48 | + 'model' => 'users', |
|
49 | + 'created_at' => \DB::raw('NOW()'), |
|
50 | + 'updated_at' => \DB::raw('NOW()') |
|
51 | + ], |
|
52 | + [ |
|
53 | + 'name' => 'search', |
|
54 | + 'model' => 'users', |
|
55 | + 'created_at' => \DB::raw('NOW()'), |
|
56 | + 'updated_at' => \DB::raw('NOW()') |
|
57 | + ], |
|
58 | + [ |
|
59 | + 'name' => 'findby', |
|
60 | + 'model' => 'users', |
|
61 | + 'created_at' => \DB::raw('NOW()'), |
|
62 | + 'updated_at' => \DB::raw('NOW()') |
|
63 | + ], |
|
64 | + [ |
|
65 | + 'name' => 'first', |
|
66 | + 'model' => 'users', |
|
67 | + 'created_at' => \DB::raw('NOW()'), |
|
68 | + 'updated_at' => \DB::raw('NOW()') |
|
69 | + ], |
|
70 | + [ |
|
71 | + 'name' => 'paginate', |
|
72 | + 'model' => 'users', |
|
73 | + 'created_at' => \DB::raw('NOW()'), |
|
74 | + 'updated_at' => \DB::raw('NOW()') |
|
75 | + ], |
|
76 | + [ |
|
77 | + 'name' => 'paginateby', |
|
78 | + 'model' => 'users', |
|
79 | + 'created_at' => \DB::raw('NOW()'), |
|
80 | + 'updated_at' => \DB::raw('NOW()') |
|
81 | + ], |
|
82 | + [ |
|
83 | + 'name' => 'assigngroups', |
|
84 | + 'model' => 'users', |
|
85 | + 'created_at' => \DB::raw('NOW()'), |
|
86 | + 'updated_at' => \DB::raw('NOW()') |
|
87 | + ], |
|
88 | 88 | |
89 | - /** |
|
90 | - * Permissions model permissions. |
|
91 | - */ |
|
92 | - [ |
|
93 | - 'name' => 'find', |
|
94 | - 'model' => 'permissions', |
|
95 | - 'created_at' => \DB::raw('NOW()'), |
|
96 | - 'updated_at' => \DB::raw('NOW()') |
|
97 | - ], |
|
98 | - [ |
|
99 | - 'name' => 'search', |
|
100 | - 'model' => 'permissions', |
|
101 | - 'created_at' => \DB::raw('NOW()'), |
|
102 | - 'updated_at' => \DB::raw('NOW()') |
|
103 | - ], |
|
104 | - [ |
|
105 | - 'name' => 'list', |
|
106 | - 'model' => 'permissions', |
|
107 | - 'created_at' => \DB::raw('NOW()'), |
|
108 | - 'updated_at' => \DB::raw('NOW()') |
|
109 | - ], |
|
110 | - [ |
|
111 | - 'name' => 'findby', |
|
112 | - 'model' => 'permissions', |
|
113 | - 'created_at' => \DB::raw('NOW()'), |
|
114 | - 'updated_at' => \DB::raw('NOW()') |
|
115 | - ], |
|
116 | - [ |
|
117 | - 'name' => 'first', |
|
118 | - 'model' => 'permissions', |
|
119 | - 'created_at' => \DB::raw('NOW()'), |
|
120 | - 'updated_at' => \DB::raw('NOW()') |
|
121 | - ], |
|
122 | - [ |
|
123 | - 'name' => 'paginate', |
|
124 | - 'model' => 'permissions', |
|
125 | - 'created_at' => \DB::raw('NOW()'), |
|
126 | - 'updated_at' => \DB::raw('NOW()') |
|
127 | - ], |
|
128 | - [ |
|
129 | - 'name' => 'paginateby', |
|
130 | - 'model' => 'permissions', |
|
131 | - 'created_at' => \DB::raw('NOW()'), |
|
132 | - 'updated_at' => \DB::raw('NOW()') |
|
133 | - ], |
|
89 | + /** |
|
90 | + * Permissions model permissions. |
|
91 | + */ |
|
92 | + [ |
|
93 | + 'name' => 'find', |
|
94 | + 'model' => 'permissions', |
|
95 | + 'created_at' => \DB::raw('NOW()'), |
|
96 | + 'updated_at' => \DB::raw('NOW()') |
|
97 | + ], |
|
98 | + [ |
|
99 | + 'name' => 'search', |
|
100 | + 'model' => 'permissions', |
|
101 | + 'created_at' => \DB::raw('NOW()'), |
|
102 | + 'updated_at' => \DB::raw('NOW()') |
|
103 | + ], |
|
104 | + [ |
|
105 | + 'name' => 'list', |
|
106 | + 'model' => 'permissions', |
|
107 | + 'created_at' => \DB::raw('NOW()'), |
|
108 | + 'updated_at' => \DB::raw('NOW()') |
|
109 | + ], |
|
110 | + [ |
|
111 | + 'name' => 'findby', |
|
112 | + 'model' => 'permissions', |
|
113 | + 'created_at' => \DB::raw('NOW()'), |
|
114 | + 'updated_at' => \DB::raw('NOW()') |
|
115 | + ], |
|
116 | + [ |
|
117 | + 'name' => 'first', |
|
118 | + 'model' => 'permissions', |
|
119 | + 'created_at' => \DB::raw('NOW()'), |
|
120 | + 'updated_at' => \DB::raw('NOW()') |
|
121 | + ], |
|
122 | + [ |
|
123 | + 'name' => 'paginate', |
|
124 | + 'model' => 'permissions', |
|
125 | + 'created_at' => \DB::raw('NOW()'), |
|
126 | + 'updated_at' => \DB::raw('NOW()') |
|
127 | + ], |
|
128 | + [ |
|
129 | + 'name' => 'paginateby', |
|
130 | + 'model' => 'permissions', |
|
131 | + 'created_at' => \DB::raw('NOW()'), |
|
132 | + 'updated_at' => \DB::raw('NOW()') |
|
133 | + ], |
|
134 | 134 | |
135 | - /** |
|
136 | - * Groups model permissions. |
|
137 | - */ |
|
138 | - [ |
|
139 | - 'name' => 'save', |
|
140 | - 'model' => 'groups', |
|
141 | - 'created_at' => \DB::raw('NOW()'), |
|
142 | - 'updated_at' => \DB::raw('NOW()') |
|
143 | - ], |
|
144 | - [ |
|
145 | - 'name' => 'delete', |
|
146 | - 'model' => 'groups', |
|
147 | - 'created_at' => \DB::raw('NOW()'), |
|
148 | - 'updated_at' => \DB::raw('NOW()') |
|
149 | - ], |
|
150 | - [ |
|
151 | - 'name' => 'find', |
|
152 | - 'model' => 'groups', |
|
153 | - 'created_at' => \DB::raw('NOW()'), |
|
154 | - 'updated_at' => \DB::raw('NOW()') |
|
155 | - ], |
|
156 | - [ |
|
157 | - 'name' => 'search', |
|
158 | - 'model' => 'groups', |
|
159 | - 'created_at' => \DB::raw('NOW()'), |
|
160 | - 'updated_at' => \DB::raw('NOW()') |
|
161 | - ], |
|
162 | - [ |
|
163 | - 'name' => 'list', |
|
164 | - 'model' => 'groups', |
|
165 | - 'created_at' => \DB::raw('NOW()'), |
|
166 | - 'updated_at' => \DB::raw('NOW()') |
|
167 | - ], |
|
168 | - [ |
|
169 | - 'name' => 'findby', |
|
170 | - 'model' => 'groups', |
|
171 | - 'created_at' => \DB::raw('NOW()'), |
|
172 | - 'updated_at' => \DB::raw('NOW()') |
|
173 | - ], |
|
174 | - [ |
|
175 | - 'name' => 'first', |
|
176 | - 'model' => 'groups', |
|
177 | - 'created_at' => \DB::raw('NOW()'), |
|
178 | - 'updated_at' => \DB::raw('NOW()') |
|
179 | - ], |
|
180 | - [ |
|
181 | - 'name' => 'paginate', |
|
182 | - 'model' => 'groups', |
|
183 | - 'created_at' => \DB::raw('NOW()'), |
|
184 | - 'updated_at' => \DB::raw('NOW()') |
|
185 | - ], |
|
186 | - [ |
|
187 | - 'name' => 'paginateby', |
|
188 | - 'model' => 'groups', |
|
189 | - 'created_at' => \DB::raw('NOW()'), |
|
190 | - 'updated_at' => \DB::raw('NOW()') |
|
191 | - ], |
|
192 | - [ |
|
193 | - 'name' => 'assignpermissions', |
|
194 | - 'model' => 'groups', |
|
195 | - 'created_at' => \DB::raw('NOW()'), |
|
196 | - 'updated_at' => \DB::raw('NOW()') |
|
197 | - ], |
|
198 | - ] |
|
199 | - ); |
|
135 | + /** |
|
136 | + * Groups model permissions. |
|
137 | + */ |
|
138 | + [ |
|
139 | + 'name' => 'save', |
|
140 | + 'model' => 'groups', |
|
141 | + 'created_at' => \DB::raw('NOW()'), |
|
142 | + 'updated_at' => \DB::raw('NOW()') |
|
143 | + ], |
|
144 | + [ |
|
145 | + 'name' => 'delete', |
|
146 | + 'model' => 'groups', |
|
147 | + 'created_at' => \DB::raw('NOW()'), |
|
148 | + 'updated_at' => \DB::raw('NOW()') |
|
149 | + ], |
|
150 | + [ |
|
151 | + 'name' => 'find', |
|
152 | + 'model' => 'groups', |
|
153 | + 'created_at' => \DB::raw('NOW()'), |
|
154 | + 'updated_at' => \DB::raw('NOW()') |
|
155 | + ], |
|
156 | + [ |
|
157 | + 'name' => 'search', |
|
158 | + 'model' => 'groups', |
|
159 | + 'created_at' => \DB::raw('NOW()'), |
|
160 | + 'updated_at' => \DB::raw('NOW()') |
|
161 | + ], |
|
162 | + [ |
|
163 | + 'name' => 'list', |
|
164 | + 'model' => 'groups', |
|
165 | + 'created_at' => \DB::raw('NOW()'), |
|
166 | + 'updated_at' => \DB::raw('NOW()') |
|
167 | + ], |
|
168 | + [ |
|
169 | + 'name' => 'findby', |
|
170 | + 'model' => 'groups', |
|
171 | + 'created_at' => \DB::raw('NOW()'), |
|
172 | + 'updated_at' => \DB::raw('NOW()') |
|
173 | + ], |
|
174 | + [ |
|
175 | + 'name' => 'first', |
|
176 | + 'model' => 'groups', |
|
177 | + 'created_at' => \DB::raw('NOW()'), |
|
178 | + 'updated_at' => \DB::raw('NOW()') |
|
179 | + ], |
|
180 | + [ |
|
181 | + 'name' => 'paginate', |
|
182 | + 'model' => 'groups', |
|
183 | + 'created_at' => \DB::raw('NOW()'), |
|
184 | + 'updated_at' => \DB::raw('NOW()') |
|
185 | + ], |
|
186 | + [ |
|
187 | + 'name' => 'paginateby', |
|
188 | + 'model' => 'groups', |
|
189 | + 'created_at' => \DB::raw('NOW()'), |
|
190 | + 'updated_at' => \DB::raw('NOW()') |
|
191 | + ], |
|
192 | + [ |
|
193 | + 'name' => 'assignpermissions', |
|
194 | + 'model' => 'groups', |
|
195 | + 'created_at' => \DB::raw('NOW()'), |
|
196 | + 'updated_at' => \DB::raw('NOW()') |
|
197 | + ], |
|
198 | + ] |
|
199 | + ); |
|
200 | 200 | |
201 | 201 | /** |
202 | 202 | * Delete previous data. |
@@ -224,29 +224,29 @@ discard block |
||
224 | 224 | * Create Default users. |
225 | 225 | */ |
226 | 226 | $adminUserId = DB::table('users')->insertGetId( |
227 | - [ |
|
227 | + [ |
|
228 | 228 | 'email' => '[email protected]', |
229 | 229 | 'password' => bcrypt('123456'), |
230 | 230 | 'created_at' => \DB::raw('NOW()'), |
231 | 231 | 'updated_at' => \DB::raw('NOW()') |
232 | 232 | ] |
233 | - ); |
|
233 | + ); |
|
234 | 234 | |
235 | 235 | /** |
236 | 236 | * Assign users to groups. |
237 | 237 | */ |
238 | 238 | DB::table('users_groups')->insert( |
239 | - [ |
|
240 | - [ |
|
239 | + [ |
|
240 | + [ |
|
241 | 241 | 'user_id' => $adminUserId, |
242 | 242 | 'group_id' => $adminGroupId, |
243 | 243 | 'created_at' => \DB::raw('NOW()'), |
244 | 244 | 'updated_at' => \DB::raw('NOW()') |
245 | - ] |
|
246 | - ] |
|
247 | - ); |
|
245 | + ] |
|
246 | + ] |
|
247 | + ); |
|
248 | 248 | |
249 | - /** |
|
249 | + /** |
|
250 | 250 | * Assign the permissions to the admin group. |
251 | 251 | */ |
252 | 252 | $permissionIds = DB::table('permissions')->whereIn('model', ['users', 'permissions', 'groups'])->select('id')->lists('id'); |
@@ -7,108 +7,108 @@ |
||
7 | 7 | |
8 | 8 | class UsersController extends BaseApiController |
9 | 9 | { |
10 | - /** |
|
11 | - * The name of the model that is used by the base api controller |
|
12 | - * to preform actions like (add, edit ... etc). |
|
13 | - * @var string |
|
14 | - */ |
|
15 | - protected $model = 'users'; |
|
10 | + /** |
|
11 | + * The name of the model that is used by the base api controller |
|
12 | + * to preform actions like (add, edit ... etc). |
|
13 | + * @var string |
|
14 | + */ |
|
15 | + protected $model = 'users'; |
|
16 | 16 | |
17 | - /** |
|
18 | - * List of all route actions that the base api controller |
|
19 | - * will skip permissions check for them. |
|
20 | - * @var array |
|
21 | - */ |
|
22 | - protected $skipPermissionCheck = ['account', 'logout']; |
|
17 | + /** |
|
18 | + * List of all route actions that the base api controller |
|
19 | + * will skip permissions check for them. |
|
20 | + * @var array |
|
21 | + */ |
|
22 | + protected $skipPermissionCheck = ['account', 'logout']; |
|
23 | 23 | |
24 | - /** |
|
25 | - * List of all route actions that the base api controller |
|
26 | - * will skip login check for them. |
|
27 | - * @var array |
|
28 | - */ |
|
29 | - protected $skipLoginCheck = ['login', 'register']; |
|
24 | + /** |
|
25 | + * List of all route actions that the base api controller |
|
26 | + * will skip login check for them. |
|
27 | + * @var array |
|
28 | + */ |
|
29 | + protected $skipLoginCheck = ['login', 'register']; |
|
30 | 30 | |
31 | - /** |
|
32 | - * The validations rules used by the base api controller |
|
33 | - * to check before add. |
|
34 | - * @var array |
|
35 | - */ |
|
36 | - protected $validationRules = [ |
|
37 | - 'email' => 'required|email|unique:users,email,{id}', |
|
38 | - 'password' => 'min:6' |
|
39 | - ]; |
|
31 | + /** |
|
32 | + * The validations rules used by the base api controller |
|
33 | + * to check before add. |
|
34 | + * @var array |
|
35 | + */ |
|
36 | + protected $validationRules = [ |
|
37 | + 'email' => 'required|email|unique:users,email,{id}', |
|
38 | + 'password' => 'min:6' |
|
39 | + ]; |
|
40 | 40 | |
41 | - /** |
|
42 | - * Return the logged in user account. |
|
43 | - * |
|
44 | - * @return object |
|
45 | - */ |
|
46 | - public function getAccount() |
|
47 | - { |
|
48 | - $relations = $this->relations && $this->relations['find'] ? $this->relations['find'] : []; |
|
49 | - return \Response::json(call_user_func_array("\Core::{$this->model}", [])->find(\JWTAuth::parseToken()->authenticate()->id, $relations), 200); |
|
50 | - } |
|
41 | + /** |
|
42 | + * Return the logged in user account. |
|
43 | + * |
|
44 | + * @return object |
|
45 | + */ |
|
46 | + public function getAccount() |
|
47 | + { |
|
48 | + $relations = $this->relations && $this->relations['find'] ? $this->relations['find'] : []; |
|
49 | + return \Response::json(call_user_func_array("\Core::{$this->model}", [])->find(\JWTAuth::parseToken()->authenticate()->id, $relations), 200); |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Logout the user. |
|
54 | - * |
|
55 | - * @return void |
|
56 | - */ |
|
57 | - public function getLogout() |
|
58 | - { |
|
59 | - return \Response::json(\JWTAuth::invalidate(\JWTAuth::getToken()), 200); |
|
60 | - } |
|
52 | + /** |
|
53 | + * Logout the user. |
|
54 | + * |
|
55 | + * @return void |
|
56 | + */ |
|
57 | + public function getLogout() |
|
58 | + { |
|
59 | + return \Response::json(\JWTAuth::invalidate(\JWTAuth::getToken()), 200); |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * Handle a registration request. |
|
64 | - * |
|
65 | - * @param \Illuminate\Http\Request $request |
|
66 | - * @return \Illuminate\Http\Response |
|
67 | - */ |
|
68 | - public function postRegister(Request $request) |
|
69 | - { |
|
70 | - $this->validate($request, ['email' => 'required|email|unique:users,email,{id}', 'password' => 'required|min:6']); |
|
62 | + /** |
|
63 | + * Handle a registration request. |
|
64 | + * |
|
65 | + * @param \Illuminate\Http\Request $request |
|
66 | + * @return \Illuminate\Http\Response |
|
67 | + */ |
|
68 | + public function postRegister(Request $request) |
|
69 | + { |
|
70 | + $this->validate($request, ['email' => 'required|email|unique:users,email,{id}', 'password' => 'required|min:6']); |
|
71 | 71 | |
72 | - $credentials = $request->only('email', 'password'); |
|
73 | - $token = \JWTAuth::fromUser(\Core::users()->model->create($credentials)); |
|
74 | - return \Response::json($token, 200); |
|
75 | - } |
|
72 | + $credentials = $request->only('email', 'password'); |
|
73 | + $token = \JWTAuth::fromUser(\Core::users()->model->create($credentials)); |
|
74 | + return \Response::json($token, 200); |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * Handle a login request to the application. |
|
79 | - * |
|
80 | - * @param \Illuminate\Http\Request $request |
|
81 | - * @return \Illuminate\Http\Response |
|
82 | - */ |
|
83 | - public function postLogin(Request $request) |
|
84 | - { |
|
85 | - $credentials = $request->only('email', 'password'); |
|
77 | + /** |
|
78 | + * Handle a login request to the application. |
|
79 | + * |
|
80 | + * @param \Illuminate\Http\Request $request |
|
81 | + * @return \Illuminate\Http\Response |
|
82 | + */ |
|
83 | + public function postLogin(Request $request) |
|
84 | + { |
|
85 | + $credentials = $request->only('email', 'password'); |
|
86 | 86 | |
87 | - if ($token = \JWTAuth::attempt($credentials)) |
|
88 | - { |
|
89 | - $relations = $this->relations && $this->relations['find'] ? $this->relations['find'] : []; |
|
90 | - return \Response::json($token, 200); |
|
91 | - } |
|
92 | - else |
|
93 | - { |
|
94 | - $error = \ErrorHandler::loginFailed(); |
|
95 | - abort($error['status'], $error['message']); |
|
96 | - } |
|
97 | - } |
|
87 | + if ($token = \JWTAuth::attempt($credentials)) |
|
88 | + { |
|
89 | + $relations = $this->relations && $this->relations['find'] ? $this->relations['find'] : []; |
|
90 | + return \Response::json($token, 200); |
|
91 | + } |
|
92 | + else |
|
93 | + { |
|
94 | + $error = \ErrorHandler::loginFailed(); |
|
95 | + abort($error['status'], $error['message']); |
|
96 | + } |
|
97 | + } |
|
98 | 98 | |
99 | - /** |
|
100 | - * Handle an assign groups to user request. |
|
101 | - * |
|
102 | - * @param \Illuminate\Http\Request $request |
|
103 | - * @return \Illuminate\Http\Response |
|
104 | - */ |
|
105 | - public function postAssigngroups(Request $request) |
|
106 | - { |
|
107 | - $this->validate($request, [ |
|
108 | - 'group_ids' => 'required|exists:groups,id', |
|
109 | - 'user_id' => 'required|exists:users,id' |
|
110 | - ]); |
|
99 | + /** |
|
100 | + * Handle an assign groups to user request. |
|
101 | + * |
|
102 | + * @param \Illuminate\Http\Request $request |
|
103 | + * @return \Illuminate\Http\Response |
|
104 | + */ |
|
105 | + public function postAssigngroups(Request $request) |
|
106 | + { |
|
107 | + $this->validate($request, [ |
|
108 | + 'group_ids' => 'required|exists:groups,id', |
|
109 | + 'user_id' => 'required|exists:users,id' |
|
110 | + ]); |
|
111 | 111 | |
112 | - return \Response::json(\Core::users()->assignGroups($request->get('user_id'), $request->get('group_ids')), 200); |
|
113 | - } |
|
112 | + return \Response::json(\Core::users()->assignGroups($request->get('user_id'), $request->get('group_ids')), 200); |
|
113 | + } |
|
114 | 114 | } |
@@ -11,63 +11,63 @@ |
||
11 | 11 | */ |
12 | 12 | protected function getModel() |
13 | 13 | { |
14 | - $apiVersion = \Request::header('api-version') ?: 1; |
|
14 | + $apiVersion = \Request::header('api-version') ?: 1; |
|
15 | 15 | return 'App\Modules\Reporting\Report'; |
16 | 16 | } |
17 | 17 | |
18 | 18 | /** |
19 | - * Render the given report db view. |
|
20 | - * |
|
21 | - * @param integer $id |
|
22 | - * @param array $relations |
|
23 | - * @param array $columns |
|
24 | - * @return object |
|
25 | - */ |
|
26 | - public function find($id, $relations = [], $columns = array('*')) |
|
27 | - { |
|
19 | + * Render the given report db view. |
|
20 | + * |
|
21 | + * @param integer $id |
|
22 | + * @param array $relations |
|
23 | + * @param array $columns |
|
24 | + * @return object |
|
25 | + */ |
|
26 | + public function find($id, $relations = [], $columns = array('*')) |
|
27 | + { |
|
28 | 28 | $report = call_user_func_array("{$this->getModel()}::with", array($relations))->find($id, $columns); |
29 | 29 | |
30 | - if ( ! $report) |
|
31 | - { |
|
32 | - $error = \ErrorHandler::notFound('report'); |
|
33 | - abort($error['status'], $error['message']); |
|
34 | - } |
|
30 | + if ( ! $report) |
|
31 | + { |
|
32 | + $error = \ErrorHandler::notFound('report'); |
|
33 | + abort($error['status'], $error['message']); |
|
34 | + } |
|
35 | 35 | |
36 | - if ( ! \Core::users()->can($report->view_name, 'reports')) |
|
37 | - { |
|
38 | - $error = \ErrorHandler::noPermissions(); |
|
39 | - abort($error['status'], $error['message']); |
|
40 | - } |
|
36 | + if ( ! \Core::users()->can($report->view_name, 'reports')) |
|
37 | + { |
|
38 | + $error = \ErrorHandler::noPermissions(); |
|
39 | + abort($error['status'], $error['message']); |
|
40 | + } |
|
41 | 41 | |
42 | - return \DB::table($report->view_name)->get(); |
|
43 | - } |
|
42 | + return \DB::table($report->view_name)->get(); |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * Render the given report db view based on the given |
|
47 | - * condition. |
|
48 | - * |
|
49 | - * @param array $conditions array of conditions |
|
50 | - * @param array $relations |
|
51 | - * @param array $colunmns |
|
52 | - * @return object |
|
53 | - */ |
|
54 | - public function first($conditions, $relations = [], $columns = array('*')) |
|
55 | - { |
|
45 | + /** |
|
46 | + * Render the given report db view based on the given |
|
47 | + * condition. |
|
48 | + * |
|
49 | + * @param array $conditions array of conditions |
|
50 | + * @param array $relations |
|
51 | + * @param array $colunmns |
|
52 | + * @return object |
|
53 | + */ |
|
54 | + public function first($conditions, $relations = [], $columns = array('*')) |
|
55 | + { |
|
56 | 56 | $conditions = $this->constructConditions($conditions); |
57 | 57 | $report = call_user_func_array("{$this->getModel()}::with", array($relations))->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->first($columns); |
58 | 58 | |
59 | - if ( ! $report) |
|
60 | - { |
|
61 | - $error = \ErrorHandler::notFound('report'); |
|
62 | - abort($error['status'], $error['message']); |
|
63 | - } |
|
59 | + if ( ! $report) |
|
60 | + { |
|
61 | + $error = \ErrorHandler::notFound('report'); |
|
62 | + abort($error['status'], $error['message']); |
|
63 | + } |
|
64 | 64 | |
65 | - if ( ! \Core::users()->can($report->view_name, 'reports')) |
|
66 | - { |
|
67 | - $error = \ErrorHandler::noPermissions(); |
|
68 | - abort($error['status'], $error['message']); |
|
69 | - } |
|
65 | + if ( ! \Core::users()->can($report->view_name, 'reports')) |
|
66 | + { |
|
67 | + $error = \ErrorHandler::noPermissions(); |
|
68 | + abort($error['status'], $error['message']); |
|
69 | + } |
|
70 | 70 | |
71 | - return \DB::table($report->view_name)->get(); |
|
72 | - } |
|
71 | + return \DB::table($report->view_name)->get(); |
|
72 | + } |
|
73 | 73 | } |
@@ -18,7 +18,7 @@ |
||
18 | 18 | $table->string('view_name',100); |
19 | 19 | $table->softDeletes(); |
20 | 20 | $table->timestamps(); |
21 | - }); |
|
21 | + }); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |