@@ -312,7 +312,7 @@ |
||
| 312 | 312 | return [ |
| 313 | 313 | 'full_name' => $user->full_name, |
| 314 | 314 | 'email' => $user->email, |
| 315 | - 'role_id' => (int) $user->role_id, |
|
| 315 | + 'role_id' => (int)$user->role_id, |
|
| 316 | 316 | 'created_at' => Carbon::parse($user->created_at)->setTimezone('UTC')->format(Carbon::ISO8601), |
| 317 | 317 | 'updated_at' => Carbon::parse($user->updated_at)->setTimezone('UTC')->format(Carbon::ISO8601), |
| 318 | 318 | 'created_by' => $user->created_by, |
@@ -101,7 +101,7 @@ |
||
| 101 | 101 | { |
| 102 | 102 | return [ |
| 103 | 103 | 'action' => $log->action, |
| 104 | - 'entity_id' => (int) $log->entity_id, |
|
| 104 | + 'entity_id' => (int)$log->entity_id, |
|
| 105 | 105 | 'entity_type' => $log->entity_type, |
| 106 | 106 | 'state' => $log->state, |
| 107 | 107 | 'created_at' => Carbon::parse($log->created_at)->setTimezone('UTC')->format(Carbon::ISO8601), |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | return [ |
| 18 | 18 | 'full_name' => $user->full_name, |
| 19 | 19 | 'email' => $user->email, |
| 20 | - 'role_id' => (int) $user->role_id, |
|
| 20 | + 'role_id' => (int)$user->role_id, |
|
| 21 | 21 | 'created_at' => Carbon::parse($user->created_at)->setTimezone('UTC')->format(Carbon::ISO8601), |
| 22 | 22 | 'updated_at' => Carbon::parse($user->updated_at)->setTimezone('UTC')->format(Carbon::ISO8601), |
| 23 | 23 | 'created_by' => $user->created_by, |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | public function creating(BaseModel $model) |
| 16 | 16 | { |
| 17 | 17 | $user = Auth::getUser(); |
| 18 | - if(!is_null($user)){ |
|
| 18 | + if (!is_null($user)) { |
|
| 19 | 19 | $model->created_by = $user->id; |
| 20 | 20 | } |
| 21 | 21 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | public function updating(BaseModel $model) |
| 31 | 31 | { |
| 32 | 32 | $user = Auth::getUser(); |
| 33 | - if(!is_null($user)){ |
|
| 33 | + if (!is_null($user)) { |
|
| 34 | 34 | $model->updated_by = $user->id; |
| 35 | 35 | } |
| 36 | 36 | } |
@@ -96,5 +96,5 @@ |
||
| 96 | 96 | | of "email". This simply helps us make messages a little cleaner. |
| 97 | 97 | | |
| 98 | 98 | */ |
| 99 | - 'attributes' => [ ], |
|
| 99 | + 'attributes' => [], |
|
| 100 | 100 | ]; |
| 101 | 101 | \ No newline at end of file |
@@ -12,8 +12,8 @@ |
||
| 12 | 12 | |
| 13 | 13 | public function actionIndex() |
| 14 | 14 | { |
| 15 | - echo 'This is sample console command.' . PHP_EOL; |
|
| 16 | - echo 'Actions: ' . PHP_EOL; |
|
| 17 | - echo 'partisan sample index' . PHP_EOL; |
|
| 15 | + echo 'This is sample console command.'.PHP_EOL; |
|
| 16 | + echo 'Actions: '.PHP_EOL; |
|
| 17 | + echo 'partisan sample index'.PHP_EOL; |
|
| 18 | 18 | } |
| 19 | 19 | } |
@@ -96,5 +96,5 @@ |
||
| 96 | 96 | | of "email". This simply helps us make messages a little cleaner. |
| 97 | 97 | | |
| 98 | 98 | */ |
| 99 | - 'attributes' => [ ], |
|
| 99 | + 'attributes' => [], |
|
| 100 | 100 | ]; |
| 101 | 101 | \ No newline at end of file |
@@ -8,13 +8,13 @@ discard block |
||
| 8 | 8 | // monolog settings |
| 9 | 9 | 'logger' => [ |
| 10 | 10 | 'name' => 'app', |
| 11 | - 'path' => __DIR__ . '/../log/app.log', |
|
| 11 | + 'path' => __DIR__.'/../log/app.log', |
|
| 12 | 12 | ], |
| 13 | 13 | |
| 14 | - 'mailTemplate' => __DIR__ . '/../mail', |
|
| 14 | + 'mailTemplate' => __DIR__.'/../mail', |
|
| 15 | 15 | |
| 16 | 16 | // DB |
| 17 | - 'database' => require(__DIR__ . '/../config/db.php'), |
|
| 17 | + 'database' => require(__DIR__.'/../config/db.php'), |
|
| 18 | 18 | |
| 19 | 19 | // ACL |
| 20 | 20 | 'acl' => |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * specified here so can be used in the code if needs be |
| 31 | 31 | * Example: ['user' => null] |
| 32 | 32 | */ |
| 33 | - 'resources' => [ ], |
|
| 33 | + 'resources' => [], |
|
| 34 | 34 | // where we specify the guarding! |
| 35 | 35 | 'guards' => [ |
| 36 | 36 | /* |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * if included all resources default to deny unless specified. |
| 40 | 40 | * Example: ['user', ['admin']] |
| 41 | 41 | */ |
| 42 | - 'resources' => [ ], |
|
| 42 | + 'resources' => [], |
|
| 43 | 43 | /* |
| 44 | 44 | * list of literal routes for guarding. |
| 45 | 45 | * optional |
@@ -48,8 +48,8 @@ discard block |
||
| 48 | 48 | * ['route', ['roles'], ['methods',' methods1']] |
| 49 | 49 | */ |
| 50 | 50 | 'routes' => [ |
| 51 | - ['/api/token', ['guest'], ['post']], |
|
| 52 | - ['/api/user', ['user'], ['get']], |
|
| 51 | + ['/api/token', ['guest'], ['post']], |
|
| 52 | + ['/api/user', ['user'], ['get']], |
|
| 53 | 53 | ], |
| 54 | 54 | /* |
| 55 | 55 | * list of callables to resolve against |
@@ -59,27 +59,27 @@ discard block |
||
| 59 | 59 | * ['callable', ['roles']] |
| 60 | 60 | */ |
| 61 | 61 | 'callables' => [ |
| 62 | - ['App\Controller\CrudController', ['user']], |
|
| 63 | - ['App\Controller\CrudController:actionIndex', ['user']], |
|
| 64 | - ['App\Controller\CrudController:actionGet', ['user']], |
|
| 65 | - ['App\Controller\CrudController:actionCreate', ['user']], |
|
| 66 | - ['App\Controller\CrudController:actionUpdate', ['user']], |
|
| 67 | - ['App\Controller\CrudController:actionDelete', ['user']], |
|
| 62 | + ['App\Controller\CrudController', ['user']], |
|
| 63 | + ['App\Controller\CrudController:actionIndex', ['user']], |
|
| 64 | + ['App\Controller\CrudController:actionGet', ['user']], |
|
| 65 | + ['App\Controller\CrudController:actionCreate', ['user']], |
|
| 66 | + ['App\Controller\CrudController:actionUpdate', ['user']], |
|
| 67 | + ['App\Controller\CrudController:actionDelete', ['user']], |
|
| 68 | 68 | |
| 69 | - ['App\Controller\UserController:actionIndex', ['admin']], |
|
| 70 | - ['App\Controller\UserController:actionGet', ['admin']], |
|
| 69 | + ['App\Controller\UserController:actionIndex', ['admin']], |
|
| 70 | + ['App\Controller\UserController:actionGet', ['admin']], |
|
| 71 | 71 | ['App\Controller\UserController:actionCreate', ['admin']], |
| 72 | 72 | ['App\Controller\UserController:actionUpdate', ['admin']], |
| 73 | - ['App\Controller\UserController:actionDelete', ['user']], |
|
| 73 | + ['App\Controller\UserController:actionDelete', ['user']], |
|
| 74 | 74 | ] |
| 75 | 75 | ] |
| 76 | 76 | ], |
| 77 | 77 | |
| 78 | 78 | 'translate' => [ |
| 79 | - 'path' => __DIR__ . '/../lang', |
|
| 79 | + 'path' => __DIR__.'/../lang', |
|
| 80 | 80 | 'locale' => 'ru', |
| 81 | 81 | ], |
| 82 | 82 | |
| 83 | - 'params' => require(__DIR__ . '/../config/params.php'), |
|
| 83 | + 'params' => require(__DIR__.'/../config/params.php'), |
|
| 84 | 84 | ], |
| 85 | 85 | ]; |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | /* |
| 12 | 12 | * Auth && ACL Middleware |
| 13 | 13 | */ |
| 14 | -$app->add(function (Request $request, Response $response, $next) { |
|
| 14 | +$app->add(function(Request $request, Response $response, $next) { |
|
| 15 | 15 | // If path is "/api/token" or "/api/user/request-password-reset" or "/api/user/reset-password" no need authorization process |
| 16 | 16 | $path = $request->getUri()->getPath(); |
| 17 | 17 | if (in_array($path, ['/api/token', '/api/user/request-password-reset', '/api/user/reset-password'])) { |
@@ -36,14 +36,14 @@ discard block |
||
| 36 | 36 | $route = $request->getAttribute('route'); |
| 37 | 37 | |
| 38 | 38 | if ($route) { |
| 39 | - if ($this->acl->hasResource('route' . $route->getPattern())) { |
|
| 40 | - $isAllowed = $isAllowed || $this->acl->isAllowed($user->role->name, 'route' . $route->getPattern(), strtolower($request->getMethod())); |
|
| 39 | + if ($this->acl->hasResource('route'.$route->getPattern())) { |
|
| 40 | + $isAllowed = $isAllowed || $this->acl->isAllowed($user->role->name, 'route'.$route->getPattern(), strtolower($request->getMethod())); |
|
| 41 | 41 | } |
| 42 | - if ($this->acl->hasResource('callable/' . $route->getCallable())) { |
|
| 43 | - $isAllowed = $isAllowed || $this->acl->isAllowed($user->role->name, 'callable/' . $route->getCallable()); |
|
| 42 | + if ($this->acl->hasResource('callable/'.$route->getCallable())) { |
|
| 43 | + $isAllowed = $isAllowed || $this->acl->isAllowed($user->role->name, 'callable/'.$route->getCallable()); |
|
| 44 | 44 | } |
| 45 | 45 | if (!$isAllowed) { |
| 46 | - throw new JsonException(null, 403, 'Not allowed', $user->role->name . ' is not allowed access to this location.'); |
|
| 46 | + throw new JsonException(null, 403, 'Not allowed', $user->role->name.' is not allowed access to this location.'); |
|
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | /* |
| 59 | 59 | * Logger |
| 60 | 60 | */ |
| 61 | -$app->add(function (Request $request, Response $response, $next) { |
|
| 61 | +$app->add(function(Request $request, Response $response, $next) { |
|
| 62 | 62 | $logger = $this->logger; |
| 63 | 63 | $response = $next($request, $response); |
| 64 | 64 | $uri = $request->getUri()->getPath(); |
@@ -99,10 +99,10 @@ discard block |
||
| 99 | 99 | /** |
| 100 | 100 | * Custom exception |
| 101 | 101 | */ |
| 102 | -$app->add(function (Request $request, Response $response, $next) { |
|
| 102 | +$app->add(function(Request $request, Response $response, $next) { |
|
| 103 | 103 | try { |
| 104 | 104 | return $next($request, $response); |
| 105 | - } catch (JsonException $e){ |
|
| 105 | + } catch (JsonException $e) { |
|
| 106 | 106 | return $this->renderer->jsonApiRender($response, $e->statusCode, $e->encodeError()); |
| 107 | 107 | } |
| 108 | 108 | }); |