generated from filamentphp/plugin-skeleton
-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from Senexis/feature-custom-text
Add ability to add text only items. (#47)
- Loading branch information
Showing
11 changed files
with
140 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<form wire:submit="save"> | ||
<x-filament::section | ||
:heading="__('filament-menu-builder::menu-builder.custom_text')" | ||
:collapsible="true" | ||
:persist-collapsed="true" | ||
id="create-custom-text" | ||
> | ||
{{ $this->form }} | ||
|
||
<x-slot:footerActions> | ||
<x-filament::button type="submit"> | ||
{{ __('filament-menu-builder::menu-builder.actions.add.label') }} | ||
</x-filament::button> | ||
</x-slot:footerActions> | ||
</x-filament::section> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Datlechin\FilamentMenuBuilder\Livewire; | ||
|
||
use Datlechin\FilamentMenuBuilder\Models\Menu; | ||
use Filament\Forms\Components\TextInput; | ||
use Filament\Forms\Concerns\InteractsWithForms; | ||
use Filament\Forms\Contracts\HasForms; | ||
use Filament\Forms\Form; | ||
use Filament\Notifications\Notification; | ||
use Illuminate\Contracts\View\View; | ||
use Livewire\Component; | ||
|
||
class CreateCustomText extends Component implements HasForms | ||
{ | ||
use InteractsWithForms; | ||
|
||
public Menu $menu; | ||
|
||
public string $title = ''; | ||
|
||
public function save(): void | ||
{ | ||
$this->validate([ | ||
'title' => ['required', 'string'], | ||
]); | ||
|
||
$this->menu | ||
->menuItems() | ||
->create([ | ||
'title' => $this->title, | ||
'order' => $this->menu->menuItems->max('order') + 1, | ||
]); | ||
|
||
Notification::make() | ||
->title(__('filament-menu-builder::menu-builder.notifications.created.title')) | ||
->success() | ||
->send(); | ||
|
||
$this->reset('title'); | ||
$this->dispatch('menu:created'); | ||
} | ||
|
||
public function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema([ | ||
TextInput::make('title') | ||
->label(__('filament-menu-builder::menu-builder.form.title')) | ||
->required(), | ||
]); | ||
} | ||
|
||
public function render(): View | ||
{ | ||
return view('filament-menu-builder::livewire.create-custom-text'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters