Skip to content

Commit

Permalink
Fix: Voucher list, add guests to voucher
Browse files Browse the repository at this point in the history
  • Loading branch information
barbosa89 committed Feb 3, 2021
1 parent bc2339f commit 3c3383c
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions app/Repositories/VoucherRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,22 @@ public function list(): Collection
{
return Voucher::owner()
->lodging()
->with(['hotel', 'guests', 'company', 'payments'])
->with([
'guests' => function ($query) {
$query->select(fields_dotted('guests'))
->withPivot('main', 'active');
},
'hotel' => function ($query) {
$query->select(fields_get('hotels'));
},
'company' => function ($query) {
$query->select(fields_get('companies'));
},
'payments' => function ($query)
{
$query->select(fields_get('payments'));
},
])
->get(fields_dotted('vouchers'));
}

Expand All @@ -155,7 +170,22 @@ public function first(int $id): Voucher
return Voucher::owner()
->id($id)
->open()
->with(['guests', 'guests.identificationType', 'rooms', 'hotel'])
->with([
'guests' => function ($query) {
$query->select(fields_dotted('guests'))
->withPivot('main', 'active');
},
'guests.identificationType' => function ($query) {
$query->select('id', 'type');
},
'rooms' => function ($query) {
$query->select(fields_dotted('rooms'))
->withPivot('quantity', 'discount', 'subvalue', 'taxes', 'value', 'start', 'end', 'price', 'enabled');
},
'hotel' => function ($query) {
$query->select(fields_get('hotels'));
},
])
->first(fields_dotted('vouchers'));
}
}

0 comments on commit 3c3383c

Please sign in to comment.