@@ -57,7 +57,7 @@ |
||
57 | 57 | |
58 | 58 | $this->app->singleton( |
59 | 59 | SQL::class, |
60 | - function ($app) { |
|
60 | + function($app) { |
|
61 | 61 | /** |
62 | 62 | * Database Manager |
63 | 63 | * |
@@ -12,73 +12,73 @@ |
||
12 | 12 | |
13 | 13 | class EpesiServiceProvider extends ServiceProvider |
14 | 14 | { |
15 | - /** |
|
16 | - * Booting the package. |
|
17 | - */ |
|
18 | - public function boot() |
|
19 | - { |
|
20 | - $this->ensureHttps(); |
|
15 | + /** |
|
16 | + * Booting the package. |
|
17 | + */ |
|
18 | + public function boot() |
|
19 | + { |
|
20 | + $this->ensureHttps(); |
|
21 | 21 | |
22 | - if (env('APP_DEBUG', false)) ModuleManager::clearCache(); |
|
22 | + if (env('APP_DEBUG', false)) ModuleManager::clearCache(); |
|
23 | 23 | |
24 | - Route::group(['namespace' => 'Epesi\Core', 'middleware' => 'web'], function() { |
|
25 | - Route::any('/', 'Controller@index'); |
|
26 | - Route::get('logo', 'Controller@logo'); |
|
27 | - Route::any('install', 'Controller@install'); |
|
24 | + Route::group(['namespace' => 'Epesi\Core', 'middleware' => 'web'], function() { |
|
25 | + Route::any('/', 'Controller@index'); |
|
26 | + Route::get('logo', 'Controller@logo'); |
|
27 | + Route::any('install', 'Controller@install'); |
|
28 | 28 | |
29 | - Route::group(['middleware' => ['auth', NoCacheHeaders::class]], function() { |
|
30 | - Route::any('home', 'Controller@home')->name('home'); |
|
29 | + Route::group(['middleware' => ['auth', NoCacheHeaders::class]], function() { |
|
30 | + Route::any('home', 'Controller@home')->name('home'); |
|
31 | 31 | |
32 | - Route::any('view/{alias}/{method?}/{args?}', 'Controller@view'); |
|
33 | - }); |
|
34 | - }); |
|
32 | + Route::any('view/{alias}/{method?}/{args?}', 'Controller@view'); |
|
33 | + }); |
|
34 | + }); |
|
35 | 35 | |
36 | - // call boot methods on all modules |
|
37 | - ModuleManager::call('boot'); |
|
36 | + // call boot methods on all modules |
|
37 | + ModuleManager::call('boot'); |
|
38 | 38 | |
39 | 39 | foreach (ModuleManager::collect('translations') as $path) { |
40 | 40 | $this->loadJsonTranslationsFrom($path); |
41 | 41 | } |
42 | 42 | |
43 | - // Register admin service provider if in admin mode or in console |
|
44 | - // TODO: apply access restriction to admin mode |
|
43 | + // Register admin service provider if in admin mode or in console |
|
44 | + // TODO: apply access restriction to admin mode |
|
45 | 45 | // if ($this->app->runningInConsole() || (request('admin', false) && Auth::user()->can('modify system'))) { |
46 | - if ($this->app->runningInConsole() || request('admin', false)) { |
|
47 | - $this->app->register(AdminServiceProvider::class); |
|
48 | - } |
|
49 | - } |
|
46 | + if ($this->app->runningInConsole() || request('admin', false)) { |
|
47 | + $this->app->register(AdminServiceProvider::class); |
|
48 | + } |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * Register the provider. |
|
53 | - */ |
|
54 | - public function register() |
|
55 | - { |
|
56 | - $this->app->singleton(UI::class); |
|
51 | + /** |
|
52 | + * Register the provider. |
|
53 | + */ |
|
54 | + public function register() |
|
55 | + { |
|
56 | + $this->app->singleton(UI::class); |
|
57 | 57 | |
58 | - $this->app->singleton( |
|
59 | - SQL::class, |
|
60 | - function ($app) { |
|
61 | - /** |
|
62 | - * Database Manager |
|
63 | - * |
|
64 | - * @var \Illuminate\Database\DatabaseManager $db |
|
65 | - */ |
|
66 | - $db = DB::getFacadeRoot(); |
|
58 | + $this->app->singleton( |
|
59 | + SQL::class, |
|
60 | + function ($app) { |
|
61 | + /** |
|
62 | + * Database Manager |
|
63 | + * |
|
64 | + * @var \Illuminate\Database\DatabaseManager $db |
|
65 | + */ |
|
66 | + $db = DB::getFacadeRoot(); |
|
67 | 67 | |
68 | - return new SQL($db); |
|
69 | - }); |
|
70 | - } |
|
68 | + return new SQL($db); |
|
69 | + }); |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * Force to set https scheme if https enabled. |
|
74 | - * |
|
75 | - * @return void |
|
76 | - */ |
|
77 | - protected function ensureHttps() |
|
78 | - { |
|
79 | - if (config('epesi.https') || config('epesi.secure')) { |
|
80 | - url()->forceScheme('https'); |
|
81 | - $this->app['request']->server->set('HTTPS', true); |
|
82 | - } |
|
83 | - } |
|
72 | + /** |
|
73 | + * Force to set https scheme if https enabled. |
|
74 | + * |
|
75 | + * @return void |
|
76 | + */ |
|
77 | + protected function ensureHttps() |
|
78 | + { |
|
79 | + if (config('epesi.https') || config('epesi.secure')) { |
|
80 | + url()->forceScheme('https'); |
|
81 | + $this->app['request']->server->set('HTTPS', true); |
|
82 | + } |
|
83 | + } |
|
84 | 84 | } |
@@ -19,7 +19,9 @@ |
||
19 | 19 | { |
20 | 20 | $this->ensureHttps(); |
21 | 21 | |
22 | - if (env('APP_DEBUG', false)) ModuleManager::clearCache(); |
|
22 | + if (env('APP_DEBUG', false)) { |
|
23 | + ModuleManager::clearCache(); |
|
24 | + } |
|
23 | 25 | |
24 | 26 | Route::group(['namespace' => 'Epesi\Core', 'middleware' => 'web'], function() { |
25 | 27 | Route::any('/', 'Controller@index'); |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | |
36 | 36 | protected function showEditPermissions() |
37 | 37 | { |
38 | - $permissionsData = Permission::all(['id', 'name'])->map(function($permission){ |
|
38 | + $permissionsData = Permission::all(['id', 'name'])->map(function($permission) { |
|
39 | 39 | $permission['name'] = trans(ucwords($permission['name'])); |
40 | 40 | |
41 | 41 | return $permission; |
@@ -99,19 +99,19 @@ discard block |
||
99 | 99 | |
100 | 100 | protected function columns() |
101 | 101 | { |
102 | - return $this->columns = $this->columns?: $this->add('Columns'); |
|
102 | + return $this->columns = $this->columns ?: $this->add('Columns'); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | protected function permissionId() |
106 | 106 | { |
107 | - return $this->app->stickyGet($this->columns()->name)?: $this->getModuleVariable('permission'); |
|
107 | + return $this->app->stickyGet($this->columns()->name) ?: $this->getModuleVariable('permission'); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | protected function reload($permissionExpression = null) |
111 | 111 | { |
112 | 112 | $columns = $this->columns(); |
113 | 113 | |
114 | - return $this->reload = $this->reload?: new jsReload($columns, [$columns->name => $permissionExpression?: '']); |
|
114 | + return $this->reload = $this->reload ?: new jsReload($columns, [$columns->name => $permissionExpression ?: '']); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | protected function getModel($array) |
@@ -8,28 +8,28 @@ |
||
8 | 8 | |
9 | 9 | class ModuleManagerTest extends TestCase |
10 | 10 | { |
11 | - /** |
|
12 | - * Setup the test environment. |
|
13 | - */ |
|
14 | - protected function setUp(): void |
|
15 | - { |
|
16 | - parent::setUp(); |
|
11 | + /** |
|
12 | + * Setup the test environment. |
|
13 | + */ |
|
14 | + protected function setUp(): void |
|
15 | + { |
|
16 | + parent::setUp(); |
|
17 | 17 | |
18 | - config([ |
|
19 | - 'epesi.modules' => [ |
|
20 | - '\\Epesi\\Core\\' => __DIR__ . implode(DIRECTORY_SEPARATOR, ['..', '..', 'src']), |
|
21 | - ] |
|
22 | - ]); |
|
18 | + config([ |
|
19 | + 'epesi.modules' => [ |
|
20 | + '\\Epesi\\Core\\' => __DIR__ . implode(DIRECTORY_SEPARATOR, ['..', '..', 'src']), |
|
21 | + ] |
|
22 | + ]); |
|
23 | 23 | |
24 | - ModuleManager::install('system'); |
|
25 | - } |
|
24 | + ModuleManager::install('system'); |
|
25 | + } |
|
26 | 26 | |
27 | - public function testContentStorage() |
|
28 | - { |
|
29 | - $installedModules = ModuleManager::getInstalled(); |
|
27 | + public function testContentStorage() |
|
28 | + { |
|
29 | + $installedModules = ModuleManager::getInstalled(); |
|
30 | 30 | |
31 | - $this->assertArrayHasKey('system', $installedModules, 'System module not installed'); |
|
32 | - } |
|
31 | + $this->assertArrayHasKey('system', $installedModules, 'System module not installed'); |
|
32 | + } |
|
33 | 33 | |
34 | 34 | |
35 | 35 | } |
36 | 36 | \ No newline at end of file |
@@ -7,41 +7,41 @@ |
||
7 | 7 | |
8 | 8 | class VariablesTest extends TestCase |
9 | 9 | { |
10 | - /** |
|
11 | - * Setup the test environment. |
|
12 | - */ |
|
13 | - protected function setUp(): void |
|
14 | - { |
|
15 | - parent::setUp(); |
|
10 | + /** |
|
11 | + * Setup the test environment. |
|
12 | + */ |
|
13 | + protected function setUp(): void |
|
14 | + { |
|
15 | + parent::setUp(); |
|
16 | 16 | |
17 | - Variable::migrate(); |
|
18 | - } |
|
17 | + Variable::migrate(); |
|
18 | + } |
|
19 | 19 | |
20 | - public function testVariableStorage() |
|
21 | - { |
|
22 | - $varString = 'test'; |
|
20 | + public function testVariableStorage() |
|
21 | + { |
|
22 | + $varString = 'test'; |
|
23 | 23 | |
24 | - Variable::memorize('testString', $varString); |
|
24 | + Variable::memorize('testString', $varString); |
|
25 | 25 | |
26 | - $this->assertEquals($varString, Variable::recall('testString'), 'String variable not stored correctly in database'); |
|
26 | + $this->assertEquals($varString, Variable::recall('testString'), 'String variable not stored correctly in database'); |
|
27 | 27 | |
28 | - Variable::forget('testString'); |
|
28 | + Variable::forget('testString'); |
|
29 | 29 | |
30 | - $this->assertEmpty(Variable::recall('testString'), 'String variable not cleared correctly from database'); |
|
30 | + $this->assertEmpty(Variable::recall('testString'), 'String variable not cleared correctly from database'); |
|
31 | 31 | |
32 | - $varArray = [ |
|
33 | - 'aa' => 'test1', |
|
34 | - 'bb' => 'test2' |
|
35 | - ]; |
|
32 | + $varArray = [ |
|
33 | + 'aa' => 'test1', |
|
34 | + 'bb' => 'test2' |
|
35 | + ]; |
|
36 | 36 | |
37 | - Variable::memorize('testArray', $varArray); |
|
37 | + Variable::memorize('testArray', $varArray); |
|
38 | 38 | |
39 | - $this->assertEquals($varArray, Variable::recall('testArray'), 'Array variable not stored correctly in database'); |
|
39 | + $this->assertEquals($varArray, Variable::recall('testArray'), 'Array variable not stored correctly in database'); |
|
40 | 40 | |
41 | - Variable::forget('testArray'); |
|
41 | + Variable::forget('testArray'); |
|
42 | 42 | |
43 | - $this->assertEmpty(Variable::recall('testArray'), 'String variable not cleared correctly from database'); |
|
44 | - } |
|
43 | + $this->assertEmpty(Variable::recall('testArray'), 'String variable not cleared correctly from database'); |
|
44 | + } |
|
45 | 45 | |
46 | 46 | |
47 | 47 | } |
48 | 48 | \ No newline at end of file |
@@ -30,7 +30,7 @@ |
||
30 | 30 | |
31 | 31 | $grid->setModel(HomePage::create()); |
32 | 32 | |
33 | - $grid->addDragHandler()->onReorder(function ($order) { |
|
33 | + $grid->addDragHandler()->onReorder(function($order) { |
|
34 | 34 | foreach (HomePage::create() as $homepage) { |
35 | 35 | $homepage->save(['priority' => array_search($homepage['id'], $order)]); |
36 | 36 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | |
11 | 11 | class HomePage extends Model |
12 | 12 | { |
13 | - use HasEpesiConnection; |
|
13 | + use HasEpesiConnection; |
|
14 | 14 | |
15 | 15 | public $table = 'home_pages'; |
16 | 16 | |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | parent::init(); |
30 | 30 | |
31 | 31 | $this->addFields([ |
32 | - 'path' => [ |
|
32 | + 'path' => [ |
|
33 | 33 | 'type' => 'enum', |
34 | 34 | 'caption' => __('Page'), |
35 | 35 | 'values' => self::list(), |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | 'filter' => true |
41 | 41 | ], |
42 | 42 | ], |
43 | - 'role' => [ |
|
43 | + 'role' => [ |
|
44 | 44 | 'type' => 'enum', |
45 | 45 | 'caption' => __('Role'), |
46 | 46 | 'values' => Role::get()->pluck('name', 'name')->all(), |
@@ -48,16 +48,16 @@ discard block |
||
48 | 48 | 'filter' => true |
49 | 49 | ] |
50 | 50 | ], |
51 | - 'date' => [ |
|
51 | + 'date' => [ |
|
52 | 52 | 'type' => 'date', |
53 | 53 | 'caption' => __('Date'), |
54 | - 'never_persist' => true, |
|
54 | + 'never_persist' => true, |
|
55 | 55 | 'ui' => [ |
56 | 56 | 'filter' => true |
57 | 57 | ] |
58 | 58 | ], |
59 | 59 | 'priority' => [ |
60 | - 'default' => 0 |
|
60 | + 'default' => 0 |
|
61 | 61 | ], |
62 | 62 | ]); |
63 | 63 |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $this->setOrder('priority'); |
65 | 65 | |
66 | 66 | $this->addHook('beforeInsert', function($model, & $data) { |
67 | - $data['priority'] = $data['priority']?: $this->action('fx', ['max', 'priority'])->getOne() + 1; |
|
67 | + $data['priority'] = $data['priority'] ?: $this->action('fx', ['max', 'priority'])->getOne() + 1; |
|
68 | 68 | }); |
69 | 69 | } |
70 | 70 | |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | { |
78 | 78 | static $cache; |
79 | 79 | |
80 | - if (! isset($cache)) { |
|
80 | + if (!isset($cache)) { |
|
81 | 81 | $cache = []; |
82 | 82 | foreach (HomePageJoint::collect() as $joint) { |
83 | 83 | $cache[$joint->link()] = $joint->caption(); |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public static function ofUser() |
96 | 96 | { |
97 | - if (! $user = Auth::user()) return; |
|
97 | + if (!$user = Auth::user()) return; |
|
98 | 98 | |
99 | 99 | return self::create()->addCondition('role', $user->roles()->pluck('name')->toArray())->loadAny(); |
100 | 100 | } |
@@ -106,6 +106,6 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public static function pathOfUser() |
108 | 108 | { |
109 | - return HomePage::ofUser()['path']?: self::$defaultPath; |
|
109 | + return HomePage::ofUser()['path'] ?: self::$defaultPath; |
|
110 | 110 | } |
111 | 111 | } |
@@ -94,7 +94,9 @@ |
||
94 | 94 | */ |
95 | 95 | public static function ofUser() |
96 | 96 | { |
97 | - if (! $user = Auth::user()) return; |
|
97 | + if (! $user = Auth::user()) { |
|
98 | + return; |
|
99 | + } |
|
98 | 100 | |
99 | 101 | return self::create()->addCondition('role', $user->roles()->pluck('name')->toArray())->loadAny(); |
100 | 102 | } |
@@ -21,14 +21,14 @@ |
||
21 | 21 | |
22 | 22 | public function install() |
23 | 23 | { |
24 | - Models\HomePage::migrate(); |
|
24 | + Models\HomePage::migrate(); |
|
25 | 25 | |
26 | 26 | // setup default home pages |
27 | 27 | Models\HomePage::create()->import([ |
28 | - [ |
|
29 | - 'path' => 'view/dashboard', |
|
30 | - 'role' => 'Super Admin' |
|
31 | - ], |
|
28 | + [ |
|
29 | + 'path' => 'view/dashboard', |
|
30 | + 'role' => 'Super Admin' |
|
31 | + ], |
|
32 | 32 | [ |
33 | 33 | 'path' => 'view/dashboard', |
34 | 34 | 'role' => 'Employee' |
@@ -7,7 +7,7 @@ |
||
7 | 7 | |
8 | 8 | class User extends Model |
9 | 9 | { |
10 | - use HasEpesiConnection; |
|
10 | + use HasEpesiConnection; |
|
11 | 11 | |
12 | 12 | public $table = 'users'; |
13 | 13 |
@@ -24,11 +24,11 @@ |
||
24 | 24 | |
25 | 25 | public function migrate() |
26 | 26 | { |
27 | - Models\Module::migrate(); |
|
27 | + Models\Module::migrate(); |
|
28 | 28 | |
29 | - Models\Variable::migrate(); |
|
29 | + Models\Variable::migrate(); |
|
30 | 30 | |
31 | - return parent::migrate(); |
|
31 | + return parent::migrate(); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | } |