components([ 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'), ]), ]); } }