From 7e48e6edcc95708dacbab35627df1706612ea5e2 Mon Sep 17 00:00:00 2001 From: datlechin Date: Tue, 20 Aug 2024 13:49:34 +0000 Subject: [PATCH] Fix styling --- src/Concerns/HasLocationAction.php | 8 ++++---- src/Concerns/HasMenuPanel.php | 2 +- src/FilamentMenuBuilderPlugin.php | 2 +- src/Livewire/MenuItems.php | 22 +++++++++++----------- src/Livewire/MenuPanel.php | 4 ++-- src/MenuPanel/ModelMenuPanel.php | 4 ++-- src/Models/Menu.php | 2 +- src/Resources/MenuResource.php | 8 ++++---- tests/TestCase.php | 2 +- 9 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/Concerns/HasLocationAction.php b/src/Concerns/HasLocationAction.php index 400b48f..1478506 100644 --- a/src/Concerns/HasLocationAction.php +++ b/src/Concerns/HasLocationAction.php @@ -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) { @@ -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') diff --git a/src/Concerns/HasMenuPanel.php b/src/Concerns/HasMenuPanel.php index 92574b0..0c3642f 100644 --- a/src/Concerns/HasMenuPanel.php +++ b/src/Concerns/HasMenuPanel.php @@ -17,6 +17,6 @@ public function getMenuPanelName(): string public function getMenuPanelModifyQueryUsing(): callable { - return fn(Builder $query) => $query; + return fn (Builder $query) => $query; } } diff --git a/src/FilamentMenuBuilderPlugin.php b/src/FilamentMenuBuilderPlugin.php index 11d97b5..5231737 100644 --- a/src/FilamentMenuBuilderPlugin.php +++ b/src/FilamentMenuBuilderPlugin.php @@ -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(); } diff --git a/src/Livewire/MenuItems.php b/src/Livewire/MenuItems.php index 88daa9c..8a3b74b 100644 --- a/src/Livewire/MenuItems.php +++ b/src/Livewire/MenuItems.php @@ -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, @@ -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() @@ -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), ) @@ -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 { diff --git a/src/Livewire/MenuPanel.php b/src/Livewire/MenuPanel.php index 328d0c6..b82f53d 100644 --- a/src/Livewire/MenuPanel.php +++ b/src/Livewire/MenuPanel.php @@ -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, @@ -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([ diff --git a/src/MenuPanel/ModelMenuPanel.php b/src/MenuPanel/ModelMenuPanel.php index 204bb1c..74a4043 100644 --- a/src/MenuPanel/ModelMenuPanel.php +++ b/src/MenuPanel/ModelMenuPanel.php @@ -21,7 +21,7 @@ class ModelMenuPanel extends AbstractMenuPanel */ public function model(string $model): static { - $this->model = new $model(); + $this->model = new $model; return $this; } @@ -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(), diff --git a/src/Models/Menu.php b/src/Models/Menu.php index c41f4a4..4fa4c2e 100644 --- a/src/Models/Menu.php +++ b/src/Models/Menu.php @@ -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; } diff --git a/src/Resources/MenuResource.php b/src/Resources/MenuResource.php index 3881447..f8bf81a 100644 --- a/src/Resources/MenuResource.php +++ b/src/Resources/MenuResource.php @@ -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()), ]); } @@ -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() @@ -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(), diff --git a/tests/TestCase.php b/tests/TestCase.php index bbc551d..92e49e3 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -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', ); }