From abe438d15afd35b2073562479a7a107feac32336 Mon Sep 17 00:00:00 2001 From: CrazyBoy49z Date: Sat, 6 Jul 2024 06:50:35 +0000 Subject: [PATCH] Fix styling --- database/factories/SettingFactory.php | 12 ++++++------ src/LazySetting.php | 14 +++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/database/factories/SettingFactory.php b/database/factories/SettingFactory.php index 9e3a816..eb79838 100644 --- a/database/factories/SettingFactory.php +++ b/database/factories/SettingFactory.php @@ -12,9 +12,9 @@ class SettingFactory extends Factory public function definition(): array { return [ - 'group' => $this->faker->word, - 'key' => $this->faker->word, - 'type' => $this->faker->randomElement([ + 'group' => $this->faker->word, + 'key' => $this->faker->word, + 'type' => $this->faker->randomElement([ 'text', 'textarea', 'select', @@ -31,10 +31,10 @@ public function definition(): array 'time', 'datetime', ]), - 'value' => $this->faker->word, - 'options' => [ + 'value' => $this->faker->word, + 'options' => [ 'is_protected' => $this->faker->boolean, - 'deletable' => $this->faker->boolean, + 'deletable' => $this->faker->boolean, ], 'is_encrypted' => $this->faker->boolean, ]; diff --git a/src/LazySetting.php b/src/LazySetting.php index 9a2c9aa..376ee99 100755 --- a/src/LazySetting.php +++ b/src/LazySetting.php @@ -4,8 +4,8 @@ use Illuminate\Support\Collection; use Illuminate\Support\Facades\Log; -use Step2Dev\LazySetting\Models\Setting; use InvalidArgumentException; +use Step2Dev\LazySetting\Models\Setting; use Throwable; class LazySetting @@ -69,12 +69,12 @@ public function getKeyAndGroup(string $key): array return compact('key', 'group'); } - public function get(string $key, mixed $default = null): string|null + public function get(string $key, mixed $default = null): ?string { return $this->getConfig($key)?->value ?? $default; } - public function getConfig(string $key): Setting|null + public function getConfig(string $key): ?Setting { try { ['group' => $group, 'key' => $key] = $this->getKeyAndGroup($key); @@ -92,7 +92,7 @@ public function getConfig(string $key): Setting|null /** * @throws Throwable */ - public function set(string $key, mixed $data, string|null $type = null): Setting + public function set(string $key, mixed $data, ?string $type = null): Setting { if ($setting = $this->getConfig($key)) { $this->update($setting, $data); @@ -120,7 +120,7 @@ public function update(Setting $setting, mixed $data): Setting /** * @throws Throwable */ - public function createIfNotExists(string $key, mixed $data, string|null $type = null): Setting + public function createIfNotExists(string $key, mixed $data, ?string $type = null): Setting { $setting = Setting::firstOrCreate($this->getKeyAndGroup($key), $this->formatData($data, $type)); @@ -145,7 +145,7 @@ public function getFieldType(string $type = ''): string }; } - final protected function formatData(array|string $data, string|null $type = null, ?array $options = []): array + final protected function formatData(array|string $data, ?string $type = null, ?array $options = []): array { $type = $this->getFieldType($type); $result = compact('type'); @@ -172,7 +172,7 @@ final protected function formatData(array|string $data, string|null $type = null /** * @throws Throwable */ - public function create(string $key, array $data, string|null $type = null): Setting + public function create(string $key, array $data, ?string $type = null): Setting { $setting = Setting::create([ ...$this->getKeyAndGroup($key),