98 lines
4.1 KiB
PHP
98 lines
4.1 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Contracts\Schemas;
|
|
|
|
use App\Enums\ContractCategory;
|
|
use App\Enums\ContractStatus;
|
|
use App\Enums\ContractType;
|
|
use Filament\Forms\Components\DatePicker;
|
|
use Filament\Forms\Components\Select;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Schemas\Components\Section;
|
|
use Filament\Schemas\Schema;
|
|
|
|
class ContractForm
|
|
{
|
|
public static function configure(Schema $schema): Schema
|
|
{
|
|
return $schema
|
|
->components([
|
|
Section::make(__('app.contract_category_section'))
|
|
->schema([
|
|
Select::make('category')
|
|
->label(__('enums.contract_category_label'))
|
|
->options(ContractCategory::options())
|
|
->required()
|
|
->native(false)
|
|
->live(),
|
|
Select::make('type')
|
|
->label(__('enums.contract_type_label'))
|
|
->options(function ($get): array {
|
|
$category = $get('category');
|
|
if ($category === 'ownership') {
|
|
return collect(ContractType::ownershipCases())->mapWithKeys(fn ($c) => [
|
|
$c->value => $c->label(),
|
|
])->toArray();
|
|
}
|
|
if ($category === 'business') {
|
|
return collect(ContractType::businessCases())->mapWithKeys(fn ($c) => [
|
|
$c->value => $c->label(),
|
|
])->toArray();
|
|
}
|
|
|
|
return ContractType::options();
|
|
})
|
|
->required()
|
|
->native(false),
|
|
])
|
|
->columns(2),
|
|
|
|
Section::make(__('app.contract_info'))
|
|
->schema([
|
|
Select::make('product_id')
|
|
->label(__('app.product'))
|
|
->relationship('product', 'name')
|
|
->searchable()
|
|
->required(),
|
|
Select::make('customer_id')
|
|
->label(__('app.widget_customer'))
|
|
->relationship('customer', 'name')
|
|
->searchable()
|
|
->required(),
|
|
Select::make('status')
|
|
->label(__('app.status'))
|
|
->options(ContractStatus::ACTIVE->options())
|
|
->default('active')
|
|
->required()
|
|
->native(false),
|
|
DatePicker::make('start_date')
|
|
->label(__('app.start_date')),
|
|
DatePicker::make('end_date')
|
|
->label(__('app.end_date')),
|
|
DatePicker::make('printed_at')
|
|
->label(__('app.printed_at')),
|
|
TextInput::make('signed_status')
|
|
->label(__('app.signed_status'))
|
|
->maxLength(255),
|
|
])
|
|
->columns(2),
|
|
|
|
Section::make(__('app.representative_info'))
|
|
->description(__('app.representative_desc'))
|
|
->schema([
|
|
TextInput::make('representative_name')
|
|
->label(__('app.name'))
|
|
->maxLength(255),
|
|
TextInput::make('representative_phone')
|
|
->label(__('app.phone'))
|
|
->maxLength(20),
|
|
TextInput::make('representative_email')
|
|
->label(__('app.email'))
|
|
->email()
|
|
->maxLength(255),
|
|
])
|
|
->columns(3),
|
|
]);
|
|
}
|
|
}
|