[增添]添加了datasource的setting数据库以及默认值
This commit is contained in:
47
vendor/filament/forms/stubs/CreateForm.stub
vendored
Normal file
47
vendor/filament/forms/stubs/CreateForm.stub
vendored
Normal 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 }}');
|
||||
}
|
||||
}
|
||||
47
vendor/filament/forms/stubs/EditForm.stub
vendored
Normal file
47
vendor/filament/forms/stubs/EditForm.stub
vendored
Normal 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
10
vendor/filament/forms/stubs/Field.stub
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace {{ namespace }};
|
||||
|
||||
use Filament\Forms\Components\Field;
|
||||
|
||||
class {{ class }} extends Field
|
||||
{
|
||||
protected string $view = '{{ view }}';
|
||||
}
|
||||
8
vendor/filament/forms/stubs/FieldView.stub
vendored
Normal file
8
vendor/filament/forms/stubs/FieldView.stub
vendored
Normal 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
43
vendor/filament/forms/stubs/Form.stub
vendored
Normal 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 }}');
|
||||
}
|
||||
}
|
||||
11
vendor/filament/forms/stubs/FormView.stub
vendored
Normal file
11
vendor/filament/forms/stubs/FormView.stub
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
<div>
|
||||
<form wire:submit="{{ submitAction }}">
|
||||
{{ $this->form }}
|
||||
|
||||
<button type="submit">
|
||||
Submit
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<x-filament-actions::modals />
|
||||
</div>
|
||||
15
vendor/filament/forms/stubs/LayoutComponent.stub
vendored
Normal file
15
vendor/filament/forms/stubs/LayoutComponent.stub
vendored
Normal 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);
|
||||
}
|
||||
}
|
||||
3
vendor/filament/forms/stubs/LayoutComponentView.stub
vendored
Normal file
3
vendor/filament/forms/stubs/LayoutComponentView.stub
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
<div {{ $attributes }}>
|
||||
{{ $getChildComponentContainer() }}
|
||||
</div>
|
||||
Reference in New Issue
Block a user