提交触发价到trigger_prices资料表

This commit is contained in:
2025-06-19 08:58:09 +07:00
parent 18c58aa976
commit 2677ec3ac0
311 changed files with 1210 additions and 29 deletions
Executable → Regular
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
+29 -22
View File
@@ -2,44 +2,51 @@
namespace App\Filament\Widgets;
use Filament\Widgets\Widget;
use Filament\Forms;
use Illuminate\Support\Facades\Cache;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Concerns\InteractsWithForms;
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 InteractsWithForms;
use Forms\Concerns\InteractsWithForms;
protected static string $view = 'filament.widgets.trigger-price-widget';
protected static string $heading = '触发价格设定';
protected static ?int $sort = -1;
protected int | string | array $columnSpan = 'full';
public ?string $price = null;
public bool $showSuccessModal = false;
public string $triggerPrice = '';
public function mount(): void
{
$this->form->fill([
'price' => Cache::get('trigger_price', ''),
'triggerPrice' => '',
]);
}
protected function getFormSchema(): array
{
return [
Forms\Components\TextInput::make('price')
->numeric()
->label('触发价格(例如 21800')
->required(),
];
}
public function submit(): void
{
$data = $this->form->getState();
Cache::put('trigger_price', $data['price']);
$this->dispatch('notify', type: 'success', title: '✅ 触发价格已更新为:' . $data['price']);
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('');
}
}