@@ -23,15 +23,15 @@ discard block |
||
23 | 23 | 'path' => __DIR__ . '/../storage/logs/app.log', |
24 | 24 | ], |
25 | 25 | 'db' => [ |
26 | - 'driver' => $env($APPROOT,'DB_DRIVER', 'mysql'), |
|
27 | - 'host' => $env($APPROOT,'DB_HOST', 'localhost'), |
|
28 | - 'database' => $env($APPROOT,'DB_NAME', 'cafesaba'), |
|
29 | - 'username' => $env($APPROOT,'DB_USERNAME', 'root'), |
|
30 | - 'password' => $env($APPROOT,'DB_PASS', 'root'), |
|
31 | - 'charset' => $env($APPROOT,'DB_CHARSET', 'utf8'), |
|
32 | - 'collation' => $env($APPROOT,'DB_COLLATION', 'utf8_unicode_ci'), |
|
33 | - 'prefix' => $env($APPROOT,'DB_PREFIX', ''), |
|
34 | - 'port' => $env($APPROOT,'DB_PORT', 3306), |
|
26 | + 'driver' => $env($APPROOT, 'DB_DRIVER', 'mysql'), |
|
27 | + 'host' => $env($APPROOT, 'DB_HOST', 'localhost'), |
|
28 | + 'database' => $env($APPROOT, 'DB_NAME', 'cafesaba'), |
|
29 | + 'username' => $env($APPROOT, 'DB_USERNAME', 'root'), |
|
30 | + 'password' => $env($APPROOT, 'DB_PASS', 'root'), |
|
31 | + 'charset' => $env($APPROOT, 'DB_CHARSET', 'utf8'), |
|
32 | + 'collation' => $env($APPROOT, 'DB_COLLATION', 'utf8_unicode_ci'), |
|
33 | + 'prefix' => $env($APPROOT, 'DB_PREFIX', ''), |
|
34 | + 'port' => $env($APPROOT, 'DB_PORT', 3306), |
|
35 | 35 | ], |
36 | 36 | 'view' => [ |
37 | 37 | 'path' => '../app/View', |
@@ -49,11 +49,11 @@ discard block |
||
49 | 49 | 'showSlimEnvironmentPanel' => 1, |
50 | 50 | 'showSlimRequestPanel' => 1, |
51 | 51 | 'showSlimResponsePanel' => 1, |
52 | - 'showSlimContainer' =>1 , |
|
52 | + 'showSlimContainer' =>1, |
|
53 | 53 | 'showEloquentORMPanel' => 1, |
54 | - 'showIdiormPanel' => 0,// > 0 mean you enable logging |
|
54 | + 'showIdiormPanel' => 0, // > 0 mean you enable logging |
|
55 | 55 | // but show or not panel you decide in browser in panel selector |
56 | - 'showDoctrinePanel' => 'em',// here also enable logging and you must enter your Doctrine container name |
|
56 | + 'showDoctrinePanel' => 'em', // here also enable logging and you must enter your Doctrine container name |
|
57 | 57 | // and also as above show or not panel you decide in browser in panel selector |
58 | 58 | 'showProfilerPanel' => 1, |
59 | 59 | 'showVendorVersionsPanel' => 1, |
@@ -16,7 +16,7 @@ |
||
16 | 16 | |
17 | 17 | Facade::setFacadeApplication($app); |
18 | 18 | $settings['tracy']['path'] = ''; |
19 | -if($app->getContainer() instanceof Psr\Container\ContainerInterface){ |
|
19 | +if ($app->getContainer() instanceof Psr\Container\ContainerInterface) { |
|
20 | 20 | $settings = $app->getContainer()->settings; |
21 | 21 | } |
22 | 22 |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | /* database connection */ |
7 | 7 | |
8 | 8 | |
9 | -$container['db'] = function ($container) { |
|
9 | +$container['db'] = function($container) { |
|
10 | 10 | $db = $container['settings']['db']; |
11 | 11 | $pdo = new PDO("mysql:host=" . $db['host'] . ";dbname=" . $db['database'], |
12 | 12 | $db['username'], $db['password']); |
@@ -18,19 +18,19 @@ discard block |
||
18 | 18 | // |
19 | 19 | |
20 | 20 | |
21 | -$c['generalErrorHandler'] = function ($container) { |
|
21 | +$c['generalErrorHandler'] = function($container) { |
|
22 | 22 | return new \Core\Handlers\GeneralErrorHandler($container); |
23 | 23 | }; |
24 | 24 | |
25 | 25 | |
26 | 26 | |
27 | 27 | // Service factory for the ORM |
28 | -$container['validator'] = function () { |
|
28 | +$container['validator'] = function() { |
|
29 | 29 | return new App\Validation\Validator(); |
30 | 30 | }; |
31 | 31 | |
32 | 32 | |
33 | -$container['eloquent'] = function ($container) { |
|
33 | +$container['eloquent'] = function($container) { |
|
34 | 34 | $capsule = new \Illuminate\Database\Capsule\Manager; |
35 | 35 | $capsule->addConnection($container['settings']['db']); |
36 | 36 | $capsule->setAsGlobal(); |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | |
50 | 50 | // monolog |
51 | -$container['logger'] = function ($c) { |
|
51 | +$container['logger'] = function($c) { |
|
52 | 52 | $settings = $c->get('settings')['logger']; |
53 | 53 | $logger = new Monolog\Logger($settings['name']); |
54 | 54 | $logger->pushProcessor(new Monolog\Processor\UidProcessor()); |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | }; |
58 | 58 | |
59 | 59 | // Register Blade View helper |
60 | -$container['view'] = function ($container) { |
|
60 | +$container['view'] = function($container) { |
|
61 | 61 | |
62 | 62 | $messages = $container->flash->getMessages(); |
63 | 63 | |
64 | 64 | $viewSettings = $container['settings']['view']; |
65 | 65 | return new \Slim\Views\Blade( |
66 | - [$viewSettings['blade_template_path'].$viewSettings['template']], |
|
66 | + [$viewSettings['blade_template_path'] . $viewSettings['template']], |
|
67 | 67 | $viewSettings['blade_cache_path'], |
68 | 68 | null, |
69 | 69 | [ |
@@ -76,13 +76,13 @@ discard block |
||
76 | 76 | $translator = new \Core\Translator\Translator($container); |
77 | 77 | $translator->init(); |
78 | 78 | |
79 | -$container['translator'] = function () use ($translator) { |
|
79 | +$container['translator'] = function() use ($translator) { |
|
80 | 80 | return $translator; |
81 | 81 | }; |
82 | 82 | |
83 | 83 | |
84 | 84 | // Register provider |
85 | -$container['flash'] = function () { |
|
85 | +$container['flash'] = function() { |
|
86 | 86 | return new \Slim\Flash\Messages(); |
87 | 87 | }; |
88 | 88 | |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | |
98 | 98 | |
99 | 99 | /*Dynamic containers in services*/ |
100 | -$dir = scandir(__APP_ROOT__.'/core/Services/'); |
|
100 | +$dir = scandir(__APP_ROOT__ . '/core/Services/'); |
|
101 | 101 | $ex_folders = array('..', '.'); |
102 | -$filesInServices = array_diff($dir,$ex_folders); |
|
102 | +$filesInServices = array_diff($dir, $ex_folders); |
|
103 | 103 | |
104 | -foreach($filesInServices as $service){ |
|
105 | - $content = preg_replace('/.php/','',$service); |
|
106 | - $container[$content] = function () use ($content){ |
|
107 | - $class = '\\Core\\Services\\'.$content ; |
|
104 | +foreach ($filesInServices as $service) { |
|
105 | + $content = preg_replace('/.php/', '', $service); |
|
106 | + $container[$content] = function() use ($content){ |
|
107 | + $class = '\\Core\\Services\\' . $content; |
|
108 | 108 | return new $class(); |
109 | 109 | }; |
110 | 110 | } |
@@ -24,14 +24,14 @@ |
||
24 | 24 | return isset($_SESSION['user']); |
25 | 25 | } |
26 | 26 | |
27 | - public function attempt(string $username,string $password) |
|
27 | + public function attempt(string $username, string $password) |
|
28 | 28 | { |
29 | 29 | $user = UserDataAccess::getUserLoginField($username)->first(); |
30 | 30 | |
31 | 31 | if (!$user) { |
32 | 32 | return false; |
33 | 33 | } |
34 | - if (password_verify($password,$user->password)) { |
|
34 | + if (password_verify($password, $user->password)) { |
|
35 | 35 | $_SESSION['user'] = $user->id; |
36 | 36 | return true; |
37 | 37 | } |
@@ -19,7 +19,7 @@ |
||
19 | 19 | |
20 | 20 | } |
21 | 21 | |
22 | - public static function getPrevious(){ |
|
22 | + public static function getPrevious() { |
|
23 | 23 | return $_SERVER['HTTP_REFERER']; |
24 | 24 | } |
25 | 25 | public static function getRoot($exclude_path = '') |
@@ -34,21 +34,21 @@ discard block |
||
34 | 34 | |
35 | 35 | public function resource($url, $controller, $args = []) |
36 | 36 | { |
37 | - $url = rtrim($url,'/'); |
|
38 | - $routeNames = implode('.',explode('/',trim($url,'/'))); |
|
39 | - |
|
40 | - $this->app->group($url, function () use ($controller,$routeNames, $args) { |
|
41 | - $this->get('', $controller . ':index')->add(self::middleware('index', $args))->setName($routeNames.'.index'); |
|
42 | - $this->get('/', $controller . ':index')->add(self::middleware('index', $args))->setName($routeNames.'.index'); |
|
43 | - $this->get('/index', $controller . ':index')->add(self::middleware('index', $args))->setName($routeNames.'.index'); |
|
44 | - |
|
45 | - $this->get('/create', $controller . ':create')->add(self::middleware('create', $args))->setName($routeNames.'.create'); |
|
46 | - $this->get('/{id:[0-9]+}', $controller . ':show')->add(self::middleware('show', $args))->setName($routeNames.'.show'); |
|
47 | - $this->get('/{id:[0-9]+}/edit', $controller . ':edit')->add(self::middleware('edit', $args))->setName($routeNames.'.edit'); |
|
48 | - $this->post('', $controller . ':store')->add(self::middleware('store', $args))->setName($routeNames.'.store'); |
|
49 | - $this->put('/{id:[0-9]+}', $controller . ':update')->add(self::middleware('update', $args))->setName($routeNames.'.update'); |
|
50 | - $this->patch('/{id:[0-9]+}', $controller . ':update')->add(self::middleware('index', $args))->setName($routeNames.'.update'); |
|
51 | - $this->delete('/{id:[0-9]+}', $controller . ':destroy')->add(self::middleware('destroy', $args))->setName($routeNames.'.destroy'); |
|
37 | + $url = rtrim($url, '/'); |
|
38 | + $routeNames = implode('.', explode('/', trim($url, '/'))); |
|
39 | + |
|
40 | + $this->app->group($url, function() use ($controller, $routeNames, $args) { |
|
41 | + $this->get('', $controller . ':index')->add(self::middleware('index', $args))->setName($routeNames . '.index'); |
|
42 | + $this->get('/', $controller . ':index')->add(self::middleware('index', $args))->setName($routeNames . '.index'); |
|
43 | + $this->get('/index', $controller . ':index')->add(self::middleware('index', $args))->setName($routeNames . '.index'); |
|
44 | + |
|
45 | + $this->get('/create', $controller . ':create')->add(self::middleware('create', $args))->setName($routeNames . '.create'); |
|
46 | + $this->get('/{id:[0-9]+}', $controller . ':show')->add(self::middleware('show', $args))->setName($routeNames . '.show'); |
|
47 | + $this->get('/{id:[0-9]+}/edit', $controller . ':edit')->add(self::middleware('edit', $args))->setName($routeNames . '.edit'); |
|
48 | + $this->post('', $controller . ':store')->add(self::middleware('store', $args))->setName($routeNames . '.store'); |
|
49 | + $this->put('/{id:[0-9]+}', $controller . ':update')->add(self::middleware('update', $args))->setName($routeNames . '.update'); |
|
50 | + $this->patch('/{id:[0-9]+}', $controller . ':update')->add(self::middleware('index', $args))->setName($routeNames . '.update'); |
|
51 | + $this->delete('/{id:[0-9]+}', $controller . ':destroy')->add(self::middleware('destroy', $args))->setName($routeNames . '.destroy'); |
|
52 | 52 | |
53 | 53 | })->add(self::middleware('group', $args)); |
54 | 54 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public static function middleware($middleWare = "group", $args) |
62 | 62 | { |
63 | - $routeResourceMiddleWare_default = function ($request, $response, $next) { |
|
63 | + $routeResourceMiddleWare_default = function($request, $response, $next) { |
|
64 | 64 | return $next($request, $response); |
65 | 65 | }; |
66 | 66 |