Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
lee-to authored and github-actions[bot] committed Aug 16, 2024
1 parent 2ece998 commit e471f60
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 19 deletions.
3 changes: 1 addition & 2 deletions src/Casts/LayoutItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ public function __construct(
private string $name,
private int $key = 0,
private array $values = []
)
{
) {
}

public function getName(): string
Expand Down
7 changes: 4 additions & 3 deletions src/Casts/LayoutsCast.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Collections/LayoutCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
4 changes: 2 additions & 2 deletions src/Collections/LayoutItemCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
4 changes: 2 additions & 2 deletions src/Fields/Layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']),

Expand Down
4 changes: 2 additions & 2 deletions src/Http/Controllers/LayoutsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function store(MoonShineRequest $request): MoonShineJsonResponse
->setValue(LayoutItemCollection::make([
new LayoutItem(
$request->get('name'),
)
),
]))
->getFilledLayouts()
->findByName($request->get('name'))
Expand Down Expand Up @@ -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()) {
Expand Down
6 changes: 3 additions & 3 deletions tests/Feature/LayoutsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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')
Expand All @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/TestModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
final class TestModel extends Model
{
protected $fillable = [
'data'
'data',
];

protected $casts = [
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/TestResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function fields(): array
])->addLayout('second', 'second', [
Text::make('Title'),
Image::make('Images')->multiple()->removable(),
])
]),
];
}

Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected function setUp(): void
moonshine()->resources([
$this->resource,
], true)->menu([
MenuItem::make('Test', $this->resource)
MenuItem::make('Test', $this->resource),
]);
}

Expand Down

0 comments on commit e471f60

Please sign in to comment.