#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\ShippingEntriesRelationManager;
|
||||
use App\Models\Customer;
|
||||
use Filament\Forms\Components\Fieldset;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
@ -29,16 +30,44 @@ class CustomerResource extends Resource
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->columns(1)
|
||||
->schema([
|
||||
Section::make([
|
||||
Fieldset::make('Primary Information')
|
||||
->columns(1)
|
||||
->columnSpan(fn (?Customer $record) => $record ? 1 : 3)
|
||||
->schema([
|
||||
TextInput::make('company_name')
|
||||
->required(),
|
||||
TextInput::make('phone'),
|
||||
TextInput::make('shipping_address_line_1'),
|
||||
TextInput::make('shipping_address_line_2'),
|
||||
TextInput::make('billing_address_line_1'),
|
||||
TextInput::make('billing_address_line_2'),
|
||||
])->columns(2),
|
||||
]),
|
||||
|
||||
Fieldset::make('Shipping Address')
|
||||
->columns(1)
|
||||
->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 [
|
||||
Actions\CreateAction::make()
|
||||
->modal()
|
||||
->modalWidth('lg')
|
||||
->icon(IconEnum::NEW->value)
|
||||
->successRedirectUrl(fn ($record) => CustomerResource::getUrl('edit', ['record' => $record->id])),
|
||||
];
|
||||
|
@ -7,7 +7,6 @@
|
||||
use App\Enums\OrderAttributes;
|
||||
use App\Enums\OrderStatus;
|
||||
use App\Enums\OrderType;
|
||||
use App\Models\Customer;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Order;
|
||||
use App\Models\OrderProduct;
|
||||
@ -61,11 +60,13 @@ public static function form(Form $form): Form
|
||||
->options(OrderType::class)
|
||||
->searchable(),
|
||||
|
||||
// Split::make([
|
||||
Select::make('customer_id')
|
||||
->required()
|
||||
->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(),
|
||||
|
||||
TextInput::make('customer_po')
|
||||
|
Loading…
x
Reference in New Issue
Block a user