53 lines
1.2 KiB
PHP
53 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Widgets;
|
|
|
|
use Filament\Forms;
|
|
use Filament\Forms\Contracts\HasForms;
|
|
use Filament\Forms\Form;
|
|
use Filament\Widgets\Widget;
|
|
use Livewire\Component;
|
|
use App\Models\TriggerPrice;
|
|
use Filament\Notifications\Notification;
|
|
use Filament\Actions\Action;
|
|
|
|
class TriggerPriceWidget extends Widget implements HasForms
|
|
{
|
|
use Forms\Concerns\InteractsWithForms;
|
|
|
|
protected static string $view = 'filament.widgets.trigger-price-widget';
|
|
|
|
public bool $showSuccessModal = false;
|
|
|
|
public string $triggerPrice = '';
|
|
|
|
public function mount(): void
|
|
{
|
|
$this->form->fill([
|
|
'triggerPrice' => '',
|
|
]);
|
|
}
|
|
|
|
public function submit(): void
|
|
{
|
|
TriggerPrice::create([
|
|
'price' => $this->triggerPrice,
|
|
'created_at' => now(),
|
|
]);
|
|
|
|
$this->showSuccessModal = true;
|
|
}
|
|
|
|
public function form(Form $form): Form
|
|
{
|
|
return $form
|
|
->schema([
|
|
Forms\Components\TextInput::make('triggerPrice')
|
|
->label('触发价格')
|
|
->numeric()
|
|
->required(),
|
|
])
|
|
->statePath('');
|
|
}
|
|
}
|