nang cap san sang import
This commit is contained in:
@@ -47,6 +47,54 @@ class FeedbackForm
|
||||
})
|
||||
->visible(fn ($get): bool => ! $get('is_general'))
|
||||
->nullable()
|
||||
->searchable()
|
||||
->live(),
|
||||
|
||||
Select::make('contract_id')
|
||||
->label('Hợp đồng')
|
||||
->visible(fn ($get): bool => ! $get('is_general') && filled($get('customer_product_id')))
|
||||
->options(function ($get): array {
|
||||
$customerProductId = $get('customer_product_id');
|
||||
if (! $customerProductId) {
|
||||
return [];
|
||||
}
|
||||
$cp = \App\Models\CustomerProduct::find($customerProductId);
|
||||
if (! $cp) {
|
||||
return [];
|
||||
}
|
||||
return \App\Models\Contract::where('product_id', $cp->product_id)
|
||||
->where('status', 'active')
|
||||
->with('customer')
|
||||
->get()
|
||||
->mapWithKeys(fn ($c) => [
|
||||
$c->id => sprintf('%s (%s) - %s',
|
||||
\App\Enums\ContractType::from($c->type)->label(),
|
||||
$c->customer->name,
|
||||
$c->start_date?->format('d/m/Y') ?? 'N/A',
|
||||
),
|
||||
])
|
||||
->toArray();
|
||||
})
|
||||
->afterStateHydrated(function ($component, $state, $get): void {
|
||||
if (filled($state)) {
|
||||
return;
|
||||
}
|
||||
$customerProductId = $get('customer_product_id');
|
||||
if (! $customerProductId) {
|
||||
return;
|
||||
}
|
||||
$cp = \App\Models\CustomerProduct::find($customerProductId);
|
||||
if (! $cp) {
|
||||
return;
|
||||
}
|
||||
$activeContract = \App\Models\Contract::where('product_id', $cp->product_id)
|
||||
->where('status', 'active')
|
||||
->first();
|
||||
if ($activeContract) {
|
||||
$component->state($activeContract->id);
|
||||
}
|
||||
})
|
||||
->nullable()
|
||||
->searchable(),
|
||||
|
||||
Select::make('feedback_channel_id')
|
||||
|
||||
@@ -26,6 +26,18 @@ class FeedbackTable
|
||||
->label('Product')
|
||||
->placeholder('General')
|
||||
->sortable(),
|
||||
TextColumn::make('contract.type')
|
||||
->label('Contract')
|
||||
->badge()
|
||||
->formatStateUsing(fn (?string $state): string => $state ? \App\Enums\ContractType::from($state)->label() : '-')
|
||||
->color(fn (?string $state): string => match ($state) {
|
||||
'sale' => 'success',
|
||||
'lease' => 'info',
|
||||
'bcc' => 'warning',
|
||||
default => 'gray',
|
||||
})
|
||||
->placeholder('-')
|
||||
->toggleable(),
|
||||
TextColumn::make('feedbackChannel.name')
|
||||
->label('Channel'),
|
||||
TextColumn::make('tags.name')
|
||||
|
||||
Reference in New Issue
Block a user