@@ -6,81 +6,81 @@ |
||
6 | 6 | |
7 | 7 | class Kernel extends HttpKernel |
8 | 8 | { |
9 | - /** |
|
10 | - * The application's global HTTP middleware stack. |
|
11 | - * |
|
12 | - * These middleware are run during every request to your application. |
|
13 | - * |
|
14 | - * @var array |
|
15 | - */ |
|
16 | - protected $middleware = [ |
|
17 | - \App\Http\Middleware\TrustProxies::class, |
|
18 | - \App\Http\Middleware\CheckForMaintenanceMode::class, |
|
19 | - \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, |
|
20 | - \App\Http\Middleware\TrimStrings::class, |
|
21 | - \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, |
|
22 | - ]; |
|
9 | + /** |
|
10 | + * The application's global HTTP middleware stack. |
|
11 | + * |
|
12 | + * These middleware are run during every request to your application. |
|
13 | + * |
|
14 | + * @var array |
|
15 | + */ |
|
16 | + protected $middleware = [ |
|
17 | + \App\Http\Middleware\TrustProxies::class, |
|
18 | + \App\Http\Middleware\CheckForMaintenanceMode::class, |
|
19 | + \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, |
|
20 | + \App\Http\Middleware\TrimStrings::class, |
|
21 | + \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, |
|
22 | + ]; |
|
23 | 23 | |
24 | - /** |
|
25 | - * The application's route middleware groups. |
|
26 | - * |
|
27 | - * @var array |
|
28 | - */ |
|
29 | - protected $middlewareGroups = [ |
|
30 | - 'web' => [ |
|
31 | - \App\Http\Middleware\EncryptCookies::class, |
|
32 | - \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, |
|
33 | - \Illuminate\Session\Middleware\StartSession::class, |
|
34 | - // \Illuminate\Session\Middleware\AuthenticateSession::class, |
|
35 | - \Illuminate\View\Middleware\ShareErrorsFromSession::class, |
|
36 | - \App\Http\Middleware\VerifyCsrfToken::class, |
|
37 | - \Illuminate\Routing\Middleware\SubstituteBindings::class, |
|
38 | - ], |
|
24 | + /** |
|
25 | + * The application's route middleware groups. |
|
26 | + * |
|
27 | + * @var array |
|
28 | + */ |
|
29 | + protected $middlewareGroups = [ |
|
30 | + 'web' => [ |
|
31 | + \App\Http\Middleware\EncryptCookies::class, |
|
32 | + \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, |
|
33 | + \Illuminate\Session\Middleware\StartSession::class, |
|
34 | + // \Illuminate\Session\Middleware\AuthenticateSession::class, |
|
35 | + \Illuminate\View\Middleware\ShareErrorsFromSession::class, |
|
36 | + \App\Http\Middleware\VerifyCsrfToken::class, |
|
37 | + \Illuminate\Routing\Middleware\SubstituteBindings::class, |
|
38 | + ], |
|
39 | 39 | |
40 | - 'api' => [ |
|
41 | - 'throttle:60,1', |
|
42 | - \Illuminate\Routing\Middleware\SubstituteBindings::class, |
|
43 | - \App\Modules\Core\Http\Middleware\SetSessions::class, |
|
44 | - \App\Modules\Core\Http\Middleware\CheckPermissions::class, |
|
45 | - \App\Modules\Core\Http\Middleware\UpdateLocaleAndTimezone::class, |
|
46 | - \App\Modules\Core\Http\Middleware\SetRelations::class, |
|
47 | - ], |
|
48 | - ]; |
|
40 | + 'api' => [ |
|
41 | + 'throttle:60,1', |
|
42 | + \Illuminate\Routing\Middleware\SubstituteBindings::class, |
|
43 | + \App\Modules\Core\Http\Middleware\SetSessions::class, |
|
44 | + \App\Modules\Core\Http\Middleware\CheckPermissions::class, |
|
45 | + \App\Modules\Core\Http\Middleware\UpdateLocaleAndTimezone::class, |
|
46 | + \App\Modules\Core\Http\Middleware\SetRelations::class, |
|
47 | + ], |
|
48 | + ]; |
|
49 | 49 | |
50 | - /** |
|
51 | - * The application's route middleware. |
|
52 | - * |
|
53 | - * These middleware may be assigned to groups or used individually. |
|
54 | - * |
|
55 | - * @var array |
|
56 | - */ |
|
57 | - protected $routeMiddleware = [ |
|
58 | - 'auth' => \App\Http\Middleware\Authenticate::class, |
|
59 | - 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, |
|
60 | - 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, |
|
61 | - 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, |
|
62 | - 'can' => \Illuminate\Auth\Middleware\Authorize::class, |
|
63 | - 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, |
|
64 | - 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, |
|
65 | - 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, |
|
66 | - 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, |
|
67 | - 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, |
|
68 | - ]; |
|
50 | + /** |
|
51 | + * The application's route middleware. |
|
52 | + * |
|
53 | + * These middleware may be assigned to groups or used individually. |
|
54 | + * |
|
55 | + * @var array |
|
56 | + */ |
|
57 | + protected $routeMiddleware = [ |
|
58 | + 'auth' => \App\Http\Middleware\Authenticate::class, |
|
59 | + 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, |
|
60 | + 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, |
|
61 | + 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, |
|
62 | + 'can' => \Illuminate\Auth\Middleware\Authorize::class, |
|
63 | + 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, |
|
64 | + 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, |
|
65 | + 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, |
|
66 | + 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, |
|
67 | + 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, |
|
68 | + ]; |
|
69 | 69 | |
70 | - /** |
|
71 | - * The priority-sorted list of middleware. |
|
72 | - * |
|
73 | - * This forces non-global middleware to always be in the given order. |
|
74 | - * |
|
75 | - * @var array |
|
76 | - */ |
|
77 | - protected $middlewarePriority = [ |
|
78 | - \Illuminate\Session\Middleware\StartSession::class, |
|
79 | - \Illuminate\View\Middleware\ShareErrorsFromSession::class, |
|
80 | - \App\Http\Middleware\Authenticate::class, |
|
81 | - \Illuminate\Routing\Middleware\ThrottleRequests::class, |
|
82 | - \Illuminate\Session\Middleware\AuthenticateSession::class, |
|
83 | - \Illuminate\Routing\Middleware\SubstituteBindings::class, |
|
84 | - \Illuminate\Auth\Middleware\Authorize::class, |
|
85 | - ]; |
|
70 | + /** |
|
71 | + * The priority-sorted list of middleware. |
|
72 | + * |
|
73 | + * This forces non-global middleware to always be in the given order. |
|
74 | + * |
|
75 | + * @var array |
|
76 | + */ |
|
77 | + protected $middlewarePriority = [ |
|
78 | + \Illuminate\Session\Middleware\StartSession::class, |
|
79 | + \Illuminate\View\Middleware\ShareErrorsFromSession::class, |
|
80 | + \App\Http\Middleware\Authenticate::class, |
|
81 | + \Illuminate\Routing\Middleware\ThrottleRequests::class, |
|
82 | + \Illuminate\Session\Middleware\AuthenticateSession::class, |
|
83 | + \Illuminate\Routing\Middleware\SubstituteBindings::class, |
|
84 | + \Illuminate\Auth\Middleware\Authorize::class, |
|
85 | + ]; |
|
86 | 86 | } |
@@ -12,5 +12,5 @@ |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | Broadcast::channel('users.{id}', function ($user, $id) { |
15 | - return (int) $user->id === (int) $id; |
|
15 | + return (int) $user->id === (int) $id; |
|
16 | 16 | }); |
@@ -11,6 +11,6 @@ |
||
11 | 11 | | |
12 | 12 | */ |
13 | 13 | |
14 | -Broadcast::channel('users.{id}', function ($user, $id) { |
|
14 | +Broadcast::channel('users.{id}', function($user, $id) { |
|
15 | 15 | return (int) $user->id === (int) $id; |
16 | 16 | }); |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | return [ |
4 | 4 | |
5 | - /* |
|
5 | + /* |
|
6 | 6 | |-------------------------------------------------------------------------- |
7 | 7 | | Authentication Defaults |
8 | 8 | |-------------------------------------------------------------------------- |
@@ -13,12 +13,12 @@ discard block |
||
13 | 13 | | |
14 | 14 | */ |
15 | 15 | |
16 | - 'defaults' => [ |
|
17 | - 'guard' => 'web', |
|
18 | - 'passwords' => 'users', |
|
19 | - ], |
|
16 | + 'defaults' => [ |
|
17 | + 'guard' => 'web', |
|
18 | + 'passwords' => 'users', |
|
19 | + ], |
|
20 | 20 | |
21 | - /* |
|
21 | + /* |
|
22 | 22 | |-------------------------------------------------------------------------- |
23 | 23 | | Authentication Guards |
24 | 24 | |-------------------------------------------------------------------------- |
@@ -35,19 +35,19 @@ discard block |
||
35 | 35 | | |
36 | 36 | */ |
37 | 37 | |
38 | - 'guards' => [ |
|
39 | - 'web' => [ |
|
40 | - 'driver' => 'session', |
|
41 | - 'provider' => 'users', |
|
42 | - ], |
|
38 | + 'guards' => [ |
|
39 | + 'web' => [ |
|
40 | + 'driver' => 'session', |
|
41 | + 'provider' => 'users', |
|
42 | + ], |
|
43 | 43 | |
44 | - 'api' => [ |
|
45 | - 'driver' => 'passport', |
|
46 | - 'provider' => 'users', |
|
47 | - ], |
|
48 | - ], |
|
44 | + 'api' => [ |
|
45 | + 'driver' => 'passport', |
|
46 | + 'provider' => 'users', |
|
47 | + ], |
|
48 | + ], |
|
49 | 49 | |
50 | - /* |
|
50 | + /* |
|
51 | 51 | |-------------------------------------------------------------------------- |
52 | 52 | | User Providers |
53 | 53 | |-------------------------------------------------------------------------- |
@@ -64,19 +64,19 @@ discard block |
||
64 | 64 | | |
65 | 65 | */ |
66 | 66 | |
67 | - 'providers' => [ |
|
68 | - 'users' => [ |
|
69 | - 'driver' => 'eloquent', |
|
70 | - 'model' => App\Modules\Users\AclUser::class, |
|
71 | - ], |
|
67 | + 'providers' => [ |
|
68 | + 'users' => [ |
|
69 | + 'driver' => 'eloquent', |
|
70 | + 'model' => App\Modules\Users\AclUser::class, |
|
71 | + ], |
|
72 | 72 | |
73 | - // 'users' => [ |
|
74 | - // 'driver' => 'database', |
|
75 | - // 'table' => 'users', |
|
76 | - // ], |
|
77 | - ], |
|
73 | + // 'users' => [ |
|
74 | + // 'driver' => 'database', |
|
75 | + // 'table' => 'users', |
|
76 | + // ], |
|
77 | + ], |
|
78 | 78 | |
79 | - /* |
|
79 | + /* |
|
80 | 80 | |-------------------------------------------------------------------------- |
81 | 81 | | Resetting Passwords |
82 | 82 | |-------------------------------------------------------------------------- |
@@ -91,12 +91,12 @@ discard block |
||
91 | 91 | | |
92 | 92 | */ |
93 | 93 | |
94 | - 'passwords' => [ |
|
95 | - 'users' => [ |
|
96 | - 'provider' => 'users', |
|
97 | - 'table' => 'password_resets', |
|
98 | - 'expire' => 60, |
|
99 | - ], |
|
100 | - ], |
|
94 | + 'passwords' => [ |
|
95 | + 'users' => [ |
|
96 | + 'provider' => 'users', |
|
97 | + 'table' => 'password_resets', |
|
98 | + 'expire' => 60, |
|
99 | + ], |
|
100 | + ], |
|
101 | 101 | |
102 | 102 | ]; |
@@ -25,7 +25,7 @@ |
||
25 | 25 | { |
26 | 26 | $this->registerPolicies(); |
27 | 27 | |
28 | - Passport::routes(function ($router) { |
|
28 | + Passport::routes(function($router) { |
|
29 | 29 | $router->forAuthorization(); |
30 | 30 | $router->forAccessTokens(); |
31 | 31 | $router->forPersonalAccessTokens(); |
@@ -7,31 +7,31 @@ |
||
7 | 7 | |
8 | 8 | class AuthServiceProvider extends ServiceProvider |
9 | 9 | { |
10 | - /** |
|
11 | - * The policy mappings for the application. |
|
12 | - * |
|
13 | - * @var array |
|
14 | - */ |
|
15 | - protected $policies = [ |
|
16 | - 'App\Model' => 'App\Policies\ModelPolicy', |
|
17 | - ]; |
|
10 | + /** |
|
11 | + * The policy mappings for the application. |
|
12 | + * |
|
13 | + * @var array |
|
14 | + */ |
|
15 | + protected $policies = [ |
|
16 | + 'App\Model' => 'App\Policies\ModelPolicy', |
|
17 | + ]; |
|
18 | 18 | |
19 | - /** |
|
20 | - * Register any authentication / authorization services. |
|
21 | - * |
|
22 | - * @return void |
|
23 | - */ |
|
24 | - public function boot() |
|
25 | - { |
|
26 | - $this->registerPolicies(); |
|
19 | + /** |
|
20 | + * Register any authentication / authorization services. |
|
21 | + * |
|
22 | + * @return void |
|
23 | + */ |
|
24 | + public function boot() |
|
25 | + { |
|
26 | + $this->registerPolicies(); |
|
27 | 27 | |
28 | - Passport::routes(function ($router) { |
|
29 | - $router->forAuthorization(); |
|
30 | - $router->forAccessTokens(); |
|
31 | - $router->forPersonalAccessTokens(); |
|
32 | - $router->forTransientTokens(); |
|
33 | - }); |
|
34 | - Passport::tokensExpireIn(\Carbon\Carbon::now()->addMinutes(config('skeleton.token_expire_in'))); |
|
35 | - Passport::refreshTokensExpireIn(\Carbon\Carbon::now()->addMinutes(config('skeleton.refresh_token_expire_in'))); |
|
36 | - } |
|
28 | + Passport::routes(function ($router) { |
|
29 | + $router->forAuthorization(); |
|
30 | + $router->forAccessTokens(); |
|
31 | + $router->forPersonalAccessTokens(); |
|
32 | + $router->forTransientTokens(); |
|
33 | + }); |
|
34 | + Passport::tokensExpireIn(\Carbon\Carbon::now()->addMinutes(config('skeleton.token_expire_in'))); |
|
35 | + Passport::refreshTokensExpireIn(\Carbon\Carbon::now()->addMinutes(config('skeleton.refresh_token_expire_in'))); |
|
36 | + } |
|
37 | 37 | } |
@@ -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 | } |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | $permission = $routeActions[1]; |
57 | 57 | |
58 | 58 | $this->auth->shouldUse('api'); |
59 | - if (! in_array($permission, $skipLoginCheck)) { |
|
60 | - $this->authMiddleware->handle($request, function ($request) use ($modelName, $skipPermissionCheck, $skipLoginCheck, $permission) { |
|
59 | + if ( ! in_array($permission, $skipLoginCheck)) { |
|
60 | + $this->authMiddleware->handle($request, function($request) use ($modelName, $skipPermissionCheck, $skipLoginCheck, $permission) { |
|
61 | 61 | $user = $this->auth->user(); |
62 | 62 | $isPasswordClient = $user->token()->client->password_client; |
63 | 63 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | if ($isPasswordClient && (in_array($permission, $skipPermissionCheck) || $this->userService->can($permission, $modelName))) { |
69 | - } elseif (! $isPasswordClient && $user->tokenCan($modelName.'-'.$permission)) { |
|
69 | + } elseif ( ! $isPasswordClient && $user->tokenCan($modelName.'-'.$permission)) { |
|
70 | 70 | } else { |
71 | 71 | \Errors::noPermissions(); |
72 | 72 | } |
@@ -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 | } |
@@ -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 | } |
@@ -6,67 +6,67 @@ |
||
6 | 6 | class SettingsObserver |
7 | 7 | { |
8 | 8 | |
9 | - public function saving($model) |
|
10 | - { |
|
11 | - // |
|
12 | - } |
|
9 | + public function saving($model) |
|
10 | + { |
|
11 | + // |
|
12 | + } |
|
13 | 13 | |
14 | - public function saved($model) |
|
15 | - { |
|
16 | - // |
|
17 | - } |
|
14 | + public function saved($model) |
|
15 | + { |
|
16 | + // |
|
17 | + } |
|
18 | 18 | |
19 | - /** |
|
20 | - * Prevent the creating of the settings. |
|
21 | - * |
|
22 | - * @param object $model the model beign created. |
|
23 | - * @return void |
|
24 | - */ |
|
25 | - public function creating($model) |
|
26 | - { |
|
27 | - \Errors::cannotCreateSetting(); |
|
28 | - } |
|
19 | + /** |
|
20 | + * Prevent the creating of the settings. |
|
21 | + * |
|
22 | + * @param object $model the model beign created. |
|
23 | + * @return void |
|
24 | + */ |
|
25 | + public function creating($model) |
|
26 | + { |
|
27 | + \Errors::cannotCreateSetting(); |
|
28 | + } |
|
29 | 29 | |
30 | - public function created($model) |
|
31 | - { |
|
32 | - // |
|
33 | - } |
|
30 | + public function created($model) |
|
31 | + { |
|
32 | + // |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * Prevent updating of the setting key. |
|
37 | - * |
|
38 | - * @param object $model the model beign updated. |
|
39 | - * @return void |
|
40 | - */ |
|
41 | - public function updating($model) |
|
42 | - { |
|
43 | - if ($model->getOriginal('key') !== $model->key) { |
|
44 | - \Errors::cannotUpdateSettingKey(); |
|
45 | - } |
|
46 | - } |
|
35 | + /** |
|
36 | + * Prevent updating of the setting key. |
|
37 | + * |
|
38 | + * @param object $model the model beign updated. |
|
39 | + * @return void |
|
40 | + */ |
|
41 | + public function updating($model) |
|
42 | + { |
|
43 | + if ($model->getOriginal('key') !== $model->key) { |
|
44 | + \Errors::cannotUpdateSettingKey(); |
|
45 | + } |
|
46 | + } |
|
47 | 47 | |
48 | - public function updated($model) |
|
49 | - { |
|
50 | - // |
|
51 | - } |
|
48 | + public function updated($model) |
|
49 | + { |
|
50 | + // |
|
51 | + } |
|
52 | 52 | |
53 | - public function deleting($model) |
|
54 | - { |
|
55 | - // |
|
56 | - } |
|
53 | + public function deleting($model) |
|
54 | + { |
|
55 | + // |
|
56 | + } |
|
57 | 57 | |
58 | - public function deleted($model) |
|
59 | - { |
|
60 | - // |
|
61 | - } |
|
58 | + public function deleted($model) |
|
59 | + { |
|
60 | + // |
|
61 | + } |
|
62 | 62 | |
63 | - public function restoring($model) |
|
64 | - { |
|
65 | - // |
|
66 | - } |
|
63 | + public function restoring($model) |
|
64 | + { |
|
65 | + // |
|
66 | + } |
|
67 | 67 | |
68 | - public function restored($model) |
|
69 | - { |
|
70 | - // |
|
71 | - } |
|
68 | + public function restored($model) |
|
69 | + { |
|
70 | + // |
|
71 | + } |
|
72 | 72 | } |
@@ -74,7 +74,7 @@ |
||
74 | 74 | if ($this->cacheConfig && $this->cacheConfig == 'cache') { |
75 | 75 | $page = \Request::get('page') !== null ? \Request::get('page') : '1'; |
76 | 76 | $cacheKey = $name.$page.\Session::get('locale').serialize($arguments); |
77 | - return $this->cache->tags([$this->cacheTag])->rememberForever($cacheKey, function () use ($arguments, $name) { |
|
77 | + return $this->cache->tags([$this->cacheTag])->rememberForever($cacheKey, function() use ($arguments, $name) { |
|
78 | 78 | return call_user_func_array([$this->repo, $name], $arguments); |
79 | 79 | }); |
80 | 80 | } elseif ($this->cacheConfig && $this->cacheConfig == 'clear') { |
@@ -7,101 +7,101 @@ |
||
7 | 7 | |
8 | 8 | class CachingDecorator |
9 | 9 | { |
10 | - /** |
|
11 | - * @var string |
|
12 | - */ |
|
13 | - public $repo; |
|
10 | + /** |
|
11 | + * @var string |
|
12 | + */ |
|
13 | + public $repo; |
|
14 | 14 | |
15 | - /** |
|
16 | - * @var Cache |
|
17 | - */ |
|
18 | - protected $cache; |
|
15 | + /** |
|
16 | + * @var Cache |
|
17 | + */ |
|
18 | + protected $cache; |
|
19 | 19 | |
20 | - /** |
|
21 | - * @var string |
|
22 | - */ |
|
23 | - public $modelKey; |
|
20 | + /** |
|
21 | + * @var string |
|
22 | + */ |
|
23 | + public $modelKey; |
|
24 | 24 | |
25 | - /** |
|
26 | - * @var string |
|
27 | - */ |
|
28 | - public $model; |
|
25 | + /** |
|
26 | + * @var string |
|
27 | + */ |
|
28 | + public $model; |
|
29 | 29 | |
30 | - /** |
|
31 | - * @var string |
|
32 | - */ |
|
33 | - public $modelClass; |
|
30 | + /** |
|
31 | + * @var string |
|
32 | + */ |
|
33 | + public $modelClass; |
|
34 | 34 | |
35 | - /** |
|
36 | - * @var mixed |
|
37 | - */ |
|
38 | - public $cacheConfig; |
|
35 | + /** |
|
36 | + * @var mixed |
|
37 | + */ |
|
38 | + public $cacheConfig; |
|
39 | 39 | |
40 | - /** |
|
41 | - * @var string |
|
42 | - */ |
|
43 | - public $cacheTag; |
|
40 | + /** |
|
41 | + * @var string |
|
42 | + */ |
|
43 | + public $cacheTag; |
|
44 | 44 | |
45 | - /** |
|
46 | - * Init new object. |
|
47 | - * |
|
48 | - * @param string $repo |
|
49 | - * @param Cache $cache |
|
50 | - * |
|
51 | - * @return void |
|
52 | - */ |
|
53 | - public function __construct($repo, Cache $cache) |
|
54 | - { |
|
55 | - $this->repo = $repo; |
|
56 | - $this->cache = $cache; |
|
57 | - $this->model = $this->repo->model; |
|
58 | - $this->modelClass = get_class($this->model); |
|
59 | - $repoClass = explode('\\', get_class($this->repo)); |
|
60 | - $repoName = end($repoClass); |
|
61 | - $this->cacheTag = lcfirst(substr($repoName, 0, strpos($repoName, 'Repository'))); |
|
62 | - } |
|
45 | + /** |
|
46 | + * Init new object. |
|
47 | + * |
|
48 | + * @param string $repo |
|
49 | + * @param Cache $cache |
|
50 | + * |
|
51 | + * @return void |
|
52 | + */ |
|
53 | + public function __construct($repo, Cache $cache) |
|
54 | + { |
|
55 | + $this->repo = $repo; |
|
56 | + $this->cache = $cache; |
|
57 | + $this->model = $this->repo->model; |
|
58 | + $this->modelClass = get_class($this->model); |
|
59 | + $repoClass = explode('\\', get_class($this->repo)); |
|
60 | + $repoName = end($repoClass); |
|
61 | + $this->cacheTag = lcfirst(substr($repoName, 0, strpos($repoName, 'Repository'))); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * Handle the cache mechanism for the called method |
|
66 | - * based the configurations. |
|
67 | - * |
|
68 | - * @param string $name the called method name |
|
69 | - * @param array $arguments the method arguments |
|
70 | - * @return object |
|
71 | - */ |
|
72 | - public function __call($name, $arguments) |
|
73 | - { |
|
74 | - $this->setCacheConfig($name); |
|
64 | + /** |
|
65 | + * Handle the cache mechanism for the called method |
|
66 | + * based the configurations. |
|
67 | + * |
|
68 | + * @param string $name the called method name |
|
69 | + * @param array $arguments the method arguments |
|
70 | + * @return object |
|
71 | + */ |
|
72 | + public function __call($name, $arguments) |
|
73 | + { |
|
74 | + $this->setCacheConfig($name); |
|
75 | 75 | |
76 | - if ($this->cacheConfig && $this->cacheConfig == 'cache') { |
|
77 | - $page = \Request::get('page') !== null ? \Request::get('page') : '1'; |
|
78 | - $cacheKey = $name.$page.\Session::get('locale').serialize($arguments); |
|
79 | - return $this->cache->tags([$this->cacheTag])->rememberForever($cacheKey, function () use ($arguments, $name) { |
|
80 | - return call_user_func_array([$this->repo, $name], $arguments); |
|
81 | - }); |
|
82 | - } elseif ($this->cacheConfig && $this->cacheConfig == 'clear') { |
|
83 | - $this->cache->tags($this->cacheConfig)->flush(); |
|
84 | - return call_user_func_array([$this->repo, $name], $arguments); |
|
85 | - } |
|
76 | + if ($this->cacheConfig && $this->cacheConfig == 'cache') { |
|
77 | + $page = \Request::get('page') !== null ? \Request::get('page') : '1'; |
|
78 | + $cacheKey = $name.$page.\Session::get('locale').serialize($arguments); |
|
79 | + return $this->cache->tags([$this->cacheTag])->rememberForever($cacheKey, function () use ($arguments, $name) { |
|
80 | + return call_user_func_array([$this->repo, $name], $arguments); |
|
81 | + }); |
|
82 | + } elseif ($this->cacheConfig && $this->cacheConfig == 'clear') { |
|
83 | + $this->cache->tags($this->cacheConfig)->flush(); |
|
84 | + return call_user_func_array([$this->repo, $name], $arguments); |
|
85 | + } |
|
86 | 86 | |
87 | - return call_user_func_array([$this->repo, $name], $arguments); |
|
88 | - } |
|
87 | + return call_user_func_array([$this->repo, $name], $arguments); |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * Set cache config based on the called method. |
|
92 | - * |
|
93 | - * @param string $name |
|
94 | - * @return void |
|
95 | - */ |
|
96 | - private function setCacheConfig($name) |
|
97 | - { |
|
98 | - $cacheConfig = Arr::get(config('core.cache_config'), $this->cacheTag, false); |
|
99 | - $this->cacheConfig = false; |
|
90 | + /** |
|
91 | + * Set cache config based on the called method. |
|
92 | + * |
|
93 | + * @param string $name |
|
94 | + * @return void |
|
95 | + */ |
|
96 | + private function setCacheConfig($name) |
|
97 | + { |
|
98 | + $cacheConfig = Arr::get(config('core.cache_config'), $this->cacheTag, false); |
|
99 | + $this->cacheConfig = false; |
|
100 | 100 | |
101 | - if ($cacheConfig && in_array($name, $cacheConfig['cache'])) { |
|
102 | - $this->cacheConfig = 'cache'; |
|
103 | - } elseif ($cacheConfig && isset($cacheConfig['clear'][$name])) { |
|
104 | - $this->cacheConfig = $cacheConfig['clear'][$name]; |
|
105 | - } |
|
106 | - } |
|
101 | + if ($cacheConfig && in_array($name, $cacheConfig['cache'])) { |
|
102 | + $this->cacheConfig = 'cache'; |
|
103 | + } elseif ($cacheConfig && isset($cacheConfig['clear'][$name])) { |
|
104 | + $this->cacheConfig = $cacheConfig['clear'][$name]; |
|
105 | + } |
|
106 | + } |
|
107 | 107 | } |