Kimi chinh sua
This commit is contained in:
@@ -2,9 +2,15 @@
|
||||
|
||||
namespace App\Filament\Resources\Customers\Schemas;
|
||||
|
||||
use App\Models\Customer;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Actions\Action;
|
||||
use Filament\Forms\Components\TagsInput;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Schemas\Components\Utilities\Set;
|
||||
|
||||
class CustomerForm
|
||||
{
|
||||
@@ -12,20 +18,75 @@ class CustomerForm
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('full_name')
|
||||
->required(),
|
||||
TextInput::make('cmnd_cccd')
|
||||
->required(),
|
||||
TextInput::make('phone')
|
||||
->tel(),
|
||||
TextInput::make('email')
|
||||
->label('Email address')
|
||||
->email(),
|
||||
TextInput::make('address_permanent'),
|
||||
TextInput::make('address_contact'),
|
||||
DatePicker::make('dob'),
|
||||
DatePicker::make('id_issue_date'),
|
||||
TextInput::make('id_issue_place'),
|
||||
Section::make('Thông tin định danh')
|
||||
->columns(2)
|
||||
->schema([
|
||||
Select::make('type')
|
||||
->label('Loại khách hàng')
|
||||
->options([
|
||||
'INDIVIDUAL' => 'Cá nhân',
|
||||
'COMPANY' => 'Công ty',
|
||||
])
|
||||
->required()
|
||||
->live(),
|
||||
TextInput::make('full_name')
|
||||
->label(fn ($get) => $get('type') === 'COMPANY' ? 'Tên công ty' : 'Họ và tên')
|
||||
->required(),
|
||||
TextInput::make('cmnd_cccd')
|
||||
->label(fn ($get) => $get('type') === 'COMPANY' ? 'GPKD / Mã số thuế' : 'CMND / CCCD')
|
||||
->required(),
|
||||
TextInput::make('tax_code')
|
||||
->label('Mã số thuế')
|
||||
->visible(fn ($get) => $get('type') === 'COMPANY'),
|
||||
Select::make('representative_id')
|
||||
->label('Người đại diện pháp luật')
|
||||
->options(Customer::where('type', 'INDIVIDUAL')->pluck('full_name', 'id'))
|
||||
->searchable()
|
||||
->visible(fn ($get) => $get('type') === 'COMPANY')
|
||||
->required(fn ($get) => $get('type') === 'COMPANY'),
|
||||
]),
|
||||
|
||||
Section::make('Liên lạc')
|
||||
->columns(2)
|
||||
->schema([
|
||||
TextInput::make('phone')
|
||||
->label('Số điện thoại chính')
|
||||
->tel(),
|
||||
TagsInput::make('secondary_phones')
|
||||
->label('Số điện thoại phụ')
|
||||
->placeholder('Nhập số và nhấn Enter'),
|
||||
TextInput::make('email')
|
||||
->label('Địa chỉ Email')
|
||||
->email(),
|
||||
]),
|
||||
|
||||
Section::make('Địa chỉ')
|
||||
->columns(2)
|
||||
->schema([
|
||||
TextInput::make('permanent_address')
|
||||
->label('Địa chỉ thường trú / Trụ sở')
|
||||
->required()
|
||||
->suffixAction(
|
||||
Action::make('clone_to_contact')
|
||||
->label('Copy sang liên hệ')
|
||||
->icon('heroicon-m-arrow-right-start-on-rectangle')
|
||||
->action(function (Set $set, $state) {
|
||||
$set('contact_address', $state);
|
||||
})
|
||||
),
|
||||
TextInput::make('contact_address')
|
||||
->label('Địa chỉ liên hệ')
|
||||
->required(),
|
||||
]),
|
||||
|
||||
Section::make('Thông tin bổ sung')
|
||||
->columns(3)
|
||||
->visible(fn ($get) => $get('type') === 'INDIVIDUAL')
|
||||
->schema([
|
||||
DatePicker::make('dob')->label('Ngày sinh'),
|
||||
DatePicker::make('id_issue_date')->label('Ngày cấp CMND'),
|
||||
TextInput::make('id_issue_place')->label('Nơi cấp'),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user