Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
datlechin authored and github-actions[bot] committed Aug 20, 2024
1 parent d912aa8 commit 7e48e6e
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 27 deletions.
8 changes: 4 additions & 4 deletions src/Concerns/HasLocationAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ public function getLocationAction(): Action
->modalWidth(MaxWidth::Large)
->modalSubmitAction($this->getRegisteredLocations()->isEmpty() ? false : null)
->color('gray')
->fillForm(fn() => $this->getRegisteredLocations()->map(fn($location, $key) => [
->fillForm(fn () => $this->getRegisteredLocations()->map(fn ($location, $key) => [
'location' => $location,
'menu' => $this->getMenuLocations()->where('location', $key)->first()?->menu_id,
])->all())
->action(function (array $data) {
$locations = collect($data)
->map(fn($item) => $item['menu'] ?? null)
->map(fn ($item) => $item['menu'] ?? null)
->all();

$this->getMenuLocations()
->pluck('location')
->diff($this->getRegisteredLocations()->keys())
->each(fn($location) => $this->getMenuLocations()->where('location', $location)->each->delete());
->each(fn ($location) => $this->getMenuLocations()->where('location', $location)->each->delete());

foreach ($locations as $location => $menu) {
if (! $menu) {
Expand All @@ -58,7 +58,7 @@ public function getLocationAction(): Action
->send();
})
->form($this->getRegisteredLocations()->map(
fn($location, $key) => Components\Grid::make(2)
fn ($location, $key) => Components\Grid::make(2)
->statePath($key)
->schema([
Components\TextInput::make('location')
Expand Down
2 changes: 1 addition & 1 deletion src/Concerns/HasMenuPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ public function getMenuPanelName(): string

public function getMenuPanelModifyQueryUsing(): callable
{
return fn(Builder $query) => $query;
return fn (Builder $query) => $query;
}
}
2 changes: 1 addition & 1 deletion src/FilamentMenuBuilderPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public function getMenuLocationModel(): string
public function getMenuPanels(): array
{
return collect($this->menuPanels)
->sortBy(fn(MenuPanel $menuPanel) => $menuPanel->getSort())
->sortBy(fn (MenuPanel $menuPanel) => $menuPanel->getSort())
->all();
}

Expand Down
22 changes: 11 additions & 11 deletions src/Livewire/MenuItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function reorder(array $order, ?string $parentId = null): void
->update([
'order' => DB::raw(
'case ' . collect($order)
->map(fn($recordKey, int $recordIndex): string => 'when id = ' . DB::getPdo()->quote($recordKey) . ' then ' . ($recordIndex + 1))
->map(fn ($recordKey, int $recordIndex): string => 'when id = ' . DB::getPdo()->quote($recordKey) . ' then ' . ($recordIndex + 1))
->implode(' ') . ' end',
),
'parent_id' => $parentId,
Expand All @@ -78,9 +78,9 @@ public function editAction(): Action
->label(__('filament-actions::edit.single.label'))
->iconButton()
->size(ActionSize::Small)
->modalHeading(fn(array $arguments): string => __('filament-actions::edit.single.modal.heading', ['label' => $arguments['title']]))
->modalHeading(fn (array $arguments): string => __('filament-actions::edit.single.modal.heading', ['label' => $arguments['title']]))
->icon('heroicon-m-pencil-square')
->fillForm(fn(array $arguments): array => FilamentMenuBuilderPlugin::get()->getMenuItemModel()::query()
->fillForm(fn (array $arguments): array => FilamentMenuBuilderPlugin::get()->getMenuItemModel()::query()
->where('id', $arguments['id'])
->with('linkable')
->first()
Expand All @@ -90,27 +90,27 @@ public function editAction(): Action
->label(__('filament-menu-builder::menu-builder.form.title'))
->required(),
TextInput::make('url')
->hidden(fn(?string $state, Get $get): bool => blank($state) || filled($get('linkable_type')))
->hidden(fn (?string $state, Get $get): bool => blank($state) || filled($get('linkable_type')))
->label(__('filament-menu-builder::menu-builder.form.url'))
->required(),
Placeholder::make('linkable_type')
->label(__('filament-menu-builder::menu-builder.form.linkable_type'))
->hidden(fn(?string $state): bool => blank($state))
->content(fn(string $state) => $state),
->hidden(fn (?string $state): bool => blank($state))
->content(fn (string $state) => $state),
Placeholder::make('linkable_id')
->label(__('filament-menu-builder::menu-builder.form.linkable_id'))
->hidden(fn(?string $state): bool => blank($state))
->content(fn(string $state) => $state),
->hidden(fn (?string $state): bool => blank($state))
->content(fn (string $state) => $state),
Select::make('target')
->label(__('filament-menu-builder::menu-builder.open_in.label'))
->options(LinkTarget::class)
->default(LinkTarget::Self),
Group::make()
->visible(fn(FormComponent $component) => $component->evaluate(FilamentMenuBuilderPlugin::get()->getMenuItemFields()) !== [])
->visible(fn (FormComponent $component) => $component->evaluate(FilamentMenuBuilderPlugin::get()->getMenuItemFields()) !== [])
->schema(FilamentMenuBuilderPlugin::get()->getMenuItemFields()),
])
->action(
fn(array $data, array $arguments) => FilamentMenuBuilderPlugin::get()->getMenuItemModel()::query()
fn (array $data, array $arguments) => FilamentMenuBuilderPlugin::get()->getMenuItemModel()::query()
->where('id', $arguments['id'])
->update($data),
)
Expand All @@ -128,7 +128,7 @@ public function deleteAction(): Action
->iconButton()
->size(ActionSize::Small)
->requiresConfirmation()
->modalHeading(fn(array $arguments): string => __('filament-actions::delete.single.modal.heading', ['label' => $arguments['title']]))
->modalHeading(fn (array $arguments): string => __('filament-actions::delete.single.modal.heading', ['label' => $arguments['title']]))
->modalSubmitActionLabel(__('filament-actions::delete.single.modal.actions.delete.label'))
->modalIcon(FilamentIcon::resolve('actions::delete-action.modal') ?? 'heroicon-o-trash')
->action(function (array $arguments): void {
Expand Down
4 changes: 2 additions & 2 deletions src/Livewire/MenuPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function add(): void
$order = $this->menu->menuItems->max('order') ?? 0;

$selectedItems = collect($this->items)
->filter(fn($item) => in_array($item['title'], $this->data))
->filter(fn ($item) => in_array($item['title'], $this->data))
->map(function ($item) use (&$order) {
return [
...$item,
Expand All @@ -102,7 +102,7 @@ public function add(): void

public function form(Form $form): Form
{
$items = collect($this->getItems())->mapWithKeys(fn($item) => [$item['title'] => $item['title']]);
$items = collect($this->getItems())->mapWithKeys(fn ($item) => [$item['title'] => $item['title']]);

return $form
->schema([
Expand Down
4 changes: 2 additions & 2 deletions src/MenuPanel/ModelMenuPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ModelMenuPanel extends AbstractMenuPanel
*/
public function model(string $model): static
{
$this->model = new $model();
$this->model = new $model;

return $this;
}
Expand All @@ -35,7 +35,7 @@ public function getItems(): array
{
return ($this->model->getMenuPanelModifyQueryUsing())($this->model->newQuery())
->get()
->map(fn(Model $model) => [
->map(fn (Model $model) => [
'title' => $model->{$this->model->getMenuPanelTitleColumn()},
'linkable_type' => $model::class,
'linkable_id' => $model->getKey(),
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function menuItems(): HasMany
public static function location(string $location): ?self
{
return FilamentMenuBuilderPlugin::get()
->getMenuLocationModel()::with(['menu' => fn(Builder $query) => $query->where('is_visible', true)])
->getMenuLocationModel()::with(['menu' => fn (Builder $query) => $query->where('is_visible', true)])
->where('location', $location)
->first()?->menu;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Resources/MenuResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static function form(Form $form): Form
]),

Components\Group::make()
->visible(fn(Component $component) => $component->evaluate(FilamentMenuBuilderPlugin::get()->getMenuFields()) !== [])
->visible(fn (Component $component) => $component->evaluate(FilamentMenuBuilderPlugin::get()->getMenuFields()) !== [])
->schema(FilamentMenuBuilderPlugin::get()->getMenuFields()),
]);
}
Expand All @@ -59,7 +59,7 @@ public static function table(Table $table): Table
$locations = FilamentMenuBuilderPlugin::get()->getLocations();

return $table
->modifyQueryUsing(fn($query) => $query->withCount('menuItems'))
->modifyQueryUsing(fn ($query) => $query->withCount('menuItems'))
->columns([
Tables\Columns\TextColumn::make('name')
->searchable()
Expand All @@ -68,8 +68,8 @@ public static function table(Table $table): Table
Tables\Columns\TextColumn::make('locations.location')
->label(__('filament-menu-builder::menu-builder.resource.locations.label'))
->default(__('filament-menu-builder::menu-builder.resource.locations.empty'))
->color(fn(string $state) => array_key_exists($state, $locations) ? 'primary' : 'gray')
->formatStateUsing(fn(string $state) => $locations[$state] ?? $state)
->color(fn (string $state) => array_key_exists($state, $locations) ? 'primary' : 'gray')
->formatStateUsing(fn (string $state) => $locations[$state] ?? $state)
->limitList(2)
->sortable()
->badge(),
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected function setUp(): void
parent::setUp();

Factory::guessFactoryNamesUsing(
fn(string $modelName) => 'Datlechin\\FilamentMenuBuilder\\Database\\Factories\\' . class_basename($modelName) . 'Factory',
fn (string $modelName) => 'Datlechin\\FilamentMenuBuilder\\Database\\Factories\\' . class_basename($modelName) . 'Factory',
);
}

Expand Down

0 comments on commit 7e48e6e

Please sign in to comment.