Compare commits
2 Commits
c4d9ecb39e
...
137e0b45ad
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
137e0b45ad | ||
|
|
2ad24216ae |
|
|
@ -34,6 +34,7 @@ class SegmentContractsExport extends DefaultValueBinder implements FromQuery, Sh
|
||||||
public const COLUMN_METADATA = [
|
public const COLUMN_METADATA = [
|
||||||
'reference' => ['label' => 'Pogodba'],
|
'reference' => ['label' => 'Pogodba'],
|
||||||
'client_case' => ['label' => 'Primer'],
|
'client_case' => ['label' => 'Primer'],
|
||||||
|
'address' => ['label' => 'Naslov'],
|
||||||
'client' => ['label' => 'Stranka'],
|
'client' => ['label' => 'Stranka'],
|
||||||
'type' => ['label' => 'Vrsta'],
|
'type' => ['label' => 'Vrsta'],
|
||||||
'start_date' => ['label' => 'Začetek'],
|
'start_date' => ['label' => 'Začetek'],
|
||||||
|
|
@ -107,6 +108,7 @@ private function resolveValue(Contract $contract, string $column): mixed
|
||||||
return match ($column) {
|
return match ($column) {
|
||||||
'reference' => $contract->reference,
|
'reference' => $contract->reference,
|
||||||
'client_case' => optional($contract->clientCase?->person)->full_name,
|
'client_case' => optional($contract->clientCase?->person)->full_name,
|
||||||
|
'address' => optional($contract->clientCase?->person?->address)->address,
|
||||||
'client' => optional($contract->clientCase?->client?->person)->full_name,
|
'client' => optional($contract->clientCase?->client?->person)->full_name,
|
||||||
'type' => optional($contract->type)->name,
|
'type' => optional($contract->type)->name,
|
||||||
'start_date' => $this->formatDate($contract->start_date),
|
'start_date' => $this->formatDate($contract->start_date),
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,12 @@ public function show(Segment $segment)
|
||||||
|
|
||||||
$contracts = $this->hydrateClientShortcut($contracts);
|
$contracts = $this->hydrateClientShortcut($contracts);
|
||||||
|
|
||||||
|
// Hide addresses array since we're using the singular address relationship
|
||||||
|
$contracts->getCollection()->each(function ($contract) {
|
||||||
|
$contract->clientCase?->person?->makeHidden('addresses');
|
||||||
|
$contract->clientCase?->client?->person?->makeHidden('addresses');
|
||||||
|
});
|
||||||
|
|
||||||
$clients = Client::query()
|
$clients = Client::query()
|
||||||
->whereHas('clientCases.contracts.segments', function ($q) use ($segment) {
|
->whereHas('clientCases.contracts.segments', function ($q) use ($segment) {
|
||||||
$q->where('segments.id', $segment->id)
|
$q->where('segments.id', $segment->id)
|
||||||
|
|
@ -191,8 +197,7 @@ private function buildContractsQuery(Segment $segment, ?string $search, ?string
|
||||||
->where('contract_segment.active', '=', 1);
|
->where('contract_segment.active', '=', 1);
|
||||||
})
|
})
|
||||||
->with([
|
->with([
|
||||||
'clientCase.person',
|
'clientCase.person.address',
|
||||||
'clientCase.client.person',
|
|
||||||
'type',
|
'type',
|
||||||
'account',
|
'account',
|
||||||
])
|
])
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,14 @@ public function addresses(): HasMany
|
||||||
->orderBy('id');
|
->orderBy('id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function address(): HasOne
|
||||||
|
{
|
||||||
|
return $this->hasOne(\App\Models\Person\PersonAddress::class)
|
||||||
|
->with(['type'])
|
||||||
|
->where('active', '=', 1)
|
||||||
|
->oldestOfMany('id');
|
||||||
|
}
|
||||||
|
|
||||||
public function emails(): HasMany
|
public function emails(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(\App\Models\Email::class, 'person_id')
|
return $this->hasMany(\App\Models\Email::class, 'person_id')
|
||||||
|
|
|
||||||
|
|
@ -49,11 +49,12 @@ const clientComboboxOpen = ref(false);
|
||||||
const columns = [
|
const columns = [
|
||||||
{ key: "reference", label: "Pogodba", sortable: false },
|
{ key: "reference", label: "Pogodba", sortable: false },
|
||||||
{ key: "client_case", label: "Primer", sortable: false },
|
{ key: "client_case", label: "Primer", sortable: false },
|
||||||
|
{ key: "address", label: "Naslov", sortable: false },
|
||||||
{ key: "client", label: "Stranka", sortable: false },
|
{ key: "client", label: "Stranka", sortable: false },
|
||||||
{ key: "type", label: "Vrsta", sortable: false },
|
{ key: "type", label: "Vrsta", sortable: false },
|
||||||
{ key: "start_date", label: "Začetek", sortable: false },
|
{ key: "start_date", label: "Začetek", sortable: false },
|
||||||
{ key: "end_date", label: "Konec", sortable: false },
|
{ key: "end_date", label: "Konec", sortable: false },
|
||||||
{ key: "account", label: "Stanje", align: "right", sortable: false },
|
{ key: "account", label: "Stanje", align: "right" },
|
||||||
];
|
];
|
||||||
|
|
||||||
const exportDialogOpen = ref(false);
|
const exportDialogOpen = ref(false);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user