@@ -2,17 +2,14 @@ |
||
| 2 | 2 | use Illuminate\Database\Capsule\Manager as Capsule; |
| 3 | 3 | use Illuminate\Events\Dispatcher; |
| 4 | 4 | use Illuminate\Container\Container; |
| 5 | - |
|
| 6 | 5 | use Monolog\Logger; |
| 7 | 6 | use Monolog\Processor\UidProcessor; |
| 8 | 7 | use Monolog\Handler\StreamHandler; |
| 9 | - |
|
| 10 | 8 | use Illuminate\Translation\FileLoader; |
| 11 | 9 | use Illuminate\Filesystem\Filesystem; |
| 12 | 10 | use Illuminate\Translation\Translator; |
| 13 | 11 | use Illuminate\Validation\DatabasePresenceVerifier; |
| 14 | 12 | use Illuminate\Validation\Factory; |
| 15 | - |
|
| 16 | 13 | use App\Common\Acl; |
| 17 | 14 | use App\Common\Renderer; |
| 18 | 15 | use App\Common\MailRenderer; |
@@ -22,20 +22,20 @@ discard block |
||
| 22 | 22 | $container = $app->getContainer(); |
| 23 | 23 | |
| 24 | 24 | // render |
| 25 | -$container['renderer'] = function($c){ |
|
| 25 | +$container['renderer'] = function($c) { |
|
| 26 | 26 | $renderer = new Renderer(); |
| 27 | 27 | |
| 28 | 28 | return $renderer; |
| 29 | 29 | }; |
| 30 | 30 | |
| 31 | -$container['mailRenderer'] = function($c){ |
|
| 31 | +$container['mailRenderer'] = function($c) { |
|
| 32 | 32 | $settings = $c->get('settings'); |
| 33 | 33 | $renderer = new MailRenderer($settings['mailTemplate']); |
| 34 | 34 | return $renderer; |
| 35 | 35 | }; |
| 36 | 36 | |
| 37 | 37 | // monolog |
| 38 | -$container['logger'] = function ($c) { |
|
| 38 | +$container['logger'] = function($c) { |
|
| 39 | 39 | $settings = $c->get('settings'); |
| 40 | 40 | $logger = new Logger($settings['logger']['name']); |
| 41 | 41 | $logger->pushProcessor(new UidProcessor()); |
@@ -45,8 +45,8 @@ discard block |
||
| 45 | 45 | }; |
| 46 | 46 | |
| 47 | 47 | // error handlers |
| 48 | -$container['errorHandler'] = function ($c) { |
|
| 49 | - return function ($request, $response, $exception) use ($c) { |
|
| 48 | +$container['errorHandler'] = function($c) { |
|
| 49 | + return function($request, $response, $exception) use ($c) { |
|
| 50 | 50 | $details = (defined('DEBUG_MODE') && DEBUG_MODE == 1) ? $exception->getMessage() : 'Internal server error'; |
| 51 | 51 | $e = new JsonException(null, 500, 'Internal server error', $details); |
| 52 | 52 | |
@@ -54,14 +54,14 @@ discard block |
||
| 54 | 54 | }; |
| 55 | 55 | }; |
| 56 | 56 | |
| 57 | -$container['notAllowedHandler'] = function ($c) { |
|
| 58 | - return function ($request, $response, $methods) use ($c) { |
|
| 59 | - throw new JsonException(null, 405, 'Method Not Allowed', 'Method must be one of: ' . implode(', ', $methods)); |
|
| 57 | +$container['notAllowedHandler'] = function($c) { |
|
| 58 | + return function($request, $response, $methods) use ($c) { |
|
| 59 | + throw new JsonException(null, 405, 'Method Not Allowed', 'Method must be one of: '.implode(', ', $methods)); |
|
| 60 | 60 | }; |
| 61 | 61 | }; |
| 62 | 62 | |
| 63 | -$container['notFoundHandler'] = function ($c) { |
|
| 64 | - return function ($request, $response) use ($c) { |
|
| 63 | +$container['notFoundHandler'] = function($c) { |
|
| 64 | + return function($request, $response) use ($c) { |
|
| 65 | 65 | throw new JsonException(null, 404, 'Not found', 'Entity not found'); |
| 66 | 66 | }; |
| 67 | 67 | }; |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | // database |
| 70 | 70 | $setting = $container->get('settings'); |
| 71 | 71 | $capsule = new Capsule; |
| 72 | -foreach ($setting['database']['connections'] as $name => $connection){ |
|
| 72 | +foreach ($setting['database']['connections'] as $name => $connection) { |
|
| 73 | 73 | $capsule->addConnection($connection, $name); |
| 74 | 74 | } |
| 75 | 75 | $capsule->setEventDispatcher(new Dispatcher(new Container)); |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | $container['databaseManager'] = $capsule->getDatabaseManager(); |
| 80 | 80 | |
| 81 | 81 | // ACL |
| 82 | -$container['acl'] = function ($c) { |
|
| 82 | +$container['acl'] = function($c) { |
|
| 83 | 83 | $settings = $c->get('settings'); |
| 84 | 84 | $acl = new Acl($settings['acl']); |
| 85 | 85 | |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | }; |
| 88 | 88 | |
| 89 | 89 | // translation |
| 90 | -$container['translator'] = function($c){ |
|
| 90 | +$container['translator'] = function($c) { |
|
| 91 | 91 | $settings = $c->get('settings'); |
| 92 | 92 | $translation_file_loader = new FileLoader(new Filesystem, $settings['translate']['path']); |
| 93 | 93 | $translator = new Translator($translation_file_loader, $settings['translate']['locale']); |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | }; |
| 97 | 97 | |
| 98 | 98 | // validation |
| 99 | -$container['validation'] = function($c){ |
|
| 99 | +$container['validation'] = function($c) { |
|
| 100 | 100 | $translator = $c->get('translator'); |
| 101 | 101 | $validation = new Factory($translator); |
| 102 | 102 | $presence = new DatabasePresenceVerifier($c->get('databaseManager')); |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | }; |
| 107 | 107 | |
| 108 | 108 | // mailer |
| 109 | -$container['mailer'] = function($c){ |
|
| 109 | +$container['mailer'] = function($c) { |
|
| 110 | 110 | $transport = \Swift_MailTransport::newInstance(); |
| 111 | 111 | $mailer = \Swift_Mailer::newInstance($transport); |
| 112 | 112 | |
@@ -22,13 +22,13 @@ discard block |
||
| 22 | 22 | $container = $app->getContainer(); |
| 23 | 23 | |
| 24 | 24 | // render |
| 25 | -$container['renderer'] = function($c){ |
|
| 25 | +$container['renderer'] = function($c) { |
|
| 26 | 26 | $renderer = new Renderer(); |
| 27 | 27 | |
| 28 | 28 | return $renderer; |
| 29 | 29 | }; |
| 30 | 30 | |
| 31 | -$container['mailRenderer'] = function($c){ |
|
| 31 | +$container['mailRenderer'] = function($c) { |
|
| 32 | 32 | $settings = $c->get('settings'); |
| 33 | 33 | $renderer = new MailRenderer($settings['mailTemplate']); |
| 34 | 34 | return $renderer; |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | // database |
| 70 | 70 | $setting = $container->get('settings'); |
| 71 | 71 | $capsule = new Capsule; |
| 72 | -foreach ($setting['database']['connections'] as $name => $connection){ |
|
| 72 | +foreach ($setting['database']['connections'] as $name => $connection) { |
|
| 73 | 73 | $capsule->addConnection($connection, $name); |
| 74 | 74 | } |
| 75 | 75 | $capsule->setEventDispatcher(new Dispatcher(new Container)); |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | }; |
| 88 | 88 | |
| 89 | 89 | // translation |
| 90 | -$container['translator'] = function($c){ |
|
| 90 | +$container['translator'] = function($c) { |
|
| 91 | 91 | $settings = $c->get('settings'); |
| 92 | 92 | $translation_file_loader = new FileLoader(new Filesystem, $settings['translate']['path']); |
| 93 | 93 | $translator = new Translator($translation_file_loader, $settings['translate']['locale']); |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | }; |
| 97 | 97 | |
| 98 | 98 | // validation |
| 99 | -$container['validation'] = function($c){ |
|
| 99 | +$container['validation'] = function($c) { |
|
| 100 | 100 | $translator = $c->get('translator'); |
| 101 | 101 | $validation = new Factory($translator); |
| 102 | 102 | $presence = new DatabasePresenceVerifier($c->get('databaseManager')); |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | }; |
| 107 | 107 | |
| 108 | 108 | // mailer |
| 109 | -$container['mailer'] = function($c){ |
|
| 109 | +$container['mailer'] = function($c) { |
|
| 110 | 110 | $transport = \Swift_MailTransport::newInstance(); |
| 111 | 111 | $mailer = \Swift_Mailer::newInstance($transport); |
| 112 | 112 | |
@@ -2,10 +2,8 @@ |
||
| 2 | 2 | use \Slim\Http\Request; |
| 3 | 3 | use \Slim\Http\Response; |
| 4 | 4 | use App\Controller\TokenController as Token; |
| 5 | - |
|
| 6 | 5 | use App\Common\Auth; |
| 7 | 6 | use App\Common\JsonException; |
| 8 | - |
|
| 9 | 7 | use App\Model\User; |
| 10 | 8 | |
| 11 | 9 | /* |
@@ -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 | }); |
| 109 | 109 | \ No newline at end of file |
@@ -102,7 +102,7 @@ |
||
| 102 | 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 | }); |
| 109 | 109 | \ No newline at end of file |
@@ -5,7 +5,6 @@ |
||
| 5 | 5 | use App\Model; |
| 6 | 6 | use App\Common\JsonException; |
| 7 | 7 | use App\Common\Auth; |
| 8 | - |
|
| 9 | 8 | use App\Requests\IRequest; |
| 10 | 9 | use \Neomerx\JsonApi\Encoder\Encoder; |
| 11 | 10 | use \Neomerx\JsonApi\Encoder\EncoderOptions; |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | /** |
| 164 | 164 | * Register model observers |
| 165 | 165 | */ |
| 166 | - private function registerModelObservers(){ |
|
| 166 | + private function registerModelObservers() { |
|
| 167 | 167 | $observers = [ |
| 168 | 168 | Observers\CreatedByAndUpdatedByObserver::class => [ |
| 169 | 169 | Model\Right::class, |
@@ -178,9 +178,9 @@ discard block |
||
| 178 | 178 | ] |
| 179 | 179 | ]; |
| 180 | 180 | |
| 181 | - foreach($observers as $observer => $models){ |
|
| 182 | - foreach($models as $model){ |
|
| 183 | - call_user_func($model. '::observe', $observer); |
|
| 181 | + foreach ($observers as $observer => $models) { |
|
| 182 | + foreach ($models as $model) { |
|
| 183 | + call_user_func($model.'::observe', $observer); |
|
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | } |
@@ -163,7 +163,8 @@ discard block |
||
| 163 | 163 | /** |
| 164 | 164 | * Register model observers |
| 165 | 165 | */ |
| 166 | - private function registerModelObservers(){ |
|
| 166 | + private function registerModelObservers() |
|
| 167 | + { |
|
| 167 | 168 | $observers = [ |
| 168 | 169 | Observers\CreatedByAndUpdatedByObserver::class => [ |
| 169 | 170 | Model\Right::class, |
@@ -178,8 +179,8 @@ discard block |
||
| 178 | 179 | ] |
| 179 | 180 | ]; |
| 180 | 181 | |
| 181 | - foreach($observers as $observer => $models){ |
|
| 182 | - foreach($models as $model){ |
|
| 182 | + foreach($observers as $observer => $models) { |
|
| 183 | + foreach($models as $model) { |
|
| 183 | 184 | call_user_func($model. '::observe', $observer); |
| 184 | 185 | } |
| 185 | 186 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * @param Response $response |
| 16 | 16 | * @param array $args |
| 17 | 17 | * |
| 18 | - * @return mixed |
|
| 18 | + * @return \Psr\Http\Message\ResponseInterface |
|
| 19 | 19 | */ |
| 20 | 20 | public function actionIndex(Request $request, Response $response, $args) |
| 21 | 21 | { |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | * @param Response $response |
| 88 | 88 | * @param array $args |
| 89 | 89 | * |
| 90 | - * @return mixed |
|
| 90 | + * @return \Psr\Http\Message\ResponseInterface |
|
| 91 | 91 | * @throws JsonException |
| 92 | 92 | */ |
| 93 | 93 | public function actionGet(Request $request, Response $response, $args) |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | * @param Response $response |
| 111 | 111 | * @param array $args |
| 112 | 112 | * |
| 113 | - * @return mixed |
|
| 113 | + * @return \Psr\Http\Message\ResponseInterface |
|
| 114 | 114 | * @throws JsonException |
| 115 | 115 | */ |
| 116 | 116 | public function actionCreate(Request $request, Response $response, $args) |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | * @param Response $response |
| 134 | 134 | * @param array $args |
| 135 | 135 | * |
| 136 | - * @return mixed |
|
| 136 | + * @return \Psr\Http\Message\ResponseInterface |
|
| 137 | 137 | * @throws JsonException |
| 138 | 138 | */ |
| 139 | 139 | public function actionUpdate(Request $request, Response $response, $args) |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | * @param Response $response |
| 163 | 163 | * @param array $args |
| 164 | 164 | * |
| 165 | - * @return mixed |
|
| 165 | + * @return \Psr\Http\Message\ResponseInterface |
|
| 166 | 166 | * @throws JsonException |
| 167 | 167 | */ |
| 168 | 168 | public function actionDelete(Request $request, Response $response, $args) |
@@ -4,7 +4,6 @@ |
||
| 4 | 4 | use App\Common\Helper; |
| 5 | 5 | use App\Common\JsonException; |
| 6 | 6 | use App\Scopes\MaxPerPageScope; |
| 7 | - |
|
| 8 | 7 | use Slim\Http\Request; |
| 9 | 8 | use Slim\Http\Response; |
| 10 | 9 | |
@@ -44,7 +44,7 @@ |
||
| 44 | 44 | $query = $query->whereNotIn($filter['attribute'], $filter['value']); |
| 45 | 45 | break; |
| 46 | 46 | case 'like': |
| 47 | - $query = $query->where($filter['attribute'], 'like', '%' . $filter['value'] . '%'); |
|
| 47 | + $query = $query->where($filter['attribute'], 'like', '%'.$filter['value'].'%'); |
|
| 48 | 48 | break; |
| 49 | 49 | case '=': |
| 50 | 50 | case '!=': |
@@ -34,7 +34,9 @@ |
||
| 34 | 34 | $filter['operator'] = trim(strtolower($filter['operator'])); |
| 35 | 35 | $filter['attribute'] = trim($filter['attribute']); |
| 36 | 36 | |
| 37 | - if (empty($filter['operator']) || empty($filter['attribute']) || empty($filter['value'])) continue; |
|
| 37 | + if (empty($filter['operator']) || empty($filter['attribute']) || empty($filter['value'])) { |
|
| 38 | + continue; |
|
| 39 | + } |
|
| 38 | 40 | |
| 39 | 41 | switch ($filter['operator']) { |
| 40 | 42 | case 'in': |
@@ -97,7 +97,7 @@ |
||
| 97 | 97 | * @param Response $response |
| 98 | 98 | * @param array $args |
| 99 | 99 | * |
| 100 | - * @return mixed |
|
| 100 | + * @return \Psr\Http\Message\ResponseInterface |
|
| 101 | 101 | * @throws JsonException |
| 102 | 102 | */ |
| 103 | 103 | public function auth(Request $request, Response $response, $args) |
@@ -4,10 +4,8 @@ |
||
| 4 | 4 | use App\Requests\GetTokenRequest; |
| 5 | 5 | use Firebase\JWT\JWT; |
| 6 | 6 | use App\Model\User; |
| 7 | - |
|
| 8 | 7 | use Slim\Http\Request; |
| 9 | 8 | use Slim\Http\Response; |
| 10 | - |
|
| 11 | 9 | use App\Common\JsonException; |
| 12 | 10 | |
| 13 | 11 | final class TokenController extends BaseController |
@@ -45,7 +45,7 @@ |
||
| 45 | 45 | return false; |
| 46 | 46 | } |
| 47 | 47 | return true; |
| 48 | - } catch (\Exception $e){ |
|
| 48 | + } catch (\Exception $e) { |
|
| 49 | 49 | return false; |
| 50 | 50 | } |
| 51 | 51 | } |
@@ -45,7 +45,7 @@ |
||
| 45 | 45 | return false; |
| 46 | 46 | } |
| 47 | 47 | return true; |
| 48 | - } catch (\Exception $e){ |
|
| 48 | + } catch (\Exception $e) { |
|
| 49 | 49 | return false; |
| 50 | 50 | } |
| 51 | 51 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | * @param Response $response |
| 20 | 20 | * @param array $args |
| 21 | 21 | * |
| 22 | - * @return mixed |
|
| 22 | + * @return \Psr\Http\Message\ResponseInterface |
|
| 23 | 23 | * @throws JsonException |
| 24 | 24 | */ |
| 25 | 25 | public function actionCreate(Request $request, Response $response, $args) |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * @param Response $response |
| 49 | 49 | * @param array $args |
| 50 | 50 | * |
| 51 | - * @return mixed |
|
| 51 | + * @return \Psr\Http\Message\ResponseInterface |
|
| 52 | 52 | * @throws JsonException |
| 53 | 53 | */ |
| 54 | 54 | public function actionUpdate(Request $request, Response $response, $args) |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * @param Response $response |
| 81 | 81 | * @param array $args |
| 82 | 82 | * |
| 83 | - * @return mixed |
|
| 83 | + * @return \Psr\Http\Message\ResponseInterface |
|
| 84 | 84 | * @throws JsonException |
| 85 | 85 | */ |
| 86 | 86 | public function actionRequestResetPassword(Request $request, Response $response, $args) |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | * @param Response $response |
| 127 | 127 | * @param array $args |
| 128 | 128 | * |
| 129 | - * @return mixed |
|
| 129 | + * @return \Psr\Http\Message\ResponseInterface |
|
| 130 | 130 | * @throws JsonException |
| 131 | 131 | */ |
| 132 | 132 | public function actionResetPassword(Request $request, Response $response, $args) |
@@ -3,12 +3,10 @@ |
||
| 3 | 3 | |
| 4 | 4 | use App\Model\User; |
| 5 | 5 | use App\Common\JsonException; |
| 6 | - |
|
| 7 | 6 | use App\Requests\RequestResetPasswordRequest; |
| 8 | 7 | use App\Requests\ResetPasswordRequest; |
| 9 | 8 | use App\Requests\UserCreateRequest; |
| 10 | 9 | use App\Requests\UserUpdateRequest; |
| 11 | - |
|
| 12 | 10 | use Slim\Http\Request; |
| 13 | 11 | use Slim\Http\Response; |
| 14 | 12 | |
@@ -141,7 +141,7 @@ |
||
| 141 | 141 | $user->setPassword($params['data']['attributes']['password']); |
| 142 | 142 | $user->removePasswordResetToken(); |
| 143 | 143 | |
| 144 | - if($user->save()){ |
|
| 144 | + if ($user->save()) { |
|
| 145 | 145 | return $this->renderer->jsonApiRender($response, 204); |
| 146 | 146 | }; |
| 147 | 147 | } |
@@ -141,7 +141,7 @@ |
||
| 141 | 141 | $user->setPassword($params['data']['attributes']['password']); |
| 142 | 142 | $user->removePasswordResetToken(); |
| 143 | 143 | |
| 144 | - if($user->save()){ |
|
| 144 | + if($user->save()) { |
|
| 145 | 145 | return $this->renderer->jsonApiRender($response, 204); |
| 146 | 146 | }; |
| 147 | 147 | } |
@@ -13,22 +13,22 @@ |
||
| 13 | 13 | }; |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | -require __DIR__ . '/../vendor/autoload.php'; |
|
| 16 | +require __DIR__.'/../vendor/autoload.php'; |
|
| 17 | 17 | |
| 18 | 18 | session_start(); |
| 19 | 19 | |
| 20 | -$settings = require __DIR__ . '/../app/settings.php'; |
|
| 20 | +$settings = require __DIR__.'/../app/settings.php'; |
|
| 21 | 21 | |
| 22 | 22 | $app = new \Slim\App($settings); |
| 23 | 23 | |
| 24 | 24 | // Set up dependencies |
| 25 | -require __DIR__ . '/../app/dependencies.php'; |
|
| 25 | +require __DIR__.'/../app/dependencies.php'; |
|
| 26 | 26 | |
| 27 | 27 | // Register middleware |
| 28 | -require __DIR__ . '/../app/middleware.php'; |
|
| 28 | +require __DIR__.'/../app/middleware.php'; |
|
| 29 | 29 | |
| 30 | 30 | // Register routes |
| 31 | -require __DIR__ . '/../app/routes.php'; |
|
| 31 | +require __DIR__.'/../app/routes.php'; |
|
| 32 | 32 | |
| 33 | 33 | // Run! |
| 34 | 34 | $app->run(); |
| 35 | 35 | \ No newline at end of file |
@@ -5,7 +5,8 @@ |
||
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | // Super debug func |
| 8 | -function prr($value) { |
|
| 8 | +function prr($value) |
|
| 9 | +{ |
|
| 9 | 10 | if (defined('DEBUG_MODE') && DEBUG_MODE == 1) { |
| 10 | 11 | echo '<pre>'; |
| 11 | 12 | print_r($value); |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // Routes |
| 3 | -$app->group('/api', function () { |
|
| 4 | - $this->options('[/{params:.*}]', function ($request, $response, $args) { |
|
| 3 | +$app->group('/api', function() { |
|
| 4 | + $this->options('[/{params:.*}]', function($request, $response, $args) { |
|
| 5 | 5 | return $response->withHeader('Access-Control-Allow-Origin', '*') |
| 6 | 6 | ->withHeader('Access-Control-Allow-Methods', 'GET, PUT, PATCH, POST, DELETE, OPTIONS') |
| 7 | 7 | ->withHeader('Access-Control-Allow-Credentials', 'true') |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | $this->post('/token', 'App\Controller\TokenController:auth'); |
| 13 | 13 | |
| 14 | - $this->group('/{entity:user}', function () { |
|
| 14 | + $this->group('/{entity:user}', function() { |
|
| 15 | 15 | $this->get('', 'App\Controller\UserController:actionIndex'); |
| 16 | 16 | $this->post('', 'App\Controller\UserController:actionCreate'); |
| 17 | 17 | $this->get('/{id:[0-9]+}', 'App\Controller\UserController:actionGet'); |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | $this->post('/reset-password', 'App\Controller\UserController:actionResetPassword'); |
| 23 | 23 | }); |
| 24 | 24 | |
| 25 | - $this->group('/{entity:role|right}', function () { |
|
| 25 | + $this->group('/{entity:role|right}', function() { |
|
| 26 | 26 | $this->get('', 'App\Controller\CrudController:actionIndex'); |
| 27 | 27 | $this->get('/{id:[0-9]+}', 'App\Controller\CrudController:actionGet'); |
| 28 | 28 | $this->post('', 'App\Controller\CrudController:actionCreate'); |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | $this->delete('/{id:[0-9]+}', 'App\Controller\CrudController:actionDelete'); |
| 31 | 31 | }); |
| 32 | 32 | |
| 33 | - $this->group('/{entity:log}', function () { |
|
| 33 | + $this->group('/{entity:log}', function() { |
|
| 34 | 34 | $this->get('', 'App\Controller\CrudController:actionIndex'); |
| 35 | 35 | $this->get('/{id:[0-9]+}', 'App\Controller\CrudController:actionGet'); |
| 36 | 36 | }); |
@@ -8,8 +8,7 @@ |
||
| 8 | 8 | */ |
| 9 | 9 | public function up() |
| 10 | 10 | { |
| 11 | - Capsule::schema()->create('roles', function($table) |
|
| 12 | - { |
|
| 11 | + Capsule::schema()->create('roles', function($table) { |
|
| 13 | 12 | $table->increments('id'); |
| 14 | 13 | $table->string('name')->unique(); |
| 15 | 14 | $table->string('description'); |