@@ -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 |
@@ -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 | |
@@ -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 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | $this->setOrder('priority'); |
| 66 | 66 | |
| 67 | 67 | $this->onHook(\atk4\data\Model::HOOK_BEFORE_INSERT, function($model, & $data) { |
| 68 | - $data['priority'] = $data['priority']?: $this->action('fx', ['max', 'priority'])->getOne() + 1; |
|
| 68 | + $data['priority'] = $data['priority'] ?: $this->action('fx', ['max', 'priority'])->getOne() + 1; |
|
| 69 | 69 | }); |
| 70 | 70 | } |
| 71 | 71 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | { |
| 79 | 79 | static $cache; |
| 80 | 80 | |
| 81 | - if (! isset($cache)) { |
|
| 81 | + if (!isset($cache)) { |
|
| 82 | 82 | $cache = []; |
| 83 | 83 | foreach (HomePageJoint::collect() as $joint) { |
| 84 | 84 | $cache[$joint->link()] = $joint->caption(); |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | public static function ofUser() |
| 97 | 97 | { |
| 98 | - if (! $user = Auth::user()) return; |
|
| 98 | + if (!$user = Auth::user()) return; |
|
| 99 | 99 | |
| 100 | 100 | return self::create()->addCondition('role', $user->roles()->pluck('name')->toArray())->loadAny(); |
| 101 | 101 | } |
@@ -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 | } |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | * Label of the module |
| 65 | 65 | */ |
| 66 | 66 | public static function label() { |
| 67 | - return static::$label?: ucwords(str_ireplace('.', ' ', static::alias())); |
|
| 67 | + return static::$label ?: ucwords(str_ireplace('.', ' ', static::alias())); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -76,11 +76,11 @@ discard block |
||
| 76 | 76 | { |
| 77 | 77 | $templatesDir = static::path() . DIRECTORY_SEPARATOR . 'Templates'; |
| 78 | 78 | |
| 79 | - if (! is_dir($templatesDir)) return; |
|
| 79 | + if (!is_dir($templatesDir)) return; |
|
| 80 | 80 | |
| 81 | 81 | $skinDir = $templatesDir . DIRECTORY_SEPARATOR . $skin; |
| 82 | 82 | |
| 83 | - return is_dir($skinDir)? $skinDir: $templatesDir; |
|
| 83 | + return is_dir($skinDir) ? $skinDir : $templatesDir; |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | public static function translations() |
@@ -46,7 +46,9 @@ |
||
| 46 | 46 | { |
| 47 | 47 | $templatesDir = static::path() . DIRECTORY_SEPARATOR . 'Templates'; |
| 48 | 48 | |
| 49 | - if (! is_dir($templatesDir)) return; |
|
| 49 | + if (! is_dir($templatesDir)) { |
|
| 50 | + return; |
|
| 51 | + } |
|
| 50 | 52 | |
| 51 | 53 | $skinDir = $templatesDir . DIRECTORY_SEPARATOR . $skin; |
| 52 | 54 | |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | $joint = new $class(); |
| 26 | 26 | |
| 27 | - if (! $joint->access()) continue; |
|
| 27 | + if (!$joint->access()) continue; |
|
| 28 | 28 | |
| 29 | 29 | $ret->add($joint); |
| 30 | 30 | } |
@@ -29,7 +29,9 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | $joint = new $class(); |
| 31 | 31 | |
| 32 | - if (! $joint->access()) continue; |
|
| 32 | + if (! $joint->access()) { |
|
| 33 | + continue; |
|
| 34 | + } |
|
| 33 | 35 | |
| 34 | 36 | $ret->add($joint); |
| 35 | 37 | } |
@@ -16,7 +16,9 @@ |
||
| 16 | 16 | { |
| 17 | 17 | $class = self::namespace() . '\\' . ($alias? Str::studly($alias): (static::name() . 'View')); |
| 18 | 18 | |
| 19 | - if ($alias) return $class; |
|
| 19 | + if ($alias) { |
|
| 20 | + return $class; |
|
| 21 | + } |
|
| 20 | 22 | |
| 21 | 23 | return static::$view?: $class; |
| 22 | 24 | } |
@@ -14,11 +14,11 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | final public static function view($alias = null) |
| 16 | 16 | { |
| 17 | - $class = self::namespace() . '\\' . ($alias? Str::studly($alias): (static::name() . 'View')); |
|
| 17 | + $class = self::namespace() . '\\' . ($alias ? Str::studly($alias) : (static::name() . 'View')); |
|
| 18 | 18 | |
| 19 | 19 | if ($alias) return $class; |
| 20 | 20 | |
| 21 | - return static::$view?: $class; |
|
| 21 | + return static::$view ?: $class; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | throw new \Exception('Undefined alias in module core class ' . static::class); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - return static::$alias?? static::module()::alias(); |
|
| 35 | + return static::$alias ?? static::module()::alias(); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | /** |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | { |
| 66 | 66 | $names = array_slice(explode('\\', static::class), -2, -1); |
| 67 | 67 | |
| 68 | - return $names? reset($names): ''; |
|
| 68 | + return $names ? reset($names) : ''; |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | { |
| 34 | 34 | $link = $this->link(); |
| 35 | 35 | |
| 36 | - $link = is_array($link)? ModuleView::moduleLink(...$link): $link; |
|
| 36 | + $link = is_array($link) ? ModuleView::moduleLink(...$link) : $link; |
|
| 37 | 37 | |
| 38 | 38 | return (new LaunchButton([ |
| 39 | 39 | 'label' => $this->label(), |