@@ -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' |
@@ -41,33 +41,33 @@ |
||
41 | 41 | */ |
42 | 42 | public static function pluck($value, $key = null) |
43 | 43 | { |
44 | - return collect(self::create()->export())->pluck($value, $key); |
|
44 | + return collect(self::create()->export())->pluck($value, $key); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | // to be removed for atk4/data 2.0 |
48 | 48 | public function addFields($fields = [], $defaults = []) |
49 | 49 | { |
50 | - foreach ($fields as $key => $field) { |
|
51 | - if (!is_int($key)) { |
|
52 | - // field name can be passed as array key |
|
53 | - $name = $key; |
|
54 | - } elseif (is_string($field)) { |
|
55 | - // or it can be simple string = field name |
|
56 | - $name = $field; |
|
57 | - $field = []; |
|
58 | - } elseif (is_array($field) && isset($field[0]) && is_string($field[0])) { |
|
59 | - // or field name can be passed as first element of seed array (old behaviour) |
|
60 | - $name = array_shift($field); |
|
61 | - } else { |
|
62 | - // some unsupported format, maybe throw exception here? |
|
63 | - continue; |
|
64 | - } |
|
50 | + foreach ($fields as $key => $field) { |
|
51 | + if (!is_int($key)) { |
|
52 | + // field name can be passed as array key |
|
53 | + $name = $key; |
|
54 | + } elseif (is_string($field)) { |
|
55 | + // or it can be simple string = field name |
|
56 | + $name = $field; |
|
57 | + $field = []; |
|
58 | + } elseif (is_array($field) && isset($field[0]) && is_string($field[0])) { |
|
59 | + // or field name can be passed as first element of seed array (old behaviour) |
|
60 | + $name = array_shift($field); |
|
61 | + } else { |
|
62 | + // some unsupported format, maybe throw exception here? |
|
63 | + continue; |
|
64 | + } |
|
65 | 65 | |
66 | - $seed = array_merge($defaults, (array) $field); |
|
66 | + $seed = array_merge($defaults, (array) $field); |
|
67 | 67 | |
68 | - $this->addField($name, $seed); |
|
69 | - } |
|
68 | + $this->addField($name, $seed); |
|
69 | + } |
|
70 | 70 | |
71 | - return $this; |
|
71 | + return $this; |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | \ No newline at end of file |
@@ -86,11 +86,9 @@ discard block |
||
86 | 86 | ob_start(); |
87 | 87 | if ($exception instanceof TokenMismatchException) { |
88 | 88 | $this->jsRedirectHomepage(__('Session expired! Redirecting to your home page ...')); |
89 | - } |
|
90 | - elseif ($exception instanceof NotFoundHttpException) { |
|
89 | + } elseif ($exception instanceof NotFoundHttpException) { |
|
91 | 90 | $this->jsRedirectHomepage(__('Requested page not found! Redirecting to your home page ...')); |
92 | - } |
|
93 | - else { |
|
91 | + } else { |
|
94 | 92 | $this->caughtException($exception); |
95 | 93 | } |
96 | 94 | |
@@ -109,8 +107,7 @@ discard block |
||
109 | 107 | 'message' => $message, |
110 | 108 | 'atkjs' => $redirectJs |
111 | 109 | ]); |
112 | - } |
|
113 | - else { |
|
110 | + } else { |
|
114 | 111 | $this->outputResponseHTML('<script>' . $redirectJs . '</script>'); |
115 | 112 | } |
116 | 113 | } |
@@ -28,10 +28,10 @@ discard block |
||
28 | 28 | { |
29 | 29 | parent::__construct([ |
30 | 30 | 'title' => config('epesi.app.title', 'EPESI'), |
31 | - 'cdn' => array_merge($this->cdn, (array) config('epesi.app.cdn')), |
|
31 | + 'cdn' => array_merge($this->cdn, (array) config('epesi.app.cdn')), |
|
32 | 32 | //TODO: set the skin from admin / user selection |
33 | - 'skin' => config('epesi.app.skin', $this->skin), |
|
34 | - 'template_dir' => array_merge(ModuleManager::collect('templates', $this->skin), (array) $this->template_dir) |
|
33 | + 'skin' => config('epesi.app.skin', $this->skin), |
|
34 | + 'template_dir' => array_merge(ModuleManager::collect('templates', $this->skin), (array) $this->template_dir) |
|
35 | 35 | ]); |
36 | 36 | } |
37 | 37 | |
@@ -73,43 +73,43 @@ discard block |
||
73 | 73 | |
74 | 74 | public function renderException($exception) |
75 | 75 | { |
76 | - ob_start(); |
|
77 | - if ($exception instanceof TokenMismatchException) { |
|
78 | - $this->jsRedirectHomepage(__('Session expired! Redirecting to your home page ...')); |
|
79 | - } |
|
80 | - elseif ($exception instanceof NotFoundHttpException) { |
|
81 | - $this->jsRedirectHomepage(__('Requested page not found! Redirecting to your home page ...')); |
|
82 | - } |
|
83 | - else { |
|
84 | - $this->caughtException($exception); |
|
85 | - } |
|
76 | + ob_start(); |
|
77 | + if ($exception instanceof TokenMismatchException) { |
|
78 | + $this->jsRedirectHomepage(__('Session expired! Redirecting to your home page ...')); |
|
79 | + } |
|
80 | + elseif ($exception instanceof NotFoundHttpException) { |
|
81 | + $this->jsRedirectHomepage(__('Requested page not found! Redirecting to your home page ...')); |
|
82 | + } |
|
83 | + else { |
|
84 | + $this->caughtException($exception); |
|
85 | + } |
|
86 | 86 | |
87 | - return ob_get_clean(); |
|
87 | + return ob_get_clean(); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | public function jsRedirectHomepage($message) |
91 | 91 | { |
92 | - $homepageUrl = url(\Epesi\Core\HomePage\Database\Models\HomePage::pathOfUser()); |
|
92 | + $homepageUrl = url(\Epesi\Core\HomePage\Database\Models\HomePage::pathOfUser()); |
|
93 | 93 | |
94 | - $redirectJs = $this->jsRedirectConfirm($homepageUrl, $message)->jsRender(); |
|
94 | + $redirectJs = $this->jsRedirectConfirm($homepageUrl, $message)->jsRender(); |
|
95 | 95 | |
96 | - if ($this->isJsonRequest()) { |
|
97 | - $this->outputResponseJSON([ |
|
98 | - 'success' => true, |
|
99 | - 'message' => $message, |
|
100 | - 'atkjs' => $redirectJs |
|
101 | - ]); |
|
102 | - } |
|
103 | - else { |
|
104 | - $this->outputResponseHTML('<script>' . $redirectJs . '</script>'); |
|
105 | - } |
|
96 | + if ($this->isJsonRequest()) { |
|
97 | + $this->outputResponseJSON([ |
|
98 | + 'success' => true, |
|
99 | + 'message' => $message, |
|
100 | + 'atkjs' => $redirectJs |
|
101 | + ]); |
|
102 | + } |
|
103 | + else { |
|
104 | + $this->outputResponseHTML('<script>' . $redirectJs . '</script>'); |
|
105 | + } |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | public function jsRedirectConfirm($page, $message) |
109 | 109 | { |
110 | - $redirectJs = $this->jsRedirect($page)->jsRender(); |
|
110 | + $redirectJs = $this->jsRedirect($page)->jsRender(); |
|
111 | 111 | |
112 | - return new jsExpression("if (confirm([])) { $redirectJs }", [$message]); |
|
112 | + return new jsExpression("if (confirm([])) { $redirectJs }", [$message]); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -127,35 +127,35 @@ discard block |
||
127 | 127 | |
128 | 128 | // jQuery |
129 | 129 | $urlJs = $this->cdn['jquery']?? $localJs; |
130 | - $this->requireJS($urlJs.'/jquery.min.js'); |
|
130 | + $this->requireJS($urlJs . '/jquery.min.js'); |
|
131 | 131 | |
132 | 132 | // Semantic UI |
133 | 133 | $urlJs = $this->cdn['semantic-ui']?? $localJs; |
134 | 134 | $urlCss = $this->cdn['semantic-ui']?? $localCss; |
135 | - $this->requireJS($urlJs.'/semantic.min.js'); |
|
136 | - $this->requireCSS($urlCss.'/semantic.min.css'); |
|
135 | + $this->requireJS($urlJs . '/semantic.min.js'); |
|
136 | + $this->requireCSS($urlCss . '/semantic.min.css'); |
|
137 | 137 | |
138 | 138 | // Serialize Object |
139 | 139 | $urlJs = $this->cdn['serialize-object']?? $localJs; |
140 | - $this->requireJS($urlJs.'/jquery.serialize-object.min.js'); |
|
140 | + $this->requireJS($urlJs . '/jquery.serialize-object.min.js'); |
|
141 | 141 | |
142 | 142 | // Agile UI |
143 | 143 | $urlJs = $this->cdn['atk']?? $localJs; |
144 | 144 | $urlCss = $this->cdn['atk']?? $localCss; |
145 | - $this->requireJS($urlJs.'/atkjs-ui.min.js'); |
|
146 | - $this->requireCSS($urlCss.'/agileui.css'); |
|
145 | + $this->requireJS($urlJs . '/atkjs-ui.min.js'); |
|
146 | + $this->requireCSS($urlCss . '/agileui.css'); |
|
147 | 147 | |
148 | 148 | // Draggable |
149 | 149 | $urlJs = $this->cdn['draggable']?? $localJs; |
150 | - $this->requireJS($urlJs.'/draggable.bundle.js'); |
|
150 | + $this->requireJS($urlJs . '/draggable.bundle.js'); |
|
151 | 151 | |
152 | 152 | // jQuery niceScroll |
153 | 153 | $urlJs = $this->cdn['jquery-nicescroll']?? $localJs; |
154 | - $this->requireJS($urlJs.'/jquery.nicescroll.js'); |
|
154 | + $this->requireJS($urlJs . '/jquery.nicescroll.js'); |
|
155 | 155 | |
156 | 156 | // clipboard.js |
157 | 157 | $urlJs = $this->cdn['clipboardjs']?? $localJs; |
158 | - $this->requireJS($urlJs.'/clipboard.js'); |
|
158 | + $this->requireJS($urlJs . '/clipboard.js'); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | public function addCsrfToken() |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | |
233 | 233 | $key = md5(serialize(func_get_args())); |
234 | 234 | |
235 | - if (! isset($cache[$key])) { |
|
235 | + if (!isset($cache[$key])) { |
|
236 | 236 | $cache[$key] = true; |
237 | 237 | |
238 | 238 | parent::requireJS($url, $isAsync, $isDefer); |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | protected $validationRules = []; |
18 | 18 | |
19 | 19 | public function addElements($elements, $parent = null) { |
20 | - $parent = $parent?: $this; |
|
20 | + $parent = $parent ?: $this; |
|
21 | 21 | |
22 | 22 | foreach ($elements as $name => $desc) { |
23 | 23 | $name = $desc['name']?? $name; |
@@ -26,9 +26,9 @@ discard block |
||
26 | 26 | |
27 | 27 | switch ($desc['type']?? 'field') { |
28 | 28 | case 'field': |
29 | - $desc = is_string($desc)? [ |
|
29 | + $desc = is_string($desc) ? [ |
|
30 | 30 | 'decorator' => [$desc] |
31 | - ]: $desc; |
|
31 | + ] : $desc; |
|
32 | 32 | |
33 | 33 | $field = $parent->addField($name, $desc['decorator']?? [], $desc['options']?? []); |
34 | 34 | |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | } |
78 | 78 | |
79 | 79 | public function addFieldsDisplayRules($fieldsDisplayRules) { |
80 | - $this->setFieldsDisplayRules(array_merge($this->fieldsDisplayRules?: [], $fieldsDisplayRules)); |
|
80 | + $this->setFieldsDisplayRules(array_merge($this->fieldsDisplayRules ?: [], $fieldsDisplayRules)); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | public function addGroupDisplayRules($groupDisplayRules) { |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | } |
90 | 90 | |
91 | 91 | public function addFieldRules($field, $rules = []) { |
92 | - if (! $rules) return; |
|
92 | + if (!$rules) return; |
|
93 | 93 | |
94 | 94 | $this->fieldRules[$field] = $rules['rules']?? [ |
95 | 95 | 'identifier' => $field, |
@@ -109,17 +109,17 @@ discard block |
||
109 | 109 | 'fields' => $this->fieldRules |
110 | 110 | ]); |
111 | 111 | |
112 | - $this->onSubmit(function ($form) use ($callback) { |
|
112 | + $this->onSubmit(function($form) use ($callback) { |
|
113 | 113 | $errors = []; |
114 | - foreach ($this->validationRules?: [] as $ruleCallback) { |
|
115 | - if (! is_callable($ruleCallback)) continue; |
|
114 | + foreach ($this->validationRules ?: [] as $ruleCallback) { |
|
115 | + if (!is_callable($ruleCallback)) continue; |
|
116 | 116 | |
117 | 117 | $ruleErrors = $ruleCallback($form); |
118 | 118 | |
119 | - $errors = array_merge($errors, $ruleErrors?: []); |
|
119 | + $errors = array_merge($errors, $ruleErrors ?: []); |
|
120 | 120 | } |
121 | 121 | |
122 | - return $errors?: $callback($this); |
|
122 | + return $errors ?: $callback($this); |
|
123 | 123 | }); |
124 | 124 | |
125 | 125 | return $this; |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | |
133 | 133 | public function confirmLeave($confirm = true) |
134 | 134 | { |
135 | - $this->canLeave = ! $confirm; |
|
135 | + $this->canLeave = !$confirm; |
|
136 | 136 | |
137 | 137 | return $this; |
138 | 138 | } |
@@ -89,7 +89,9 @@ discard block |
||
89 | 89 | } |
90 | 90 | |
91 | 91 | public function addFieldRules($field, $rules = []) { |
92 | - if (! $rules) return; |
|
92 | + if (! $rules) { |
|
93 | + return; |
|
94 | + } |
|
93 | 95 | |
94 | 96 | $this->fieldRules[$field] = $rules['rules']?? [ |
95 | 97 | 'identifier' => $field, |
@@ -112,7 +114,9 @@ discard block |
||
112 | 114 | $this->onSubmit(function ($form) use ($callback) { |
113 | 115 | $errors = []; |
114 | 116 | foreach ($this->validationRules?: [] as $ruleCallback) { |
115 | - if (! is_callable($ruleCallback)) continue; |
|
117 | + if (! is_callable($ruleCallback)) { |
|
118 | + continue; |
|
119 | + } |
|
116 | 120 | |
117 | 121 | $ruleErrors = $ruleCallback($form); |
118 | 122 |