@@ -11,68 +11,68 @@ |
||
11 | 11 | |
12 | 12 | class CheckPermissions |
13 | 13 | { |
14 | - protected $route; |
|
15 | - protected $auth; |
|
16 | - protected $authMiddleware; |
|
17 | - protected $userService; |
|
18 | - protected $arr; |
|
14 | + protected $route; |
|
15 | + protected $auth; |
|
16 | + protected $authMiddleware; |
|
17 | + protected $userService; |
|
18 | + protected $arr; |
|
19 | 19 | |
20 | - /** |
|
21 | - * Init new object. |
|
22 | - * |
|
23 | - * @param Route $route |
|
24 | - * @param Auth $auth |
|
25 | - * @param AuthMiddleware $authMiddleware |
|
26 | - * @param UserService $userService |
|
27 | - * @param Arr $arr |
|
28 | - * |
|
29 | - * @return void |
|
30 | - */ |
|
31 | - public function __construct(Route $route, Auth $auth, AuthMiddleware $authMiddleware, UserService $userService, Arr $arr) |
|
32 | - { |
|
33 | - $this->route = $route; |
|
34 | - $this->auth = $auth; |
|
35 | - $this->authMiddleware = $authMiddleware; |
|
36 | - $this->userService = $userService; |
|
37 | - $this->arr = $arr; |
|
38 | - } |
|
20 | + /** |
|
21 | + * Init new object. |
|
22 | + * |
|
23 | + * @param Route $route |
|
24 | + * @param Auth $auth |
|
25 | + * @param AuthMiddleware $authMiddleware |
|
26 | + * @param UserService $userService |
|
27 | + * @param Arr $arr |
|
28 | + * |
|
29 | + * @return void |
|
30 | + */ |
|
31 | + public function __construct(Route $route, Auth $auth, AuthMiddleware $authMiddleware, UserService $userService, Arr $arr) |
|
32 | + { |
|
33 | + $this->route = $route; |
|
34 | + $this->auth = $auth; |
|
35 | + $this->authMiddleware = $authMiddleware; |
|
36 | + $this->userService = $userService; |
|
37 | + $this->arr = $arr; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * Handle an incoming request. |
|
42 | - * |
|
43 | - * @param \Illuminate\Http\Request $request |
|
44 | - * @param \Closure $next |
|
45 | - * @return mixed |
|
46 | - */ |
|
47 | - public function handle($request, Closure $next) |
|
48 | - { |
|
49 | - $routeActions = explode('@', $this->route->currentRouteAction()); |
|
50 | - $reflectionClass = new \ReflectionClass($routeActions[0]); |
|
51 | - $classProperties = $reflectionClass->getDefaultProperties(); |
|
52 | - $skipPermissionCheck = $this->arr->get($classProperties, 'skipPermissionCheck', []); |
|
53 | - $skipLoginCheck = $this->arr->get($classProperties, 'skipLoginCheck', []); |
|
54 | - $modelName = explode('\\', $routeActions[0]); |
|
55 | - $modelName = lcfirst(str_replace('Controller', '', end($modelName))); |
|
56 | - $permission = $routeActions[1]; |
|
40 | + /** |
|
41 | + * Handle an incoming request. |
|
42 | + * |
|
43 | + * @param \Illuminate\Http\Request $request |
|
44 | + * @param \Closure $next |
|
45 | + * @return mixed |
|
46 | + */ |
|
47 | + public function handle($request, Closure $next) |
|
48 | + { |
|
49 | + $routeActions = explode('@', $this->route->currentRouteAction()); |
|
50 | + $reflectionClass = new \ReflectionClass($routeActions[0]); |
|
51 | + $classProperties = $reflectionClass->getDefaultProperties(); |
|
52 | + $skipPermissionCheck = $this->arr->get($classProperties, 'skipPermissionCheck', []); |
|
53 | + $skipLoginCheck = $this->arr->get($classProperties, 'skipLoginCheck', []); |
|
54 | + $modelName = explode('\\', $routeActions[0]); |
|
55 | + $modelName = lcfirst(str_replace('Controller', '', end($modelName))); |
|
56 | + $permission = $routeActions[1]; |
|
57 | 57 | |
58 | - $this->auth->shouldUse('api'); |
|
59 | - if (! in_array($permission, $skipLoginCheck)) { |
|
60 | - $this->authMiddleware->handle($request, function ($request) use ($modelName, $skipPermissionCheck, $skipLoginCheck, $permission) { |
|
61 | - $user = $this->auth->user(); |
|
62 | - $isPasswordClient = $user->token()->client->password_client; |
|
58 | + $this->auth->shouldUse('api'); |
|
59 | + if (! in_array($permission, $skipLoginCheck)) { |
|
60 | + $this->authMiddleware->handle($request, function ($request) use ($modelName, $skipPermissionCheck, $skipLoginCheck, $permission) { |
|
61 | + $user = $this->auth->user(); |
|
62 | + $isPasswordClient = $user->token()->client->password_client; |
|
63 | 63 | |
64 | - if ($user->blocked) { |
|
65 | - \Errors::userIsBlocked(); |
|
66 | - } |
|
64 | + if ($user->blocked) { |
|
65 | + \Errors::userIsBlocked(); |
|
66 | + } |
|
67 | 67 | |
68 | - if ($isPasswordClient && (in_array($permission, $skipPermissionCheck) || $this->userService->can($permission, $modelName))) { |
|
69 | - } elseif (! $isPasswordClient && $user->tokenCan($modelName.'-'.$permission)) { |
|
70 | - } else { |
|
71 | - \Errors::noPermissions(); |
|
72 | - } |
|
73 | - }); |
|
74 | - } |
|
68 | + if ($isPasswordClient && (in_array($permission, $skipPermissionCheck) || $this->userService->can($permission, $modelName))) { |
|
69 | + } elseif (! $isPasswordClient && $user->tokenCan($modelName.'-'.$permission)) { |
|
70 | + } else { |
|
71 | + \Errors::noPermissions(); |
|
72 | + } |
|
73 | + }); |
|
74 | + } |
|
75 | 75 | |
76 | - return $next($request); |
|
77 | - } |
|
76 | + return $next($request); |
|
77 | + } |
|
78 | 78 | } |
@@ -8,53 +8,53 @@ |
||
8 | 8 | |
9 | 9 | class UpdateLocaleAndTimezone |
10 | 10 | { |
11 | - protected $session; |
|
12 | - protected $auth; |
|
11 | + protected $session; |
|
12 | + protected $auth; |
|
13 | 13 | |
14 | - /** |
|
15 | - * Init new object. |
|
16 | - * |
|
17 | - * @param Session $session |
|
18 | - * @param Auth $auth |
|
19 | - * @param Errors $errors |
|
20 | - * |
|
21 | - * @return void |
|
22 | - */ |
|
23 | - public function __construct(Session $session, Auth $auth) |
|
24 | - { |
|
25 | - $this->session = $session; |
|
26 | - $this->auth = $auth; |
|
27 | - } |
|
14 | + /** |
|
15 | + * Init new object. |
|
16 | + * |
|
17 | + * @param Session $session |
|
18 | + * @param Auth $auth |
|
19 | + * @param Errors $errors |
|
20 | + * |
|
21 | + * @return void |
|
22 | + */ |
|
23 | + public function __construct(Session $session, Auth $auth) |
|
24 | + { |
|
25 | + $this->session = $session; |
|
26 | + $this->auth = $auth; |
|
27 | + } |
|
28 | 28 | |
29 | - /** |
|
30 | - * Handle an incoming request. |
|
31 | - * |
|
32 | - * @param \Illuminate\Http\Request $request |
|
33 | - * @param \Closure $next |
|
34 | - * @return mixed |
|
35 | - */ |
|
36 | - public function handle($request, Closure $next) |
|
37 | - { |
|
38 | - $update = false; |
|
39 | - $user = $this->auth->user(); |
|
40 | - if ($user) { |
|
41 | - $locale = $this->session->get('locale'); |
|
42 | - $timezone = $this->session->get('time-zone'); |
|
43 | - if ($locale && $locale !== 'all' && $locale !== $user->locale) { |
|
44 | - $user->locale = $locale; |
|
45 | - $update = true; |
|
46 | - } |
|
29 | + /** |
|
30 | + * Handle an incoming request. |
|
31 | + * |
|
32 | + * @param \Illuminate\Http\Request $request |
|
33 | + * @param \Closure $next |
|
34 | + * @return mixed |
|
35 | + */ |
|
36 | + public function handle($request, Closure $next) |
|
37 | + { |
|
38 | + $update = false; |
|
39 | + $user = $this->auth->user(); |
|
40 | + if ($user) { |
|
41 | + $locale = $this->session->get('locale'); |
|
42 | + $timezone = $this->session->get('time-zone'); |
|
43 | + if ($locale && $locale !== 'all' && $locale !== $user->locale) { |
|
44 | + $user->locale = $locale; |
|
45 | + $update = true; |
|
46 | + } |
|
47 | 47 | |
48 | - if ($timezone && $timezone !== $user->timezone) { |
|
49 | - $user->timezone = $timezone; |
|
50 | - $update = true; |
|
51 | - } |
|
48 | + if ($timezone && $timezone !== $user->timezone) { |
|
49 | + $user->timezone = $timezone; |
|
50 | + $update = true; |
|
51 | + } |
|
52 | 52 | |
53 | - if ($update) { |
|
54 | - $user->save(); |
|
55 | - } |
|
56 | - } |
|
53 | + if ($update) { |
|
54 | + $user->save(); |
|
55 | + } |
|
56 | + } |
|
57 | 57 | |
58 | - return $next($request); |
|
59 | - } |
|
58 | + return $next($request); |
|
59 | + } |
|
60 | 60 | } |
@@ -4,8 +4,8 @@ |
||
4 | 4 | |
5 | 5 | class Errors extends Facade |
6 | 6 | { |
7 | - protected static function getFacadeAccessor() |
|
8 | - { |
|
9 | - return 'Errors'; |
|
10 | - } |
|
7 | + protected static function getFacadeAccessor() |
|
8 | + { |
|
9 | + return 'Errors'; |
|
10 | + } |
|
11 | 11 | } |
@@ -2,123 +2,123 @@ |
||
2 | 2 | |
3 | 3 | class Errors |
4 | 4 | { |
5 | - public function unAuthorized() |
|
6 | - { |
|
7 | - $error = ['status' => 401, 'message' => trans('core::errors.unAuthorized')]; |
|
8 | - abort($error['status'], $error['message']); |
|
9 | - } |
|
10 | - |
|
11 | - public function invalidRefreshToken() |
|
12 | - { |
|
13 | - $error = ['status' => 400, 'message' => trans('core::errors.invalidRefreshToken')]; |
|
14 | - abort($error['status'], $error['message']); |
|
15 | - } |
|
16 | - |
|
17 | - public function noPermissions() |
|
18 | - { |
|
19 | - $error = ['status' => 403, 'message' => trans('core::errors.noPermissions')]; |
|
20 | - abort($error['status'], $error['message']); |
|
21 | - } |
|
22 | - |
|
23 | - public function loginFailed() |
|
24 | - { |
|
25 | - $error = ['status' => 400, 'message' => trans('core::errors.loginFailed')]; |
|
26 | - abort($error['status'], $error['message']); |
|
27 | - } |
|
28 | - |
|
29 | - public function noSocialEmail() |
|
30 | - { |
|
31 | - $error = ['status' => 400, 'message' => trans('core::errors.noSocialEmail')]; |
|
32 | - abort($error['status'], $error['message']); |
|
33 | - } |
|
34 | - |
|
35 | - public function userAlreadyRegistered() |
|
36 | - { |
|
37 | - $error = ['status' => 400, 'message' => trans('core::errors.userAlreadyRegistered')]; |
|
38 | - abort($error['status'], $error['message']); |
|
39 | - } |
|
40 | - |
|
41 | - public function connectionError() |
|
42 | - { |
|
43 | - $error = ['status' => 400, 'message' => trans('core::errors.connectionError')]; |
|
44 | - abort($error['status'], $error['message']); |
|
45 | - } |
|
46 | - |
|
47 | - public function redisNotRunning() |
|
48 | - { |
|
49 | - $error = ['status' => 400, 'message' => trans('core::errors.redisNotRunning')]; |
|
50 | - abort($error['status'], $error['message']); |
|
51 | - } |
|
52 | - |
|
53 | - public function dbQueryError() |
|
54 | - { |
|
55 | - $error = ['status' => 400, 'message' => trans('core::errors.dbQueryError')]; |
|
56 | - abort($error['status'], $error['message']); |
|
57 | - } |
|
58 | - |
|
59 | - public function cannotCreateSetting() |
|
60 | - { |
|
61 | - $error = ['status' => 400, 'message' => trans('core::errors.cannotCreateSetting')]; |
|
62 | - abort($error['status'], $error['message']); |
|
63 | - } |
|
64 | - |
|
65 | - public function cannotUpdateSettingKey() |
|
66 | - { |
|
67 | - $error = ['status' => 400, 'message' => trans('core::errors.cannotUpdateSettingKey')]; |
|
68 | - abort($error['status'], $error['message']); |
|
69 | - } |
|
70 | - |
|
71 | - public function userIsBlocked() |
|
72 | - { |
|
73 | - $error = ['status' => 403, 'message' => trans('core::errors.userIsBlocked')]; |
|
74 | - abort($error['status'], $error['message']); |
|
75 | - } |
|
76 | - |
|
77 | - public function emailNotConfirmed() |
|
78 | - { |
|
79 | - $error = ['status' => 403, 'message' => trans('core::errors.emailNotConfirmed')]; |
|
80 | - abort($error['status'], $error['message']); |
|
81 | - } |
|
82 | - |
|
83 | - public function emailAlreadyConfirmed() |
|
84 | - { |
|
85 | - $error = ['status' => 403, 'message' => trans('core::errors.emailAlreadyConfirmed')]; |
|
86 | - abort($error['status'], $error['message']); |
|
87 | - } |
|
88 | - |
|
89 | - public function invalidResetToken() |
|
90 | - { |
|
91 | - $error = ['status' => 400, 'message' => trans('core::errors.invalidResetToken')]; |
|
92 | - abort($error['status'], $error['message']); |
|
93 | - } |
|
94 | - |
|
95 | - public function invalidResetPassword() |
|
96 | - { |
|
97 | - $error = ['status' => 400, 'message' => trans('core::errors.invalidResetPassword')]; |
|
98 | - abort($error['status'], $error['message']); |
|
99 | - } |
|
100 | - |
|
101 | - public function invalidOldPassword() |
|
102 | - { |
|
103 | - $error = ['status' => 400, 'message' => trans('core::errors.invalidOldPassword')]; |
|
104 | - abort($error['status'], $error['message']); |
|
105 | - } |
|
106 | - |
|
107 | - public function invalidConfirmationCode() |
|
108 | - { |
|
109 | - $error = ['status' => 400, 'message' => trans('core::errors.invalidConfirmationCode')]; |
|
110 | - abort($error['status'], $error['message']); |
|
111 | - } |
|
112 | - |
|
113 | - public function notFound($text) |
|
114 | - { |
|
115 | - $error = ['status' => 404, 'message' => trans('core::errors.notFound', ['replace' => $text])]; |
|
116 | - abort($error['status'], $error['message']); |
|
117 | - } |
|
118 | - |
|
119 | - public function generalError() |
|
120 | - { |
|
121 | - $error = ['status' => 400, 'message' => trans('core::errors.generalError')]; |
|
122 | - abort($error['status'], $error['message']); |
|
123 | - } |
|
5 | + public function unAuthorized() |
|
6 | + { |
|
7 | + $error = ['status' => 401, 'message' => trans('core::errors.unAuthorized')]; |
|
8 | + abort($error['status'], $error['message']); |
|
9 | + } |
|
10 | + |
|
11 | + public function invalidRefreshToken() |
|
12 | + { |
|
13 | + $error = ['status' => 400, 'message' => trans('core::errors.invalidRefreshToken')]; |
|
14 | + abort($error['status'], $error['message']); |
|
15 | + } |
|
16 | + |
|
17 | + public function noPermissions() |
|
18 | + { |
|
19 | + $error = ['status' => 403, 'message' => trans('core::errors.noPermissions')]; |
|
20 | + abort($error['status'], $error['message']); |
|
21 | + } |
|
22 | + |
|
23 | + public function loginFailed() |
|
24 | + { |
|
25 | + $error = ['status' => 400, 'message' => trans('core::errors.loginFailed')]; |
|
26 | + abort($error['status'], $error['message']); |
|
27 | + } |
|
28 | + |
|
29 | + public function noSocialEmail() |
|
30 | + { |
|
31 | + $error = ['status' => 400, 'message' => trans('core::errors.noSocialEmail')]; |
|
32 | + abort($error['status'], $error['message']); |
|
33 | + } |
|
34 | + |
|
35 | + public function userAlreadyRegistered() |
|
36 | + { |
|
37 | + $error = ['status' => 400, 'message' => trans('core::errors.userAlreadyRegistered')]; |
|
38 | + abort($error['status'], $error['message']); |
|
39 | + } |
|
40 | + |
|
41 | + public function connectionError() |
|
42 | + { |
|
43 | + $error = ['status' => 400, 'message' => trans('core::errors.connectionError')]; |
|
44 | + abort($error['status'], $error['message']); |
|
45 | + } |
|
46 | + |
|
47 | + public function redisNotRunning() |
|
48 | + { |
|
49 | + $error = ['status' => 400, 'message' => trans('core::errors.redisNotRunning')]; |
|
50 | + abort($error['status'], $error['message']); |
|
51 | + } |
|
52 | + |
|
53 | + public function dbQueryError() |
|
54 | + { |
|
55 | + $error = ['status' => 400, 'message' => trans('core::errors.dbQueryError')]; |
|
56 | + abort($error['status'], $error['message']); |
|
57 | + } |
|
58 | + |
|
59 | + public function cannotCreateSetting() |
|
60 | + { |
|
61 | + $error = ['status' => 400, 'message' => trans('core::errors.cannotCreateSetting')]; |
|
62 | + abort($error['status'], $error['message']); |
|
63 | + } |
|
64 | + |
|
65 | + public function cannotUpdateSettingKey() |
|
66 | + { |
|
67 | + $error = ['status' => 400, 'message' => trans('core::errors.cannotUpdateSettingKey')]; |
|
68 | + abort($error['status'], $error['message']); |
|
69 | + } |
|
70 | + |
|
71 | + public function userIsBlocked() |
|
72 | + { |
|
73 | + $error = ['status' => 403, 'message' => trans('core::errors.userIsBlocked')]; |
|
74 | + abort($error['status'], $error['message']); |
|
75 | + } |
|
76 | + |
|
77 | + public function emailNotConfirmed() |
|
78 | + { |
|
79 | + $error = ['status' => 403, 'message' => trans('core::errors.emailNotConfirmed')]; |
|
80 | + abort($error['status'], $error['message']); |
|
81 | + } |
|
82 | + |
|
83 | + public function emailAlreadyConfirmed() |
|
84 | + { |
|
85 | + $error = ['status' => 403, 'message' => trans('core::errors.emailAlreadyConfirmed')]; |
|
86 | + abort($error['status'], $error['message']); |
|
87 | + } |
|
88 | + |
|
89 | + public function invalidResetToken() |
|
90 | + { |
|
91 | + $error = ['status' => 400, 'message' => trans('core::errors.invalidResetToken')]; |
|
92 | + abort($error['status'], $error['message']); |
|
93 | + } |
|
94 | + |
|
95 | + public function invalidResetPassword() |
|
96 | + { |
|
97 | + $error = ['status' => 400, 'message' => trans('core::errors.invalidResetPassword')]; |
|
98 | + abort($error['status'], $error['message']); |
|
99 | + } |
|
100 | + |
|
101 | + public function invalidOldPassword() |
|
102 | + { |
|
103 | + $error = ['status' => 400, 'message' => trans('core::errors.invalidOldPassword')]; |
|
104 | + abort($error['status'], $error['message']); |
|
105 | + } |
|
106 | + |
|
107 | + public function invalidConfirmationCode() |
|
108 | + { |
|
109 | + $error = ['status' => 400, 'message' => trans('core::errors.invalidConfirmationCode')]; |
|
110 | + abort($error['status'], $error['message']); |
|
111 | + } |
|
112 | + |
|
113 | + public function notFound($text) |
|
114 | + { |
|
115 | + $error = ['status' => 404, 'message' => trans('core::errors.notFound', ['replace' => $text])]; |
|
116 | + abort($error['status'], $error['message']); |
|
117 | + } |
|
118 | + |
|
119 | + public function generalError() |
|
120 | + { |
|
121 | + $error = ['status' => 400, 'message' => trans('core::errors.generalError')]; |
|
122 | + abort($error['status'], $error['message']); |
|
123 | + } |
|
124 | 124 | } |
@@ -6,53 +6,53 @@ |
||
6 | 6 | |
7 | 7 | class ModuleServiceProvider extends ServiceProvider |
8 | 8 | { |
9 | - /** |
|
10 | - * Bootstrap the module services. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function boot() |
|
15 | - { |
|
16 | - $this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'core'); |
|
17 | - $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'core'); |
|
18 | - |
|
19 | - $this->loadMigrationsFrom(module_path('core', 'Database/Migrations', 'app')); |
|
20 | - $this->loadFactoriesFrom(module_path('core', 'Database/Factories', 'app')); |
|
21 | - } |
|
22 | - |
|
23 | - /** |
|
24 | - * Register the module services. |
|
25 | - * |
|
26 | - * @return void |
|
27 | - */ |
|
28 | - public function register() |
|
29 | - { |
|
30 | - //Bind Core Facade to the Service Container |
|
31 | - $this->app->singleton('Core', function () { |
|
32 | - return new \App\Modules\Core\Core; |
|
33 | - }); |
|
34 | - |
|
35 | - //Bind Errors Facade to the Service Container |
|
36 | - $this->app->singleton('Errors', function () { |
|
37 | - return new \App\Modules\Core\Utl\Errors; |
|
38 | - }); |
|
39 | - |
|
40 | - //Bind CoreConfig Facade to the Service Container |
|
41 | - $this->app->singleton('CoreConfig', function () { |
|
42 | - return new \App\Modules\Core\Utl\CoreConfig; |
|
43 | - }); |
|
44 | - |
|
45 | - //Bind Media Facade to the Service Container |
|
46 | - $this->app->singleton('Media', function () { |
|
47 | - return new \App\Modules\Core\Utl\Media; |
|
48 | - }); |
|
49 | - |
|
50 | - //Bind ApiConsumer Facade to the Service Container |
|
51 | - $this->app->singleton('ApiConsumer', function () { |
|
52 | - $app = app(); |
|
53 | - return new \App\Modules\Core\Utl\ApiConsumer($app, $app['request'], $app['router']); |
|
54 | - }); |
|
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'); |
|
18 | + |
|
19 | + $this->loadMigrationsFrom(module_path('core', 'Database/Migrations', 'app')); |
|
20 | + $this->loadFactoriesFrom(module_path('core', 'Database/Factories', 'app')); |
|
21 | + } |
|
22 | + |
|
23 | + /** |
|
24 | + * Register the module services. |
|
25 | + * |
|
26 | + * @return void |
|
27 | + */ |
|
28 | + public function register() |
|
29 | + { |
|
30 | + //Bind Core Facade to the Service Container |
|
31 | + $this->app->singleton('Core', function () { |
|
32 | + return new \App\Modules\Core\Core; |
|
33 | + }); |
|
34 | + |
|
35 | + //Bind Errors Facade to the Service Container |
|
36 | + $this->app->singleton('Errors', function () { |
|
37 | + return new \App\Modules\Core\Utl\Errors; |
|
38 | + }); |
|
39 | + |
|
40 | + //Bind CoreConfig Facade to the Service Container |
|
41 | + $this->app->singleton('CoreConfig', function () { |
|
42 | + return new \App\Modules\Core\Utl\CoreConfig; |
|
43 | + }); |
|
44 | + |
|
45 | + //Bind Media Facade to the Service Container |
|
46 | + $this->app->singleton('Media', function () { |
|
47 | + return new \App\Modules\Core\Utl\Media; |
|
48 | + }); |
|
49 | + |
|
50 | + //Bind ApiConsumer Facade to the Service Container |
|
51 | + $this->app->singleton('ApiConsumer', function () { |
|
52 | + $app = app(); |
|
53 | + return new \App\Modules\Core\Utl\ApiConsumer($app, $app['request'], $app['router']); |
|
54 | + }); |
|
55 | 55 | |
56 | - $this->app->register(RouteServiceProvider::class); |
|
57 | - } |
|
56 | + $this->app->register(RouteServiceProvider::class); |
|
57 | + } |
|
58 | 58 | } |
@@ -10,240 +10,240 @@ |
||
10 | 10 | |
11 | 11 | class MakeModuleCommand extends Command |
12 | 12 | { |
13 | - /** |
|
14 | - * The name and signature of the console command. |
|
15 | - * |
|
16 | - * @var string |
|
17 | - */ |
|
18 | - protected $signature = 'generate:module |
|
13 | + /** |
|
14 | + * The name and signature of the console command. |
|
15 | + * |
|
16 | + * @var string |
|
17 | + */ |
|
18 | + protected $signature = 'generate:module |
|
19 | 19 | {slug : The slug of the module}'; |
20 | 20 | |
21 | - /** |
|
22 | - * The console command description. |
|
23 | - * |
|
24 | - * @var string |
|
25 | - */ |
|
26 | - protected $description = 'Create a new module'; |
|
27 | - |
|
28 | - /** |
|
29 | - * The modules instance. |
|
30 | - * |
|
31 | - * @var RepositoryManager |
|
32 | - */ |
|
33 | - protected $module; |
|
34 | - |
|
35 | - /** |
|
36 | - * The filesystem instance. |
|
37 | - * |
|
38 | - * @var Filesystem |
|
39 | - */ |
|
40 | - protected $files; |
|
41 | - |
|
42 | - /** |
|
43 | - * Array to store the configuration details. |
|
44 | - * |
|
45 | - * @var array |
|
46 | - */ |
|
47 | - protected $container; |
|
48 | - |
|
49 | - /** |
|
50 | - * Array of folder mappings. |
|
51 | - * |
|
52 | - * @var Array |
|
53 | - */ |
|
54 | - protected $mapping = [ |
|
55 | - 'Database/Factories' => 'Database/Factories', |
|
56 | - 'Database/Migrations' => 'Database/Migrations', |
|
57 | - 'Database/Seeds' => 'Database/Seeds', |
|
58 | - 'Http/Controllers' => 'Http/Controllers', |
|
59 | - 'Http/Requests' => 'Http/Requests', |
|
60 | - 'Http/Resources' => 'Http/Resources', |
|
61 | - 'ModelObservers' => 'ModelObservers', |
|
62 | - 'Providers' => 'Providers', |
|
63 | - 'Repositories' => 'Repositories', |
|
64 | - 'Services' => 'Services', |
|
65 | - 'Routes' => 'Routes' |
|
66 | - ]; |
|
67 | - |
|
68 | - /** |
|
69 | - * Create a new command instance. |
|
70 | - * |
|
71 | - * @param Filesystem $files |
|
72 | - * @param RepositoryManager $module |
|
73 | - */ |
|
74 | - public function __construct(Filesystem $files, RepositoryManager $module) |
|
75 | - { |
|
76 | - parent::__construct(); |
|
77 | - |
|
78 | - $this->files = $files; |
|
79 | - $this->module = $module; |
|
80 | - } |
|
81 | - |
|
82 | - /** |
|
83 | - * Execute the console command. |
|
84 | - * |
|
85 | - * @return mixed |
|
86 | - */ |
|
87 | - public function handle() |
|
88 | - { |
|
89 | - $this->container['slug'] = Str::slug($this->argument('slug')); |
|
90 | - $this->container['name'] = Str::studly($this->container['slug']); |
|
91 | - $this->container['version'] = '1.0'; |
|
92 | - $this->container['description'] = 'This is the description for the ' . $this->container['name'] . ' module.'; |
|
93 | - $this->container['location'] = config('modules.default_location'); |
|
94 | - $this->container['provider'] = config("modules.locations.{$this->container['location']}.provider"); |
|
95 | - $this->container['basename'] = Str::studly($this->container['slug']); |
|
96 | - $this->container['namespace'] = config("modules.locations.{$this->container['location']}.namespace").$this->container['basename']; |
|
97 | - |
|
98 | - return $this->generate(); |
|
99 | - } |
|
100 | - |
|
101 | - /** |
|
102 | - * Generate the module. |
|
103 | - */ |
|
104 | - protected function generate() |
|
105 | - { |
|
106 | - $steps = [ |
|
107 | - 'Generating module...' => 'generateModule', |
|
108 | - 'Optimizing module cache...' => 'optimizeModules', |
|
109 | - 'Generating migrations...' => 'generateMigration', |
|
110 | - ]; |
|
111 | - |
|
112 | - $progress = new ProgressBar($this->output, count($steps)); |
|
113 | - $progress->start(); |
|
114 | - |
|
115 | - foreach ($steps as $message => $function) { |
|
116 | - $progress->setMessage($message); |
|
117 | - |
|
118 | - $this->$function(); |
|
119 | - |
|
120 | - $progress->advance(); |
|
121 | - } |
|
122 | - |
|
123 | - $progress->finish(); |
|
124 | - |
|
125 | - event($this->container['slug'] . '.module.made'); |
|
126 | - |
|
127 | - $this->info("\nModule generated successfully."); |
|
128 | - } |
|
129 | - |
|
130 | - /** |
|
131 | - * Generate defined module folders. |
|
132 | - */ |
|
133 | - protected function generateModule() |
|
134 | - { |
|
135 | - $location = $this->container['location']; |
|
136 | - $root = module_path(null, '', $location); |
|
137 | - $manifest = config("modules.locations.$location.manifest") ?: 'module.json'; |
|
138 | - $provider = config("modules.locations.$location.provider") ?: 'ModuleServiceProvider'; |
|
139 | - |
|
140 | - if (!$this->files->isDirectory($root)) { |
|
141 | - $this->files->makeDirectory($root); |
|
142 | - } |
|
143 | - |
|
144 | - $directory = module_path(null, $this->container['basename'], $location); |
|
145 | - $source = __DIR__ . '/Stubs/Module'; |
|
146 | - |
|
147 | - $this->files->makeDirectory($directory); |
|
148 | - |
|
149 | - $sourceFiles = $this->files->allFiles($source, true); |
|
150 | - |
|
151 | - if (!empty($this->mapping)) { |
|
152 | - $search = array_keys($this->mapping); |
|
153 | - $replace = array_values($this->mapping); |
|
154 | - } |
|
155 | - |
|
156 | - foreach ($sourceFiles as $file) { |
|
157 | - $contents = $this->replacePlaceholders($file->getContents()); |
|
158 | - $subPath = $file->getRelativePathname(); |
|
159 | - |
|
160 | - if (!empty($this->mapping)) { |
|
161 | - $subPath = str_replace($search, $replace, $subPath); |
|
162 | - } |
|
163 | - |
|
164 | - $filePath = $directory . '/' . $subPath; |
|
21 | + /** |
|
22 | + * The console command description. |
|
23 | + * |
|
24 | + * @var string |
|
25 | + */ |
|
26 | + protected $description = 'Create a new module'; |
|
27 | + |
|
28 | + /** |
|
29 | + * The modules instance. |
|
30 | + * |
|
31 | + * @var RepositoryManager |
|
32 | + */ |
|
33 | + protected $module; |
|
34 | + |
|
35 | + /** |
|
36 | + * The filesystem instance. |
|
37 | + * |
|
38 | + * @var Filesystem |
|
39 | + */ |
|
40 | + protected $files; |
|
41 | + |
|
42 | + /** |
|
43 | + * Array to store the configuration details. |
|
44 | + * |
|
45 | + * @var array |
|
46 | + */ |
|
47 | + protected $container; |
|
48 | + |
|
49 | + /** |
|
50 | + * Array of folder mappings. |
|
51 | + * |
|
52 | + * @var Array |
|
53 | + */ |
|
54 | + protected $mapping = [ |
|
55 | + 'Database/Factories' => 'Database/Factories', |
|
56 | + 'Database/Migrations' => 'Database/Migrations', |
|
57 | + 'Database/Seeds' => 'Database/Seeds', |
|
58 | + 'Http/Controllers' => 'Http/Controllers', |
|
59 | + 'Http/Requests' => 'Http/Requests', |
|
60 | + 'Http/Resources' => 'Http/Resources', |
|
61 | + 'ModelObservers' => 'ModelObservers', |
|
62 | + 'Providers' => 'Providers', |
|
63 | + 'Repositories' => 'Repositories', |
|
64 | + 'Services' => 'Services', |
|
65 | + 'Routes' => 'Routes' |
|
66 | + ]; |
|
67 | + |
|
68 | + /** |
|
69 | + * Create a new command instance. |
|
70 | + * |
|
71 | + * @param Filesystem $files |
|
72 | + * @param RepositoryManager $module |
|
73 | + */ |
|
74 | + public function __construct(Filesystem $files, RepositoryManager $module) |
|
75 | + { |
|
76 | + parent::__construct(); |
|
77 | + |
|
78 | + $this->files = $files; |
|
79 | + $this->module = $module; |
|
80 | + } |
|
81 | + |
|
82 | + /** |
|
83 | + * Execute the console command. |
|
84 | + * |
|
85 | + * @return mixed |
|
86 | + */ |
|
87 | + public function handle() |
|
88 | + { |
|
89 | + $this->container['slug'] = Str::slug($this->argument('slug')); |
|
90 | + $this->container['name'] = Str::studly($this->container['slug']); |
|
91 | + $this->container['version'] = '1.0'; |
|
92 | + $this->container['description'] = 'This is the description for the ' . $this->container['name'] . ' module.'; |
|
93 | + $this->container['location'] = config('modules.default_location'); |
|
94 | + $this->container['provider'] = config("modules.locations.{$this->container['location']}.provider"); |
|
95 | + $this->container['basename'] = Str::studly($this->container['slug']); |
|
96 | + $this->container['namespace'] = config("modules.locations.{$this->container['location']}.namespace").$this->container['basename']; |
|
97 | + |
|
98 | + return $this->generate(); |
|
99 | + } |
|
100 | + |
|
101 | + /** |
|
102 | + * Generate the module. |
|
103 | + */ |
|
104 | + protected function generate() |
|
105 | + { |
|
106 | + $steps = [ |
|
107 | + 'Generating module...' => 'generateModule', |
|
108 | + 'Optimizing module cache...' => 'optimizeModules', |
|
109 | + 'Generating migrations...' => 'generateMigration', |
|
110 | + ]; |
|
111 | + |
|
112 | + $progress = new ProgressBar($this->output, count($steps)); |
|
113 | + $progress->start(); |
|
114 | + |
|
115 | + foreach ($steps as $message => $function) { |
|
116 | + $progress->setMessage($message); |
|
117 | + |
|
118 | + $this->$function(); |
|
119 | + |
|
120 | + $progress->advance(); |
|
121 | + } |
|
122 | + |
|
123 | + $progress->finish(); |
|
124 | + |
|
125 | + event($this->container['slug'] . '.module.made'); |
|
126 | + |
|
127 | + $this->info("\nModule generated successfully."); |
|
128 | + } |
|
129 | + |
|
130 | + /** |
|
131 | + * Generate defined module folders. |
|
132 | + */ |
|
133 | + protected function generateModule() |
|
134 | + { |
|
135 | + $location = $this->container['location']; |
|
136 | + $root = module_path(null, '', $location); |
|
137 | + $manifest = config("modules.locations.$location.manifest") ?: 'module.json'; |
|
138 | + $provider = config("modules.locations.$location.provider") ?: 'ModuleServiceProvider'; |
|
139 | + |
|
140 | + if (!$this->files->isDirectory($root)) { |
|
141 | + $this->files->makeDirectory($root); |
|
142 | + } |
|
143 | + |
|
144 | + $directory = module_path(null, $this->container['basename'], $location); |
|
145 | + $source = __DIR__ . '/Stubs/Module'; |
|
146 | + |
|
147 | + $this->files->makeDirectory($directory); |
|
148 | + |
|
149 | + $sourceFiles = $this->files->allFiles($source, true); |
|
150 | + |
|
151 | + if (!empty($this->mapping)) { |
|
152 | + $search = array_keys($this->mapping); |
|
153 | + $replace = array_values($this->mapping); |
|
154 | + } |
|
155 | + |
|
156 | + foreach ($sourceFiles as $file) { |
|
157 | + $contents = $this->replacePlaceholders($file->getContents()); |
|
158 | + $subPath = $file->getRelativePathname(); |
|
159 | + |
|
160 | + if (!empty($this->mapping)) { |
|
161 | + $subPath = str_replace($search, $replace, $subPath); |
|
162 | + } |
|
163 | + |
|
164 | + $filePath = $directory . '/' . $subPath; |
|
165 | 165 | |
166 | - // if the file is module.json, replace it with the custom manifest file name |
|
167 | - if ($file->getFilename() === 'module.json' && $manifest) { |
|
168 | - $filePath = str_replace('module.json', $manifest, $filePath); |
|
169 | - } |
|
166 | + // if the file is module.json, replace it with the custom manifest file name |
|
167 | + if ($file->getFilename() === 'module.json' && $manifest) { |
|
168 | + $filePath = str_replace('module.json', $manifest, $filePath); |
|
169 | + } |
|
170 | 170 | |
171 | - // if the file is ModuleServiceProvider.php, replace it with the custom provider file name |
|
172 | - if ($file->getFilename() === 'ModuleServiceProvider.php') { |
|
173 | - $filePath = str_replace('ModuleServiceProvider', $provider, $filePath); |
|
174 | - } |
|
175 | - $filePath = $this->replacePlaceholders($filePath); |
|
171 | + // if the file is ModuleServiceProvider.php, replace it with the custom provider file name |
|
172 | + if ($file->getFilename() === 'ModuleServiceProvider.php') { |
|
173 | + $filePath = str_replace('ModuleServiceProvider', $provider, $filePath); |
|
174 | + } |
|
175 | + $filePath = $this->replacePlaceholders($filePath); |
|
176 | 176 | |
177 | - $dir = dirname($filePath); |
|
177 | + $dir = dirname($filePath); |
|
178 | 178 | |
179 | - if (! $this->files->isDirectory($dir)) { |
|
180 | - $this->files->makeDirectory($dir, 0755, true); |
|
181 | - } |
|
182 | - |
|
183 | - $this->files->put($filePath, $contents); |
|
184 | - } |
|
185 | - } |
|
186 | - |
|
187 | - protected function replacePlaceholders($contents) |
|
188 | - { |
|
189 | - $modelName = \Str::camel($this->container['slug']); |
|
190 | - $modelNameSingular = \Str::singular($modelName); |
|
191 | - |
|
192 | - $find = [ |
|
193 | - 'DummyFactory', |
|
194 | - 'DummyModelName', |
|
195 | - 'DummyModuleSlug', |
|
196 | - 'DummyModule', |
|
197 | - 'DummyModel', |
|
198 | - 'DummyDatabaseSeeder', |
|
199 | - 'DummyTableSeeder', |
|
200 | - 'DummyController', |
|
201 | - 'DummyService', |
|
202 | - 'DummyRepository', |
|
203 | - 'InsertDummy', |
|
204 | - 'UpdateDummy', |
|
205 | - 'DummyResource', |
|
206 | - 'DummyObserver', |
|
207 | - 'DummyTableName', |
|
208 | - 'DummyRoutePrefix', |
|
209 | - ]; |
|
210 | - |
|
211 | - $replace = [ |
|
212 | - ucfirst($modelNameSingular) . 'Factory', |
|
213 | - $modelNameSingular, |
|
214 | - $this->container['slug'], |
|
215 | - ucfirst($modelName), |
|
216 | - ucfirst($modelNameSingular), |
|
217 | - ucfirst($modelName) . 'DatabaseSeeder', |
|
218 | - ucfirst($modelName) . 'TableSeeder', |
|
219 | - ucfirst($modelNameSingular) . 'Controller', |
|
220 | - ucfirst($modelNameSingular) . 'Service', |
|
221 | - ucfirst($modelNameSingular) . 'Repository', |
|
222 | - 'Insert' . ucfirst($modelNameSingular), |
|
223 | - 'Update' . ucfirst($modelNameSingular), |
|
224 | - ucfirst($modelNameSingular), |
|
225 | - ucfirst($modelNameSingular) . 'Observer', |
|
226 | - $modelName, |
|
227 | - $modelName, |
|
228 | - ]; |
|
229 | - |
|
230 | - return str_replace($find, $replace, $contents); |
|
231 | - } |
|
232 | - |
|
233 | - /** |
|
234 | - * Reset module cache of enabled and disabled modules. |
|
235 | - */ |
|
236 | - protected function optimizeModules() |
|
237 | - { |
|
238 | - return $this->callSilent('module:optimize'); |
|
239 | - } |
|
240 | - |
|
241 | - /** |
|
242 | - * Generate table migrations. |
|
243 | - */ |
|
244 | - protected function generateMigration() |
|
245 | - { |
|
246 | - $modelName = $this->container['slug']; |
|
247 | - return $this->callSilent('make:module:migration', ['slug' => $modelName, 'name' => 'create_' . $modelName . '_table']); |
|
248 | - } |
|
179 | + if (! $this->files->isDirectory($dir)) { |
|
180 | + $this->files->makeDirectory($dir, 0755, true); |
|
181 | + } |
|
182 | + |
|
183 | + $this->files->put($filePath, $contents); |
|
184 | + } |
|
185 | + } |
|
186 | + |
|
187 | + protected function replacePlaceholders($contents) |
|
188 | + { |
|
189 | + $modelName = \Str::camel($this->container['slug']); |
|
190 | + $modelNameSingular = \Str::singular($modelName); |
|
191 | + |
|
192 | + $find = [ |
|
193 | + 'DummyFactory', |
|
194 | + 'DummyModelName', |
|
195 | + 'DummyModuleSlug', |
|
196 | + 'DummyModule', |
|
197 | + 'DummyModel', |
|
198 | + 'DummyDatabaseSeeder', |
|
199 | + 'DummyTableSeeder', |
|
200 | + 'DummyController', |
|
201 | + 'DummyService', |
|
202 | + 'DummyRepository', |
|
203 | + 'InsertDummy', |
|
204 | + 'UpdateDummy', |
|
205 | + 'DummyResource', |
|
206 | + 'DummyObserver', |
|
207 | + 'DummyTableName', |
|
208 | + 'DummyRoutePrefix', |
|
209 | + ]; |
|
210 | + |
|
211 | + $replace = [ |
|
212 | + ucfirst($modelNameSingular) . 'Factory', |
|
213 | + $modelNameSingular, |
|
214 | + $this->container['slug'], |
|
215 | + ucfirst($modelName), |
|
216 | + ucfirst($modelNameSingular), |
|
217 | + ucfirst($modelName) . 'DatabaseSeeder', |
|
218 | + ucfirst($modelName) . 'TableSeeder', |
|
219 | + ucfirst($modelNameSingular) . 'Controller', |
|
220 | + ucfirst($modelNameSingular) . 'Service', |
|
221 | + ucfirst($modelNameSingular) . 'Repository', |
|
222 | + 'Insert' . ucfirst($modelNameSingular), |
|
223 | + 'Update' . ucfirst($modelNameSingular), |
|
224 | + ucfirst($modelNameSingular), |
|
225 | + ucfirst($modelNameSingular) . 'Observer', |
|
226 | + $modelName, |
|
227 | + $modelName, |
|
228 | + ]; |
|
229 | + |
|
230 | + return str_replace($find, $replace, $contents); |
|
231 | + } |
|
232 | + |
|
233 | + /** |
|
234 | + * Reset module cache of enabled and disabled modules. |
|
235 | + */ |
|
236 | + protected function optimizeModules() |
|
237 | + { |
|
238 | + return $this->callSilent('module:optimize'); |
|
239 | + } |
|
240 | + |
|
241 | + /** |
|
242 | + * Generate table migrations. |
|
243 | + */ |
|
244 | + protected function generateMigration() |
|
245 | + { |
|
246 | + $modelName = $this->container['slug']; |
|
247 | + return $this->callSilent('make:module:migration', ['slug' => $modelName, 'name' => 'create_' . $modelName . '_table']); |
|
248 | + } |
|
249 | 249 | } |
@@ -10,57 +10,57 @@ |
||
10 | 10 | |
11 | 11 | class DummyController extends BaseApiController |
12 | 12 | { |
13 | - /** |
|
14 | - * Path of the model resource |
|
15 | - * |
|
16 | - * @var string |
|
17 | - */ |
|
18 | - protected $modelResource = 'App\Modules\DummyModule\Http\Resources\DummyModel'; |
|
13 | + /** |
|
14 | + * Path of the model resource |
|
15 | + * |
|
16 | + * @var string |
|
17 | + */ |
|
18 | + protected $modelResource = 'App\Modules\DummyModule\Http\Resources\DummyModel'; |
|
19 | 19 | |
20 | - /** |
|
21 | - * List of all route actions that the base api controller |
|
22 | - * will skip permissions check for them. |
|
23 | - * @var array |
|
24 | - */ |
|
25 | - protected $skipPermissionCheck = []; |
|
20 | + /** |
|
21 | + * List of all route actions that the base api controller |
|
22 | + * will skip permissions check for them. |
|
23 | + * @var array |
|
24 | + */ |
|
25 | + protected $skipPermissionCheck = []; |
|
26 | 26 | |
27 | - /** |
|
28 | - * List of all route actions that the base api controller |
|
29 | - * will skip login check for them. |
|
30 | - * @var array |
|
31 | - */ |
|
32 | - protected $skipLoginCheck = []; |
|
27 | + /** |
|
28 | + * List of all route actions that the base api controller |
|
29 | + * will skip login check for them. |
|
30 | + * @var array |
|
31 | + */ |
|
32 | + protected $skipLoginCheck = []; |
|
33 | 33 | |
34 | - /** |
|
35 | - * Init new object. |
|
36 | - * |
|
37 | - * @param DummyService $service |
|
38 | - * @return void |
|
39 | - */ |
|
40 | - public function __construct(DummyService $service) |
|
41 | - { |
|
42 | - parent::__construct($service); |
|
43 | - } |
|
34 | + /** |
|
35 | + * Init new object. |
|
36 | + * |
|
37 | + * @param DummyService $service |
|
38 | + * @return void |
|
39 | + */ |
|
40 | + public function __construct(DummyService $service) |
|
41 | + { |
|
42 | + parent::__construct($service); |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * Insert the given model to storage. |
|
47 | - * |
|
48 | - * @param InsertDummy $request |
|
49 | - * @return \Illuminate\Http\Response |
|
50 | - */ |
|
51 | - public function insert(InsertDummy $request) |
|
52 | - { |
|
53 | - return new $this->modelResource($this->service->save($request->all())); |
|
54 | - } |
|
45 | + /** |
|
46 | + * Insert the given model to storage. |
|
47 | + * |
|
48 | + * @param InsertDummy $request |
|
49 | + * @return \Illuminate\Http\Response |
|
50 | + */ |
|
51 | + public function insert(InsertDummy $request) |
|
52 | + { |
|
53 | + return new $this->modelResource($this->service->save($request->all())); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * Update the given model to storage. |
|
58 | - * |
|
59 | - * @param UpdateDummy $request |
|
60 | - * @return \Illuminate\Http\Response |
|
61 | - */ |
|
62 | - public function update(UpdateDummy $request) |
|
63 | - { |
|
64 | - return new $this->modelResource($this->service->save($request->all())); |
|
65 | - } |
|
56 | + /** |
|
57 | + * Update the given model to storage. |
|
58 | + * |
|
59 | + * @param UpdateDummy $request |
|
60 | + * @return \Illuminate\Http\Response |
|
61 | + */ |
|
62 | + public function update(UpdateDummy $request) |
|
63 | + { |
|
64 | + return new $this->modelResource($this->service->save($request->all())); |
|
65 | + } |
|
66 | 66 | } |
@@ -6,32 +6,32 @@ |
||
6 | 6 | |
7 | 7 | class DummyModel extends Model |
8 | 8 | { |
9 | - use SoftDeletes; |
|
10 | - protected $table = 'DummyTableName'; |
|
11 | - protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
12 | - protected $hidden = ['deleted_at']; |
|
13 | - protected $guarded = ['id']; |
|
14 | - protected $fillable = []; // Add attributes here |
|
15 | - public $searchable = []; // Add earchable attributes here |
|
9 | + use SoftDeletes; |
|
10 | + protected $table = 'DummyTableName'; |
|
11 | + protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
12 | + protected $hidden = ['deleted_at']; |
|
13 | + protected $guarded = ['id']; |
|
14 | + protected $fillable = []; // Add attributes here |
|
15 | + public $searchable = []; // Add earchable attributes here |
|
16 | 16 | |
17 | - public function getCreatedAtAttribute($value) |
|
18 | - { |
|
19 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
20 | - } |
|
17 | + public function getCreatedAtAttribute($value) |
|
18 | + { |
|
19 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
20 | + } |
|
21 | 21 | |
22 | - public function getUpdatedAtAttribute($value) |
|
23 | - { |
|
24 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
25 | - } |
|
22 | + public function getUpdatedAtAttribute($value) |
|
23 | + { |
|
24 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
25 | + } |
|
26 | 26 | |
27 | - public function getDeletedAtAttribute($value) |
|
28 | - { |
|
29 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
30 | - } |
|
27 | + public function getDeletedAtAttribute($value) |
|
28 | + { |
|
29 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
30 | + } |
|
31 | 31 | |
32 | - public static function boot() |
|
33 | - { |
|
34 | - parent::boot(); |
|
35 | - DummyModel::observe(DummyObserver::class); |
|
36 | - } |
|
32 | + public static function boot() |
|
33 | + { |
|
34 | + parent::boot(); |
|
35 | + DummyModel::observe(DummyObserver::class); |
|
36 | + } |
|
37 | 37 | } |
@@ -5,14 +5,14 @@ |
||
5 | 5 | |
6 | 6 | class DummyService extends BaseService |
7 | 7 | { |
8 | - /** |
|
9 | - * Init new object. |
|
10 | - * |
|
11 | - * @param DummyRepository $repo |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function __construct(DummyRepository $repo) |
|
15 | - { |
|
16 | - parent::__construct($repo); |
|
17 | - } |
|
8 | + /** |
|
9 | + * Init new object. |
|
10 | + * |
|
11 | + * @param DummyRepository $repo |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function __construct(DummyRepository $repo) |
|
15 | + { |
|
16 | + parent::__construct($repo); |
|
17 | + } |
|
18 | 18 | } |