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.
- Loading branch information
1 parent
73a77d7
commit 310191f
Showing
1 changed file
with
60 additions
and
60 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +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'); | ||
} | ||
} | ||
<?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'); | ||
} | ||
} |