#118: Improve customer form
Also re-added creating a new customer from the order form
This commit is contained in:
parent
47669851ff
commit
6814821100
@ -8,6 +8,7 @@
|
|||||||
use App\Filament\Admin\Resources\CustomerResource\RelationManagers\PaymentsRelationManager;
|
use App\Filament\Admin\Resources\CustomerResource\RelationManagers\PaymentsRelationManager;
|
||||||
use App\Filament\Admin\Resources\CustomerResource\RelationManagers\ShippingEntriesRelationManager;
|
use App\Filament\Admin\Resources\CustomerResource\RelationManagers\ShippingEntriesRelationManager;
|
||||||
use App\Models\Customer;
|
use App\Models\Customer;
|
||||||
|
use Filament\Forms\Components\Fieldset;
|
||||||
use Filament\Forms\Components\Section;
|
use Filament\Forms\Components\Section;
|
||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
@ -29,16 +30,44 @@ class CustomerResource extends Resource
|
|||||||
public static function form(Form $form): Form
|
public static function form(Form $form): Form
|
||||||
{
|
{
|
||||||
return $form
|
return $form
|
||||||
|
->columns(1)
|
||||||
->schema([
|
->schema([
|
||||||
Section::make([
|
Section::make([
|
||||||
|
Fieldset::make('Primary Information')
|
||||||
|
->columns(1)
|
||||||
|
->columnSpan(fn (?Customer $record) => $record ? 1 : 3)
|
||||||
|
->schema([
|
||||||
TextInput::make('company_name')
|
TextInput::make('company_name')
|
||||||
->required(),
|
->required(),
|
||||||
TextInput::make('phone'),
|
TextInput::make('phone'),
|
||||||
TextInput::make('shipping_address_line_1'),
|
]),
|
||||||
TextInput::make('shipping_address_line_2'),
|
|
||||||
TextInput::make('billing_address_line_1'),
|
Fieldset::make('Shipping Address')
|
||||||
TextInput::make('billing_address_line_2'),
|
->columns(1)
|
||||||
])->columns(2),
|
->columnSpan(fn (?Customer $record) => $record ? 1 : 3)
|
||||||
|
->schema([
|
||||||
|
TextInput::make('shipping_address_line_1')
|
||||||
|
->label('Line 1')
|
||||||
|
->placeholder('618 East Kent Ave S #108'),
|
||||||
|
TextInput::make('shipping_address_line_2')
|
||||||
|
->label('Line 2')
|
||||||
|
->placeholder('Vancouver, BC V5X 0B2, Canada'),
|
||||||
|
]),
|
||||||
|
|
||||||
|
Fieldset::make('Billing Address')
|
||||||
|
->columns(1)
|
||||||
|
->columnSpan(fn (?Customer $record) => $record ? 1 : 3)
|
||||||
|
->schema([
|
||||||
|
TextInput::make('billing_address_line_1')
|
||||||
|
->label('Line 1')
|
||||||
|
->placeholder('618 East Kent Ave S #108'),
|
||||||
|
TextInput::make('billing_address_line_2')
|
||||||
|
->label('Line 2')
|
||||||
|
->placeholder('Vancouver, BC V5X 0B2, Canada'),
|
||||||
|
]),
|
||||||
|
])
|
||||||
|
->columns(3)
|
||||||
|
->columnSpan(fn (?Customer $record) => $record ? 1 : 3),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ protected function getHeaderActions(): array
|
|||||||
return [
|
return [
|
||||||
Actions\CreateAction::make()
|
Actions\CreateAction::make()
|
||||||
->modal()
|
->modal()
|
||||||
|
->modalWidth('lg')
|
||||||
->icon(IconEnum::NEW->value)
|
->icon(IconEnum::NEW->value)
|
||||||
->successRedirectUrl(fn ($record) => CustomerResource::getUrl('edit', ['record' => $record->id])),
|
->successRedirectUrl(fn ($record) => CustomerResource::getUrl('edit', ['record' => $record->id])),
|
||||||
];
|
];
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
use App\Enums\OrderAttributes;
|
use App\Enums\OrderAttributes;
|
||||||
use App\Enums\OrderStatus;
|
use App\Enums\OrderStatus;
|
||||||
use App\Enums\OrderType;
|
use App\Enums\OrderType;
|
||||||
use App\Models\Customer;
|
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\Order;
|
use App\Models\Order;
|
||||||
use App\Models\OrderProduct;
|
use App\Models\OrderProduct;
|
||||||
@ -61,11 +60,13 @@ public static function form(Form $form): Form
|
|||||||
->options(OrderType::class)
|
->options(OrderType::class)
|
||||||
->searchable(),
|
->searchable(),
|
||||||
|
|
||||||
// Split::make([
|
|
||||||
Select::make('customer_id')
|
Select::make('customer_id')
|
||||||
->required()
|
->required()
|
||||||
->label('Customer')
|
->label('Customer')
|
||||||
->options(Customer::all()->pluck('company_name', 'id'))
|
->relationship(name: 'customer', titleAttribute: 'company_name')
|
||||||
|
->preload()
|
||||||
|
->createOptionForm(fn ($form) => CustomerResource::form($form))
|
||||||
|
->createOptionAction(fn ($action) => $action->modalWidth('lg'))
|
||||||
->searchable(),
|
->searchable(),
|
||||||
|
|
||||||
TextInput::make('customer_po')
|
TextInput::make('customer_po')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user