[增添]添加了datasource的setting数据库以及默认值

This commit is contained in:
makotocc0107
2024-08-27 09:57:44 +08:00
parent d111dfaea4
commit 72eb990970
10955 changed files with 978898 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
<?php
namespace {{ namespace }};
use App\Models\{{ model }};
use Filament\Forms;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Form;
use Livewire\Component;
use Illuminate\Contracts\View\View;
class {{ class }} extends Component implements HasForms
{
use InteractsWithForms;
public ?array $data = [];
public function mount(): void
{
$this->form->fill();
}
public function form(Form $form): Form
{
return $form
->schema([
{{ schema }}
])
->statePath('data')
->model({{ modelClass }}::class);
}
public function create(): void
{
$data = $this->form->getState();
$record = {{ modelClass }}::create($data);
$this->form->model($record)->saveRelationships();
}
public function render(): View
{
return view('{{ view }}');
}
}

View File

@@ -0,0 +1,47 @@
<?php
namespace {{ namespace }};
use App\Models\{{ model }};
use Filament\Forms;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Form;
use Livewire\Component;
use Illuminate\Contracts\View\View;
class {{ class }} extends Component implements HasForms
{
use InteractsWithForms;
public ?array $data = [];
public {{ modelClass }} $record;
public function mount(): void
{
$this->form->fill($this->record->attributesToArray());
}
public function form(Form $form): Form
{
return $form
->schema([
{{ schema }}
])
->statePath('data')
->model($this->record);
}
public function save(): void
{
$data = $this->form->getState();
$this->record->update($data);
}
public function render(): View
{
return view('{{ view }}');
}
}

10
vendor/filament/forms/stubs/Field.stub vendored Normal file
View File

@@ -0,0 +1,10 @@
<?php
namespace {{ namespace }};
use Filament\Forms\Components\Field;
class {{ class }} extends Field
{
protected string $view = '{{ view }}';
}

View File

@@ -0,0 +1,8 @@
<x-dynamic-component
:component="$getFieldWrapperView()"
:field="$field"
>
<div x-data="{ state: $wire.$entangle('{{ $getStatePath() }}') }">
<!-- Interact with the `state` property in Alpine.js -->
</div>
</x-dynamic-component>

43
vendor/filament/forms/stubs/Form.stub vendored Normal file
View File

@@ -0,0 +1,43 @@
<?php
namespace {{ namespace }};
use Filament\Forms;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Form;
use Livewire\Component;
use Illuminate\Contracts\View\View;
class {{ class }} extends Component implements HasForms
{
use InteractsWithForms;
public ?array $data = [];
public function mount()
{
$this->form->fill();
}
public function form(Form $form): Form
{
return $form
->schema([
//
])
->statePath('data');
}
public function submit(): void
{
$data = $this->form->getState();
//
}
public function render(): View
{
return view('{{ view }}');
}
}

View File

@@ -0,0 +1,11 @@
<div>
<form wire:submit="{{ submitAction }}">
{{ $this->form }}
<button type="submit">
Submit
</button>
</form>
<x-filament-actions::modals />
</div>

View File

@@ -0,0 +1,15 @@
<?php
namespace {{ namespace }};
use Filament\Forms\Components\Component;
class {{ class }} extends Component
{
protected string $view = '{{ view }}';
public static function make(): static
{
return app(static::class);
}
}

View File

@@ -0,0 +1,3 @@
<div {{ $attributes }}>
{{ $getChildComponentContainer() }}
</div>