@@ -29,6 +29,6 @@ |
||
29 | 29 | $group->permissions()->attach($permissionIds); |
30 | 30 | }); |
31 | 31 | |
32 | - return $this->find($groupId); |
|
32 | + return $this->find($groupId); |
|
33 | 33 | } |
34 | 34 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | */ |
24 | 24 | public function assignPermissions($groupId, $permissionIds) |
25 | 25 | { |
26 | - \DB::transaction(function () use ($groupId, $permissionIds) { |
|
26 | + \DB::transaction(function() use ($groupId, $permissionIds) { |
|
27 | 27 | $group = $this->find($groupId); |
28 | 28 | $group->permissions()->detach(); |
29 | 29 | $group->permissions()->attach($permissionIds); |
@@ -4,37 +4,37 @@ |
||
4 | 4 | |
5 | 5 | class OauthClientRepository 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\Acl\OauthClient'; |
|
15 | - } |
|
7 | + /** |
|
8 | + * Return the model full namespace. |
|
9 | + * |
|
10 | + * @return string |
|
11 | + */ |
|
12 | + protected function getModel() |
|
13 | + { |
|
14 | + return 'App\Modules\Acl\OauthClient'; |
|
15 | + } |
|
16 | 16 | |
17 | - /** |
|
18 | - * Revoke the given client. |
|
19 | - * |
|
20 | - * @param integer $clientId |
|
21 | - * @return void |
|
22 | - */ |
|
23 | - public function revoke($clientId) |
|
24 | - { |
|
25 | - $client = $this->find($clientId); |
|
26 | - $client->tokens()->update(['revoked' => true]); |
|
27 | - $this->save(['id'=> $clientId, 'revoked' => true]); |
|
28 | - } |
|
17 | + /** |
|
18 | + * Revoke the given client. |
|
19 | + * |
|
20 | + * @param integer $clientId |
|
21 | + * @return void |
|
22 | + */ |
|
23 | + public function revoke($clientId) |
|
24 | + { |
|
25 | + $client = $this->find($clientId); |
|
26 | + $client->tokens()->update(['revoked' => true]); |
|
27 | + $this->save(['id'=> $clientId, 'revoked' => true]); |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * Un revoke the given client. |
|
32 | - * |
|
33 | - * @param integer $clientId |
|
34 | - * @return void |
|
35 | - */ |
|
36 | - public function unRevoke($clientId) |
|
37 | - { |
|
38 | - $this->save(['id'=> $clientId, 'revoked' => false]); |
|
39 | - } |
|
30 | + /** |
|
31 | + * Un revoke the given client. |
|
32 | + * |
|
33 | + * @param integer $clientId |
|
34 | + * @return void |
|
35 | + */ |
|
36 | + public function unRevoke($clientId) |
|
37 | + { |
|
38 | + $this->save(['id'=> $clientId, 'revoked' => false]); |
|
39 | + } |
|
40 | 40 | } |
@@ -2,9 +2,9 @@ discard block |
||
2 | 2 | |
3 | 3 | class CoreConfig |
4 | 4 | { |
5 | - public function getConfig() |
|
6 | - { |
|
7 | - return [ |
|
5 | + public function getConfig() |
|
6 | + { |
|
7 | + return [ |
|
8 | 8 | /** |
9 | 9 | * Specify what relations should be used for every model. |
10 | 10 | */ |
@@ -133,5 +133,5 @@ discard block |
||
133 | 133 | ] |
134 | 134 | ] |
135 | 135 | ]; |
136 | - } |
|
136 | + } |
|
137 | 137 | } |
138 | 138 | \ No newline at end of file |
@@ -2,67 +2,67 @@ |
||
2 | 2 | |
3 | 3 | class Media |
4 | 4 | { |
5 | - /** |
|
6 | - * Upload the given image. |
|
7 | - * |
|
8 | - * @param object $image |
|
9 | - * @param string $dir |
|
10 | - * @return string |
|
11 | - */ |
|
12 | - public function uploadImage($image, $dir) |
|
13 | - { |
|
14 | - $response = []; |
|
15 | - $image = $image; |
|
16 | - $imageName = str_slug('image' . uniqid() . time() . '_' . $image->getClientOriginalName()); |
|
17 | - $destinationPath = 'media' . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR; |
|
5 | + /** |
|
6 | + * Upload the given image. |
|
7 | + * |
|
8 | + * @param object $image |
|
9 | + * @param string $dir |
|
10 | + * @return string |
|
11 | + */ |
|
12 | + public function uploadImage($image, $dir) |
|
13 | + { |
|
14 | + $response = []; |
|
15 | + $image = $image; |
|
16 | + $imageName = str_slug('image' . uniqid() . time() . '_' . $image->getClientOriginalName()); |
|
17 | + $destinationPath = 'media' . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR; |
|
18 | 18 | |
19 | - ! file_exists($destinationPath) ? \File::makeDirectory($destinationPath) : false; |
|
20 | - $image->move($destinationPath, $imageName); |
|
19 | + ! file_exists($destinationPath) ? \File::makeDirectory($destinationPath) : false; |
|
20 | + $image->move($destinationPath, $imageName); |
|
21 | 21 | |
22 | - return url($destinationPath . $imageName); |
|
23 | - } |
|
22 | + return url($destinationPath . $imageName); |
|
23 | + } |
|
24 | 24 | |
25 | - /** |
|
26 | - * Upload the given image. |
|
27 | - * |
|
28 | - * @param object $image |
|
29 | - * @param string $dir |
|
30 | - * @return string |
|
31 | - */ |
|
32 | - public function uploadImageBas64($image, $dir) |
|
33 | - { |
|
34 | - if (! strlen($image)) |
|
35 | - { |
|
36 | - return null; |
|
37 | - } |
|
25 | + /** |
|
26 | + * Upload the given image. |
|
27 | + * |
|
28 | + * @param object $image |
|
29 | + * @param string $dir |
|
30 | + * @return string |
|
31 | + */ |
|
32 | + public function uploadImageBas64($image, $dir) |
|
33 | + { |
|
34 | + if (! strlen($image)) |
|
35 | + { |
|
36 | + return null; |
|
37 | + } |
|
38 | 38 | |
39 | - $response = []; |
|
40 | - $image = $image; |
|
41 | - $imageName = 'image' . uniqid() . time() . '.jpg'; |
|
42 | - $destinationPath = 'media' . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR; |
|
39 | + $response = []; |
|
40 | + $image = $image; |
|
41 | + $imageName = 'image' . uniqid() . time() . '.jpg'; |
|
42 | + $destinationPath = 'media' . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR; |
|
43 | 43 | |
44 | - ! file_exists($destinationPath) ? \File::makeDirectory($destinationPath) : false; |
|
44 | + ! file_exists($destinationPath) ? \File::makeDirectory($destinationPath) : false; |
|
45 | 45 | |
46 | - $base = base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $image)); |
|
47 | - $image = \Image::make($base)->save($destinationPath . $imageName); |
|
46 | + $base = base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $image)); |
|
47 | + $image = \Image::make($base)->save($destinationPath . $imageName); |
|
48 | 48 | |
49 | - return url($destinationPath . $imageName); |
|
50 | - } |
|
49 | + return url($destinationPath . $imageName); |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Delete the given image. |
|
54 | - * |
|
55 | - * @param object $path |
|
56 | - * @param string $dir |
|
57 | - * @return void |
|
58 | - */ |
|
59 | - public function deleteImage($path, $dir) |
|
60 | - { |
|
61 | - $arr = explode('/', $path); |
|
62 | - $path = 'media' . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR . end($arr); |
|
63 | - if (\File::exists($path)) |
|
64 | - { |
|
65 | - \File::delete($path); |
|
66 | - } |
|
67 | - } |
|
52 | + /** |
|
53 | + * Delete the given image. |
|
54 | + * |
|
55 | + * @param object $path |
|
56 | + * @param string $dir |
|
57 | + * @return void |
|
58 | + */ |
|
59 | + public function deleteImage($path, $dir) |
|
60 | + { |
|
61 | + $arr = explode('/', $path); |
|
62 | + $path = 'media' . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR . end($arr); |
|
63 | + if (\File::exists($path)) |
|
64 | + { |
|
65 | + \File::delete($path); |
|
66 | + } |
|
67 | + } |
|
68 | 68 | } |
@@ -13,13 +13,13 @@ discard block |
||
13 | 13 | { |
14 | 14 | $response = []; |
15 | 15 | $image = $image; |
16 | - $imageName = str_slug('image' . uniqid() . time() . '_' . $image->getClientOriginalName()); |
|
17 | - $destinationPath = 'media' . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR; |
|
16 | + $imageName = str_slug('image'.uniqid().time().'_'.$image->getClientOriginalName()); |
|
17 | + $destinationPath = 'media'.DIRECTORY_SEPARATOR.$dir.DIRECTORY_SEPARATOR; |
|
18 | 18 | |
19 | 19 | ! file_exists($destinationPath) ? \File::makeDirectory($destinationPath) : false; |
20 | 20 | $image->move($destinationPath, $imageName); |
21 | 21 | |
22 | - return url($destinationPath . $imageName); |
|
22 | + return url($destinationPath.$imageName); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
@@ -31,22 +31,22 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function uploadImageBas64($image, $dir) |
33 | 33 | { |
34 | - if (! strlen($image)) |
|
34 | + if ( ! strlen($image)) |
|
35 | 35 | { |
36 | 36 | return null; |
37 | 37 | } |
38 | 38 | |
39 | 39 | $response = []; |
40 | 40 | $image = $image; |
41 | - $imageName = 'image' . uniqid() . time() . '.jpg'; |
|
42 | - $destinationPath = 'media' . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR; |
|
41 | + $imageName = 'image'.uniqid().time().'.jpg'; |
|
42 | + $destinationPath = 'media'.DIRECTORY_SEPARATOR.$dir.DIRECTORY_SEPARATOR; |
|
43 | 43 | |
44 | 44 | ! file_exists($destinationPath) ? \File::makeDirectory($destinationPath) : false; |
45 | 45 | |
46 | 46 | $base = base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $image)); |
47 | - $image = \Image::make($base)->save($destinationPath . $imageName); |
|
47 | + $image = \Image::make($base)->save($destinationPath.$imageName); |
|
48 | 48 | |
49 | - return url($destinationPath . $imageName); |
|
49 | + return url($destinationPath.$imageName); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | public function deleteImage($path, $dir) |
60 | 60 | { |
61 | 61 | $arr = explode('/', $path); |
62 | - $path = 'media' . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR . end($arr); |
|
62 | + $path = 'media'.DIRECTORY_SEPARATOR.$dir.DIRECTORY_SEPARATOR.end($arr); |
|
63 | 63 | if (\File::exists($path)) |
64 | 64 | { |
65 | 65 | \File::delete($path); |
@@ -2,117 +2,117 @@ |
||
2 | 2 | |
3 | 3 | class ErrorHandler |
4 | 4 | { |
5 | - public function unAuthorized() |
|
6 | - { |
|
7 | - $error = ['status' => 401, 'message' => trans('errors.unAuthorized')]; |
|
8 | - abort($error['status'], $error['message']); |
|
9 | - } |
|
10 | - |
|
11 | - public function invalidRefreshToken() |
|
12 | - { |
|
13 | - $error = ['status' => 400, 'message' => trans('errors.invalidRefreshToken')]; |
|
14 | - abort($error['status'], $error['message']); |
|
15 | - } |
|
16 | - |
|
17 | - public function noPermissions() |
|
18 | - { |
|
19 | - $error = ['status' => 403, 'message' => trans('errors.noPermissions')]; |
|
20 | - abort($error['status'], $error['message']); |
|
21 | - } |
|
22 | - |
|
23 | - public function loginFailed() |
|
24 | - { |
|
25 | - $error = ['status' => 400, 'message' => trans('errors.loginFailed')]; |
|
26 | - abort($error['status'], $error['message']); |
|
27 | - } |
|
28 | - |
|
29 | - public function noSocialEmail() |
|
30 | - { |
|
31 | - $error = ['status' => 400, 'message' => trans('errors.noSocialEmail')]; |
|
32 | - abort($error['status'], $error['message']); |
|
33 | - } |
|
34 | - |
|
35 | - public function userAlreadyRegistered() |
|
36 | - { |
|
37 | - $error = ['status' => 400, 'message' => trans('errors.userAlreadyRegistered')]; |
|
38 | - abort($error['status'], $error['message']); |
|
39 | - } |
|
40 | - |
|
41 | - public function connectionError() |
|
42 | - { |
|
43 | - $error = ['status' => 400, 'message' => trans('errors.connectionError')]; |
|
44 | - abort($error['status'], $error['message']); |
|
45 | - } |
|
46 | - |
|
47 | - public function redisNotRunning() |
|
48 | - { |
|
49 | - $error = ['status' => 400, 'message' => trans('errors.redisNotRunning')]; |
|
50 | - abort($error['status'], $error['message']); |
|
51 | - } |
|
52 | - |
|
53 | - public function dbQueryError() |
|
54 | - { |
|
55 | - $error = ['status' => 400, 'message' => trans('errors.dbQueryError')]; |
|
56 | - abort($error['status'], $error['message']); |
|
57 | - } |
|
58 | - |
|
59 | - public function cannotCreateSetting() |
|
60 | - { |
|
61 | - $error = ['status' => 400, 'message' => trans('errors.cannotCreateSetting')]; |
|
62 | - abort($error['status'], $error['message']); |
|
63 | - } |
|
64 | - |
|
65 | - public function cannotUpdateSettingKey() |
|
66 | - { |
|
67 | - $error = ['status' => 400, 'message' => trans('errors.cannotUpdateSettingKey')]; |
|
68 | - abort($error['status'], $error['message']); |
|
69 | - } |
|
70 | - |
|
71 | - public function userIsBlocked() |
|
72 | - { |
|
73 | - $error = ['status' => 403, 'message' => trans('errors.userIsBlocked')]; |
|
74 | - abort($error['status'], $error['message']); |
|
75 | - } |
|
76 | - |
|
77 | - public function emailNotConfirmed() |
|
78 | - { |
|
79 | - $error = ['status' => 403, 'message' => trans('errors.emailNotConfirmed')]; |
|
80 | - abort($error['status'], $error['message']); |
|
81 | - } |
|
82 | - |
|
83 | - public function emailAlreadyConfirmed() |
|
84 | - { |
|
85 | - $error = ['status' => 403, 'message' => trans('errors.emailAlreadyConfirmed')]; |
|
86 | - abort($error['status'], $error['message']); |
|
87 | - } |
|
88 | - |
|
89 | - public function invalidResetToken() |
|
90 | - { |
|
91 | - $error = ['status' => 400, 'message' => trans('errors.invalidResetToken')]; |
|
92 | - abort($error['status'], $error['message']); |
|
93 | - } |
|
94 | - |
|
95 | - public function invalidResetPassword() |
|
96 | - { |
|
97 | - $error = ['status' => 400, 'message' => trans('errors.invalidResetPassword')]; |
|
98 | - abort($error['status'], $error['message']); |
|
99 | - } |
|
100 | - |
|
101 | - public function invalidOldPassword() |
|
102 | - { |
|
103 | - $error = ['status' => 400, 'message' => trans('errors.invalidOldPassword')]; |
|
104 | - abort($error['status'], $error['message']); |
|
105 | - } |
|
106 | - |
|
107 | - public function notFound($text) |
|
108 | - { |
|
109 | - $error = ['status' => 404, 'message' => trans('errors.notFound', ['replace' => $text])]; |
|
110 | - abort($error['status'], $error['message']); |
|
111 | - } |
|
112 | - |
|
113 | - public function generalError() |
|
114 | - { |
|
115 | - $error = ['status' => 400, 'message' => trans('errors.generalError')]; |
|
116 | - abort($error['status'], $error['message']); |
|
117 | - } |
|
5 | + public function unAuthorized() |
|
6 | + { |
|
7 | + $error = ['status' => 401, 'message' => trans('errors.unAuthorized')]; |
|
8 | + abort($error['status'], $error['message']); |
|
9 | + } |
|
10 | + |
|
11 | + public function invalidRefreshToken() |
|
12 | + { |
|
13 | + $error = ['status' => 400, 'message' => trans('errors.invalidRefreshToken')]; |
|
14 | + abort($error['status'], $error['message']); |
|
15 | + } |
|
16 | + |
|
17 | + public function noPermissions() |
|
18 | + { |
|
19 | + $error = ['status' => 403, 'message' => trans('errors.noPermissions')]; |
|
20 | + abort($error['status'], $error['message']); |
|
21 | + } |
|
22 | + |
|
23 | + public function loginFailed() |
|
24 | + { |
|
25 | + $error = ['status' => 400, 'message' => trans('errors.loginFailed')]; |
|
26 | + abort($error['status'], $error['message']); |
|
27 | + } |
|
28 | + |
|
29 | + public function noSocialEmail() |
|
30 | + { |
|
31 | + $error = ['status' => 400, 'message' => trans('errors.noSocialEmail')]; |
|
32 | + abort($error['status'], $error['message']); |
|
33 | + } |
|
34 | + |
|
35 | + public function userAlreadyRegistered() |
|
36 | + { |
|
37 | + $error = ['status' => 400, 'message' => trans('errors.userAlreadyRegistered')]; |
|
38 | + abort($error['status'], $error['message']); |
|
39 | + } |
|
40 | + |
|
41 | + public function connectionError() |
|
42 | + { |
|
43 | + $error = ['status' => 400, 'message' => trans('errors.connectionError')]; |
|
44 | + abort($error['status'], $error['message']); |
|
45 | + } |
|
46 | + |
|
47 | + public function redisNotRunning() |
|
48 | + { |
|
49 | + $error = ['status' => 400, 'message' => trans('errors.redisNotRunning')]; |
|
50 | + abort($error['status'], $error['message']); |
|
51 | + } |
|
52 | + |
|
53 | + public function dbQueryError() |
|
54 | + { |
|
55 | + $error = ['status' => 400, 'message' => trans('errors.dbQueryError')]; |
|
56 | + abort($error['status'], $error['message']); |
|
57 | + } |
|
58 | + |
|
59 | + public function cannotCreateSetting() |
|
60 | + { |
|
61 | + $error = ['status' => 400, 'message' => trans('errors.cannotCreateSetting')]; |
|
62 | + abort($error['status'], $error['message']); |
|
63 | + } |
|
64 | + |
|
65 | + public function cannotUpdateSettingKey() |
|
66 | + { |
|
67 | + $error = ['status' => 400, 'message' => trans('errors.cannotUpdateSettingKey')]; |
|
68 | + abort($error['status'], $error['message']); |
|
69 | + } |
|
70 | + |
|
71 | + public function userIsBlocked() |
|
72 | + { |
|
73 | + $error = ['status' => 403, 'message' => trans('errors.userIsBlocked')]; |
|
74 | + abort($error['status'], $error['message']); |
|
75 | + } |
|
76 | + |
|
77 | + public function emailNotConfirmed() |
|
78 | + { |
|
79 | + $error = ['status' => 403, 'message' => trans('errors.emailNotConfirmed')]; |
|
80 | + abort($error['status'], $error['message']); |
|
81 | + } |
|
82 | + |
|
83 | + public function emailAlreadyConfirmed() |
|
84 | + { |
|
85 | + $error = ['status' => 403, 'message' => trans('errors.emailAlreadyConfirmed')]; |
|
86 | + abort($error['status'], $error['message']); |
|
87 | + } |
|
88 | + |
|
89 | + public function invalidResetToken() |
|
90 | + { |
|
91 | + $error = ['status' => 400, 'message' => trans('errors.invalidResetToken')]; |
|
92 | + abort($error['status'], $error['message']); |
|
93 | + } |
|
94 | + |
|
95 | + public function invalidResetPassword() |
|
96 | + { |
|
97 | + $error = ['status' => 400, 'message' => trans('errors.invalidResetPassword')]; |
|
98 | + abort($error['status'], $error['message']); |
|
99 | + } |
|
100 | + |
|
101 | + public function invalidOldPassword() |
|
102 | + { |
|
103 | + $error = ['status' => 400, 'message' => trans('errors.invalidOldPassword')]; |
|
104 | + abort($error['status'], $error['message']); |
|
105 | + } |
|
106 | + |
|
107 | + public function notFound($text) |
|
108 | + { |
|
109 | + $error = ['status' => 404, 'message' => trans('errors.notFound', ['replace' => $text])]; |
|
110 | + abort($error['status'], $error['message']); |
|
111 | + } |
|
112 | + |
|
113 | + public function generalError() |
|
114 | + { |
|
115 | + $error = ['status' => 400, 'message' => trans('errors.generalError')]; |
|
116 | + abort($error['status'], $error['message']); |
|
117 | + } |
|
118 | 118 | } |
119 | 119 | \ No newline at end of file |
@@ -8,72 +8,72 @@ |
||
8 | 8 | class RouteServiceProvider extends ServiceProvider |
9 | 9 | { |
10 | 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\Core\Http\Controllers'; |
|
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\Core\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('core', '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('core', '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('core', '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('core', 'Routes/api.php'); |
|
77 | + }); |
|
78 | + } |
|
79 | 79 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | Route::group([ |
55 | 55 | 'middleware' => 'web', |
56 | 56 | 'namespace' => $this->namespace, |
57 | - ], function ($router) { |
|
57 | + ], function($router) { |
|
58 | 58 | require module_path('core', 'Routes/web.php'); |
59 | 59 | }); |
60 | 60 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | 'middleware' => 'api', |
73 | 73 | 'namespace' => $this->namespace, |
74 | 74 | 'prefix' => 'api', |
75 | - ], function ($router) { |
|
75 | + ], function($router) { |
|
76 | 76 | require module_path('core', 'Routes/api.php'); |
77 | 77 | }); |
78 | 78 | } |
@@ -7,75 +7,75 @@ |
||
7 | 7 | class ModuleServiceProvider extends ServiceProvider |
8 | 8 | { |
9 | 9 | /** |
10 | - * Bootstrap the module services. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function boot() |
|
15 | - { |
|
16 | - $this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'core'); |
|
17 | - $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'core'); |
|
10 | + * Bootstrap the module services. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function boot() |
|
15 | + { |
|
16 | + $this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'core'); |
|
17 | + $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'core'); |
|
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 | - //Bind Core Facade to the IoC Container |
|
31 | - \App::bind('Core', function() |
|
32 | - { |
|
33 | - return new \App\Modules\Core\Core; |
|
34 | - }); |
|
23 | + /** |
|
24 | + * Register the module services. |
|
25 | + * |
|
26 | + * @return void |
|
27 | + */ |
|
28 | + public function register() |
|
29 | + { |
|
30 | + //Bind Core Facade to the IoC Container |
|
31 | + \App::bind('Core', function() |
|
32 | + { |
|
33 | + return new \App\Modules\Core\Core; |
|
34 | + }); |
|
35 | 35 | |
36 | - //Bind ErrorHandler Facade to the IoC Container |
|
37 | - \App::bind('ErrorHandler', function() |
|
38 | - { |
|
39 | - return new \App\Modules\Core\Utl\ErrorHandler; |
|
40 | - }); |
|
36 | + //Bind ErrorHandler Facade to the IoC Container |
|
37 | + \App::bind('ErrorHandler', function() |
|
38 | + { |
|
39 | + return new \App\Modules\Core\Utl\ErrorHandler; |
|
40 | + }); |
|
41 | 41 | |
42 | - //Bind CoreConfig Facade to the IoC Container |
|
43 | - \App::bind('CoreConfig', function() |
|
44 | - { |
|
45 | - return new \App\Modules\Core\Utl\CoreConfig; |
|
46 | - }); |
|
42 | + //Bind CoreConfig Facade to the IoC Container |
|
43 | + \App::bind('CoreConfig', function() |
|
44 | + { |
|
45 | + return new \App\Modules\Core\Utl\CoreConfig; |
|
46 | + }); |
|
47 | 47 | |
48 | - //Bind Mpgs Facade to the IoC Container |
|
49 | - \App::bind('Media', function() |
|
50 | - { |
|
51 | - return new \App\Modules\Core\Utl\Media; |
|
52 | - }); |
|
48 | + //Bind Mpgs Facade to the IoC Container |
|
49 | + \App::bind('Media', function() |
|
50 | + { |
|
51 | + return new \App\Modules\Core\Utl\Media; |
|
52 | + }); |
|
53 | 53 | |
54 | - \Validator::extend('base64image', function ($attribute, $value, $parameters, $validator) { |
|
55 | - $explode = explode(',', $value); |
|
56 | - $allow = ['png', 'jpg', 'svg']; |
|
57 | - $format = str_replace( |
|
58 | - [ |
|
59 | - 'data:image/', |
|
60 | - ';', |
|
61 | - 'base64', |
|
62 | - ], |
|
63 | - [ |
|
64 | - '', '', '', |
|
65 | - ], |
|
66 | - $explode[0] |
|
67 | - ); |
|
68 | - // check file format |
|
69 | - if (!in_array($format, $allow)) { |
|
70 | - return false; |
|
71 | - } |
|
72 | - // check base64 format |
|
73 | - if (!preg_match('%^[a-zA-Z0-9/+]*={0,2}$%', $explode[1])) { |
|
74 | - return false; |
|
75 | - } |
|
76 | - return true; |
|
77 | - }); |
|
54 | + \Validator::extend('base64image', function ($attribute, $value, $parameters, $validator) { |
|
55 | + $explode = explode(',', $value); |
|
56 | + $allow = ['png', 'jpg', 'svg']; |
|
57 | + $format = str_replace( |
|
58 | + [ |
|
59 | + 'data:image/', |
|
60 | + ';', |
|
61 | + 'base64', |
|
62 | + ], |
|
63 | + [ |
|
64 | + '', '', '', |
|
65 | + ], |
|
66 | + $explode[0] |
|
67 | + ); |
|
68 | + // check file format |
|
69 | + if (!in_array($format, $allow)) { |
|
70 | + return false; |
|
71 | + } |
|
72 | + // check base64 format |
|
73 | + if (!preg_match('%^[a-zA-Z0-9/+]*={0,2}$%', $explode[1])) { |
|
74 | + return false; |
|
75 | + } |
|
76 | + return true; |
|
77 | + }); |
|
78 | 78 | |
79 | - $this->app->register(RouteServiceProvider::class); |
|
80 | - } |
|
79 | + $this->app->register(RouteServiceProvider::class); |
|
80 | + } |
|
81 | 81 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | return new \App\Modules\Core\Utl\Media; |
52 | 52 | }); |
53 | 53 | |
54 | - \Validator::extend('base64image', function ($attribute, $value, $parameters, $validator) { |
|
54 | + \Validator::extend('base64image', function($attribute, $value, $parameters, $validator) { |
|
55 | 55 | $explode = explode(',', $value); |
56 | 56 | $allow = ['png', 'jpg', 'svg']; |
57 | 57 | $format = str_replace( |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | $explode[0] |
67 | 67 | ); |
68 | 68 | // check file format |
69 | - if (!in_array($format, $allow)) { |
|
69 | + if ( ! in_array($format, $allow)) { |
|
70 | 70 | return false; |
71 | 71 | } |
72 | 72 | // check base64 format |
73 | - if (!preg_match('%^[a-zA-Z0-9/+]*={0,2}$%', $explode[1])) { |
|
73 | + if ( ! preg_match('%^[a-zA-Z0-9/+]*={0,2}$%', $explode[1])) { |
|
74 | 74 | return false; |
75 | 75 | } |
76 | 76 | return true; |
@@ -2,117 +2,117 @@ |
||
2 | 2 | |
3 | 3 | class CachingDecorator |
4 | 4 | { |
5 | - /** |
|
6 | - * The repo implementation. |
|
7 | - * |
|
8 | - * @var string |
|
9 | - */ |
|
10 | - public $repo; |
|
5 | + /** |
|
6 | + * The repo implementation. |
|
7 | + * |
|
8 | + * @var string |
|
9 | + */ |
|
10 | + public $repo; |
|
11 | 11 | |
12 | - /** |
|
13 | - * The cache implementation. |
|
14 | - * |
|
15 | - * @var object |
|
16 | - */ |
|
17 | - protected $cache; |
|
12 | + /** |
|
13 | + * The cache implementation. |
|
14 | + * |
|
15 | + * @var object |
|
16 | + */ |
|
17 | + protected $cache; |
|
18 | 18 | |
19 | - /** |
|
20 | - * The modelKey implementation. |
|
21 | - * |
|
22 | - * @var string |
|
23 | - */ |
|
24 | - public $modelKey; |
|
19 | + /** |
|
20 | + * The modelKey implementation. |
|
21 | + * |
|
22 | + * @var string |
|
23 | + */ |
|
24 | + public $modelKey; |
|
25 | 25 | |
26 | - /** |
|
27 | - * The model implementation. |
|
28 | - * |
|
29 | - * @var string |
|
30 | - */ |
|
31 | - public $model; |
|
26 | + /** |
|
27 | + * The model implementation. |
|
28 | + * |
|
29 | + * @var string |
|
30 | + */ |
|
31 | + public $model; |
|
32 | 32 | |
33 | - /** |
|
34 | - * The modelClass implementation. |
|
35 | - * |
|
36 | - * @var string |
|
37 | - */ |
|
38 | - public $modelClass; |
|
33 | + /** |
|
34 | + * The modelClass implementation. |
|
35 | + * |
|
36 | + * @var string |
|
37 | + */ |
|
38 | + public $modelClass; |
|
39 | 39 | |
40 | - /** |
|
41 | - * The cacheConfig implementation. |
|
42 | - * |
|
43 | - * @var array |
|
44 | - */ |
|
45 | - public $cacheConfig; |
|
40 | + /** |
|
41 | + * The cacheConfig implementation. |
|
42 | + * |
|
43 | + * @var array |
|
44 | + */ |
|
45 | + public $cacheConfig; |
|
46 | 46 | |
47 | - /** |
|
48 | - * The cacheTag implementation. |
|
49 | - * |
|
50 | - * @var string |
|
51 | - */ |
|
52 | - public $cacheTag; |
|
47 | + /** |
|
48 | + * The cacheTag implementation. |
|
49 | + * |
|
50 | + * @var string |
|
51 | + */ |
|
52 | + public $cacheTag; |
|
53 | 53 | |
54 | - /** |
|
55 | - * Create new CachingDecorator instance. |
|
56 | - */ |
|
57 | - public function __construct($repo, $cache) |
|
58 | - { |
|
59 | - $this->repo = $repo; |
|
60 | - $this->cache = $cache; |
|
61 | - $this->model = $this->repo->model; |
|
62 | - $this->modelClass = get_class($this->model); |
|
63 | - $repoClass = explode('\\', get_class($this->repo)); |
|
64 | - $repoName = end($repoClass); |
|
65 | - $this->cacheTag = str_plural(lcfirst(substr($repoName, 0, strpos($repoName, 'Repository')))); |
|
66 | - } |
|
54 | + /** |
|
55 | + * Create new CachingDecorator instance. |
|
56 | + */ |
|
57 | + public function __construct($repo, $cache) |
|
58 | + { |
|
59 | + $this->repo = $repo; |
|
60 | + $this->cache = $cache; |
|
61 | + $this->model = $this->repo->model; |
|
62 | + $this->modelClass = get_class($this->model); |
|
63 | + $repoClass = explode('\\', get_class($this->repo)); |
|
64 | + $repoName = end($repoClass); |
|
65 | + $this->cacheTag = str_plural(lcfirst(substr($repoName, 0, strpos($repoName, 'Repository')))); |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * Handle the cache mechanism for the called method |
|
70 | - * based the configurations. |
|
71 | - * |
|
72 | - * @param string $name the called method name |
|
73 | - * @param array $arguments the method arguments |
|
74 | - * @return object |
|
75 | - */ |
|
76 | - public function __call($name, $arguments) |
|
77 | - { |
|
78 | - $this->setCacheConfig($name); |
|
68 | + /** |
|
69 | + * Handle the cache mechanism for the called method |
|
70 | + * based the configurations. |
|
71 | + * |
|
72 | + * @param string $name the called method name |
|
73 | + * @param array $arguments the method arguments |
|
74 | + * @return object |
|
75 | + */ |
|
76 | + public function __call($name, $arguments) |
|
77 | + { |
|
78 | + $this->setCacheConfig($name); |
|
79 | 79 | |
80 | - if ($this->cacheConfig && $this->cacheConfig == 'cache') |
|
81 | - { |
|
82 | - $page = \Request::get('page') !== null ? \Request::get('page') : '1'; |
|
83 | - $cacheKey = $name . $page . \Session::get('locale') . serialize($arguments); |
|
84 | - return $this->cache->tags([$this->cacheTag])->rememberForever($cacheKey, function() use ($arguments, $name) { |
|
85 | - return call_user_func_array([$this->repo, $name], $arguments); |
|
86 | - }); |
|
87 | - } |
|
88 | - else if ($this->cacheConfig) |
|
89 | - { |
|
90 | - $this->cache->tags($this->cacheConfig)->flush(); |
|
91 | - return call_user_func_array([$this->repo, $name], $arguments); |
|
92 | - } |
|
80 | + if ($this->cacheConfig && $this->cacheConfig == 'cache') |
|
81 | + { |
|
82 | + $page = \Request::get('page') !== null ? \Request::get('page') : '1'; |
|
83 | + $cacheKey = $name . $page . \Session::get('locale') . serialize($arguments); |
|
84 | + return $this->cache->tags([$this->cacheTag])->rememberForever($cacheKey, function() use ($arguments, $name) { |
|
85 | + return call_user_func_array([$this->repo, $name], $arguments); |
|
86 | + }); |
|
87 | + } |
|
88 | + else if ($this->cacheConfig) |
|
89 | + { |
|
90 | + $this->cache->tags($this->cacheConfig)->flush(); |
|
91 | + return call_user_func_array([$this->repo, $name], $arguments); |
|
92 | + } |
|
93 | 93 | |
94 | - return call_user_func_array([$this->repo, $name], $arguments); |
|
95 | - } |
|
94 | + return call_user_func_array([$this->repo, $name], $arguments); |
|
95 | + } |
|
96 | 96 | |
97 | - /** |
|
98 | - * Set cache config based on the called method. |
|
99 | - * |
|
100 | - * @param string $name |
|
101 | - * @return void |
|
102 | - */ |
|
103 | - private function setCacheConfig($name) |
|
104 | - { |
|
105 | - $config = \CoreConfig::getConfig(); |
|
106 | - $cacheConfig = array_key_exists($this->cacheTag, $config['cacheConfig']) ? $config['cacheConfig'][$this->cacheTag] : false; |
|
107 | - $this->cacheConfig = false; |
|
97 | + /** |
|
98 | + * Set cache config based on the called method. |
|
99 | + * |
|
100 | + * @param string $name |
|
101 | + * @return void |
|
102 | + */ |
|
103 | + private function setCacheConfig($name) |
|
104 | + { |
|
105 | + $config = \CoreConfig::getConfig(); |
|
106 | + $cacheConfig = array_key_exists($this->cacheTag, $config['cacheConfig']) ? $config['cacheConfig'][$this->cacheTag] : false; |
|
107 | + $this->cacheConfig = false; |
|
108 | 108 | |
109 | - if ($cacheConfig && in_array($name, $cacheConfig['cache'])) |
|
110 | - { |
|
111 | - $this->cacheConfig = 'cache'; |
|
112 | - } |
|
113 | - else if ($cacheConfig && isset($cacheConfig['clear'][$name])) |
|
114 | - { |
|
115 | - $this->cacheConfig = $cacheConfig['clear'][$name]; |
|
116 | - } |
|
117 | - } |
|
109 | + if ($cacheConfig && in_array($name, $cacheConfig['cache'])) |
|
110 | + { |
|
111 | + $this->cacheConfig = 'cache'; |
|
112 | + } |
|
113 | + else if ($cacheConfig && isset($cacheConfig['clear'][$name])) |
|
114 | + { |
|
115 | + $this->cacheConfig = $cacheConfig['clear'][$name]; |
|
116 | + } |
|
117 | + } |
|
118 | 118 | } |
119 | 119 | \ No newline at end of file |
@@ -64,7 +64,7 @@ |
||
64 | 64 | if ($this->cacheConfig && $this->cacheConfig == 'cache') |
65 | 65 | { |
66 | 66 | $page = \Request::get('page') !== null ? \Request::get('page') : '1'; |
67 | - $cacheKey = $name . $page . \Session::get('locale') . serialize($arguments); |
|
67 | + $cacheKey = $name.$page.\Session::get('locale').serialize($arguments); |
|
68 | 68 | return $this->cache->tags([$this->cacheTag])->rememberForever($cacheKey, function() use ($arguments, $name) { |
69 | 69 | return call_user_func_array([$this->repo, $name], $arguments); |
70 | 70 | }); |
@@ -68,8 +68,7 @@ discard block |
||
68 | 68 | return $this->cache->tags([$this->cacheTag])->rememberForever($cacheKey, function() use ($arguments, $name) { |
69 | 69 | return call_user_func_array([$this->repo, $name], $arguments); |
70 | 70 | }); |
71 | - } |
|
72 | - else if ($this->cacheConfig) |
|
71 | + } else if ($this->cacheConfig) |
|
73 | 72 | { |
74 | 73 | $this->cache->tags($this->cacheConfig)->flush(); |
75 | 74 | return call_user_func_array([$this->repo, $name], $arguments); |
@@ -93,8 +92,7 @@ discard block |
||
93 | 92 | if ($cacheConfig && in_array($name, $cacheConfig['cache'])) |
94 | 93 | { |
95 | 94 | $this->cacheConfig = 'cache'; |
96 | - } |
|
97 | - else if ($cacheConfig && isset($cacheConfig['clear'][$name])) |
|
95 | + } else if ($cacheConfig && isset($cacheConfig['clear'][$name])) |
|
98 | 96 | { |
99 | 97 | $this->cacheConfig = $cacheConfig['clear'][$name]; |
100 | 98 | } |
@@ -2,51 +2,51 @@ |
||
2 | 2 | |
3 | 3 | trait Translatable |
4 | 4 | { |
5 | - /** |
|
6 | - * Create a new model instance that is existing. |
|
7 | - * |
|
8 | - * @param array $attributes |
|
9 | - * @param string|null $connection |
|
10 | - * @return static |
|
11 | - */ |
|
12 | - public function newFromBuilder($attributes = [], $connection = null) |
|
13 | - { |
|
14 | - $model = parent::newFromBuilder($attributes, $connection); |
|
5 | + /** |
|
6 | + * Create a new model instance that is existing. |
|
7 | + * |
|
8 | + * @param array $attributes |
|
9 | + * @param string|null $connection |
|
10 | + * @return static |
|
11 | + */ |
|
12 | + public function newFromBuilder($attributes = [], $connection = null) |
|
13 | + { |
|
14 | + $model = parent::newFromBuilder($attributes, $connection); |
|
15 | 15 | |
16 | - foreach ($model->attributes AS $key => $value) |
|
17 | - { |
|
18 | - if (isset($this->translatable) && in_array($key, $this->translatable)) |
|
19 | - { |
|
20 | - $model->$key = $this->getTranslatedAttribute($key, $value); |
|
21 | - } |
|
22 | - } |
|
16 | + foreach ($model->attributes AS $key => $value) |
|
17 | + { |
|
18 | + if (isset($this->translatable) && in_array($key, $this->translatable)) |
|
19 | + { |
|
20 | + $model->$key = $this->getTranslatedAttribute($key, $value); |
|
21 | + } |
|
22 | + } |
|
23 | 23 | |
24 | - return $model; |
|
25 | - } |
|
24 | + return $model; |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * Returns a translatable model attribute based on the application's locale settings. |
|
29 | - * |
|
30 | - * @param $key |
|
31 | - * @param $values |
|
32 | - * @return string |
|
33 | - */ |
|
34 | - protected function getTranslatedAttribute($key, $values) |
|
35 | - { |
|
36 | - $values = json_decode($values); |
|
37 | - $primaryLocale = \Session::get('locale'); |
|
38 | - $fallbackLocale = 'en'; |
|
27 | + /** |
|
28 | + * Returns a translatable model attribute based on the application's locale settings. |
|
29 | + * |
|
30 | + * @param $key |
|
31 | + * @param $values |
|
32 | + * @return string |
|
33 | + */ |
|
34 | + protected function getTranslatedAttribute($key, $values) |
|
35 | + { |
|
36 | + $values = json_decode($values); |
|
37 | + $primaryLocale = \Session::get('locale'); |
|
38 | + $fallbackLocale = 'en'; |
|
39 | 39 | |
40 | - if ($primaryLocale == 'all') |
|
41 | - { |
|
42 | - return $values; |
|
43 | - } |
|
40 | + if ($primaryLocale == 'all') |
|
41 | + { |
|
42 | + return $values; |
|
43 | + } |
|
44 | 44 | |
45 | - if ( ! $primaryLocale || ! is_object($values) || ! property_exists($values, $primaryLocale)) |
|
46 | - { |
|
47 | - return $values ? isset($values->$fallbackLocale) ? $values->$fallbackLocale : $values : ''; |
|
48 | - } |
|
45 | + if ( ! $primaryLocale || ! is_object($values) || ! property_exists($values, $primaryLocale)) |
|
46 | + { |
|
47 | + return $values ? isset($values->$fallbackLocale) ? $values->$fallbackLocale : $values : ''; |
|
48 | + } |
|
49 | 49 | |
50 | - return $primaryLocale == 'all' ? $values : $values->$primaryLocale; |
|
51 | - } |
|
50 | + return $primaryLocale == 'all' ? $values : $values->$primaryLocale; |
|
51 | + } |
|
52 | 52 | } |
53 | 53 | \ No newline at end of file |