components([ Section::make('Liên kết & Mẫu thanh toán') ->columns(2) ->schema([ Select::make('product_id') ->label('Sản phẩm') ->relationship('product', 'code') ->required() ->live() ->afterStateUpdated(function (Set $set, $state) { if ($state) { $product = Product::find($state); if ($product) { $set('total_value', $product->total_price); } } }), Select::make('payment_template_id') ->label('Mẫu thanh toán') ->options(fn () => PaymentTemplate::pluck('name', 'id')) ->required() ->dehydrated(false), Select::make('customers') ->label('Khách hàng') ->relationship('customers', 'full_name') ->multiple() ->required() ->columnSpanFull(), ]), Section::make('Chi tiết Hợp đồng') ->columns(2) ->schema([ TextInput::make('contract_number')->label('Số HĐ')->required(), Select::make('contract_type') ->label('Loại HĐ') ->options([ 'HĐMB' => 'HĐMB', 'HĐGV' => 'HĐGV', 'HĐDC' => 'HĐDC', ]) ->default('HĐMB') ->required(), DatePicker::make('signing_date')->label('Ngày ký')->required(), TextInput::make('total_value') ->label('Giá trị HĐ') ->numeric() ->required() ->prefix('VND'), Select::make('status') ->label('Trạng thái') ->options([ 'Đang hiệu lực' => 'Đang hiệu lực', 'Đã hoàn thành' => 'Đã hoàn thành', 'Đã hủy' => 'Đã hủy', ]) ->default('Đang hiệu lực') ->required(), ]) ]); } }