From e471f60ac681dc2c7de685f7e14539b7d7c4579c Mon Sep 17 00:00:00 2001 From: lee-to Date: Fri, 16 Aug 2024 14:24:53 +0000 Subject: [PATCH] Fix styling --- src/Casts/LayoutItem.php | 3 +-- src/Casts/LayoutsCast.php | 7 ++++--- src/Collections/LayoutCollection.php | 4 ++-- src/Collections/LayoutItemCollection.php | 4 ++-- src/Fields/Layout.php | 4 ++-- src/Http/Controllers/LayoutsController.php | 4 ++-- tests/Feature/LayoutsTest.php | 6 +++--- tests/Fixtures/TestModel.php | 2 +- tests/Fixtures/TestResource.php | 2 +- tests/TestCase.php | 2 +- 10 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/Casts/LayoutItem.php b/src/Casts/LayoutItem.php index 1db9571..978c108 100644 --- a/src/Casts/LayoutItem.php +++ b/src/Casts/LayoutItem.php @@ -12,8 +12,7 @@ public function __construct( private string $name, private int $key = 0, private array $values = [] - ) - { + ) { } public function getName(): string diff --git a/src/Casts/LayoutsCast.php b/src/Casts/LayoutsCast.php index 2bbdcd8..c173e7e 100644 --- a/src/Casts/LayoutsCast.php +++ b/src/Casts/LayoutsCast.php @@ -30,7 +30,7 @@ public function get(Model $model, string $key, mixed $value, array $attributes): */ public function set(Model $model, string $key, mixed $value, array $attributes): LayoutItemCollection { - if(!$value instanceof LayoutItemCollection) { + if(! $value instanceof LayoutItemCollection) { return $this->_map($value); } @@ -46,12 +46,13 @@ private function _map(mixed $value): LayoutItemCollection $value = json_decode($value, true, 512, JSON_THROW_ON_ERROR); } - $values = collect($value)->map(fn(array $data): LayoutItem => new LayoutItem( + $values = collect($value)->map(fn (array $data): LayoutItem => new LayoutItem( $data['name'], $data['key'] ?? 0, $data['values'] ?? [], ))->filter(); - } catch (Throwable) {} + } catch (Throwable) { + } return LayoutItemCollection::make($values); } diff --git a/src/Collections/LayoutCollection.php b/src/Collections/LayoutCollection.php index 47fb610..db42d31 100644 --- a/src/Collections/LayoutCollection.php +++ b/src/Collections/LayoutCollection.php @@ -14,11 +14,11 @@ final class LayoutCollection extends Collection { public function findByKey(int $key, ?LayoutContract $default = null): ?LayoutContract { - return $this->first(fn(LayoutContract $layout): bool => $layout->key() === $key, $default); + return $this->first(fn (LayoutContract $layout): bool => $layout->key() === $key, $default); } public function findByName(string $name, ?LayoutContract $default = null): ?LayoutContract { - return $this->first(fn(LayoutContract $layout): bool => $layout->name() === $name, $default); + return $this->first(fn (LayoutContract $layout): bool => $layout->name() === $name, $default); } } diff --git a/src/Collections/LayoutItemCollection.php b/src/Collections/LayoutItemCollection.php index f7be0a8..42ada4a 100644 --- a/src/Collections/LayoutItemCollection.php +++ b/src/Collections/LayoutItemCollection.php @@ -14,11 +14,11 @@ final class LayoutItemCollection extends Collection { public function findByName(string $value): ?LayoutItem { - return $this->firstWhere(fn(LayoutItem $item): bool => $item->getName() === $value); + return $this->firstWhere(fn (LayoutItem $item): bool => $item->getName() === $value); } public function findByKey(int $value): ?LayoutItem { - return $this->firstWhere(fn(LayoutItem $item): bool => $item->getKey() === $value); + return $this->firstWhere(fn (LayoutItem $item): bool => $item->getKey() === $value); } } diff --git a/src/Fields/Layout.php b/src/Fields/Layout.php index 0baf456..7359847 100644 --- a/src/Fields/Layout.php +++ b/src/Fields/Layout.php @@ -117,8 +117,8 @@ public function headingFields(): Fields return Fields::make([ Flex::make(array_filter([ $this->disableSort ? null : Preview::make( - formatted: static fn () => Icon::make('heroicons.outline.bars-4') - ) + formatted: static fn () => Icon::make('heroicons.outline.bars-4') + ) ->withoutWrapper() ->customAttributes(['class' => 'handle', 'style' => 'cursor: move']), diff --git a/src/Http/Controllers/LayoutsController.php b/src/Http/Controllers/LayoutsController.php index eb3ac05..ce50766 100644 --- a/src/Http/Controllers/LayoutsController.php +++ b/src/Http/Controllers/LayoutsController.php @@ -37,7 +37,7 @@ public function store(MoonShineRequest $request): MoonShineJsonResponse ->setValue(LayoutItemCollection::make([ new LayoutItem( $request->get('name'), - ) + ), ])) ->getFilledLayouts() ->findByName($request->get('name')) @@ -67,7 +67,7 @@ private function getField(MoonShineRequest $request): ?Layouts { $page = $request->getPage(); - if(!$resource = $request->getResource()) { + if(! $resource = $request->getResource()) { $fields = Fields::make(is_null($page->pageType()) ? $page->components() : $page->fields()); } else { $fields = match ($page->pageType()) { diff --git a/tests/Feature/LayoutsTest.php b/tests/Feature/LayoutsTest.php index 067fe93..d2d1ef3 100644 --- a/tests/Feature/LayoutsTest.php +++ b/tests/Feature/LayoutsTest.php @@ -27,7 +27,7 @@ public function it_successful_save(): void 'data' => [ ['_layout' => 'first', 'title' => 'First title', 'image' => $image], ['_layout' => 'second', 'title' => 'Second title', 'images' => [$image]], - ] + ], ]; $this->actingAs($this->adminUser, 'moonshine') @@ -49,7 +49,7 @@ public function it_successful_save(): void 'data' => [ ['_layout' => 'first', 'title' => 'First title', 'hidden_image' => $image->hashName()], ['_layout' => 'second', 'title' => 'Second title', 'hidden_images' => [$image->hashName()]], - ] + ], ]; $this->actingAs($this->adminUser, 'moonshine') @@ -69,7 +69,7 @@ public function it_successful_save(): void 'data' => [ ['_layout' => 'first', 'title' => 'First title'], ['_layout' => 'second', 'title' => 'Second title'], - ] + ], ]; $this->actingAs($this->adminUser, 'moonshine') diff --git a/tests/Fixtures/TestModel.php b/tests/Fixtures/TestModel.php index 59541db..22a9ce8 100644 --- a/tests/Fixtures/TestModel.php +++ b/tests/Fixtures/TestModel.php @@ -10,7 +10,7 @@ final class TestModel extends Model { protected $fillable = [ - 'data' + 'data', ]; protected $casts = [ diff --git a/tests/Fixtures/TestResource.php b/tests/Fixtures/TestResource.php index 3d52421..7877186 100644 --- a/tests/Fixtures/TestResource.php +++ b/tests/Fixtures/TestResource.php @@ -25,7 +25,7 @@ public function fields(): array ])->addLayout('second', 'second', [ Text::make('Title'), Image::make('Images')->multiple()->removable(), - ]) + ]), ]; } diff --git a/tests/TestCase.php b/tests/TestCase.php index 2b1a8f6..991fa1a 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -36,7 +36,7 @@ protected function setUp(): void moonshine()->resources([ $this->resource, ], true)->menu([ - MenuItem::make('Test', $this->resource) + MenuItem::make('Test', $this->resource), ]); }