Skip to content

Commit 8b0f41d

Browse files
committed
Merge remote-tracking branch 'origin/develop'
2 parents 1388858 + 2dedc12 commit 8b0f41d

2 files changed

Lines changed: 18 additions & 7 deletions

File tree

app/Http/Controllers/ReportsController.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -808,11 +808,22 @@ public function postCustom(CustomAssetReportRequest $request): StreamedResponse
808808
$checkout_start = Carbon::parse($request->input('checkout_date_start'))->startOfDay();
809809
$checkout_end = Carbon::parse($request->input('checkout_date_end', now()))->endOfDay();
810810

811-
$actionlogassets = Actionlog::select('item_id')->where('action_type', '=', 'checkout')
812-
->where('item_type', '=', Asset::class)
813-
->whereBetween('action_date', [$checkout_start, $checkout_end]); // we are *not* doing ->get()...
814-
815-
$assets->whereIn('assets.id', $actionlogassets); // ...because this _should_ act as a 'subquery'
811+
// Inline closure rather than a pre-built Eloquent Builder so
812+
// the subquery's `select('item_id')` clause is preserved. When
813+
// passed an Eloquent Builder as the second whereIn argument,
814+
// Laravel doesn't always propagate the SELECT to the subquery
815+
// and falls back to `select id`, which is wrong here (we want
816+
// action_logs.item_id, not action_logs.id) and additionally
817+
// combines with the InCategory scope's models/categories joins
818+
// to produce an ambiguous outer `id` in the generated SQL.
819+
$assets->whereIn('assets.id', function ($q) use ($checkout_start, $checkout_end) {
820+
$q->select('item_id')
821+
->from('action_logs')
822+
->where('action_type', '=', 'checkout')
823+
->where('item_type', '=', Asset::class)
824+
->whereBetween('action_date', [$checkout_start, $checkout_end])
825+
->whereNull('deleted_at');
826+
});
816827
}
817828

818829
if (($request->filled('checkin_date_start'))) {

app/Notifications/CheckoutAccessoryNotification.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ public function toMicrosoftTeams()
141141
->addStartGroupToSection('activityText')
142142
->fact(htmlspecialchars_decode($item->display_name), '', 'activityTitle')
143143
->fact(trans('mail.assigned_to'), $target->display_name)
144-
->fact(trans('general.qty'), $this->checkout_qty)
145-
->fact(trans('mail.checkedout_from'), $item->location->name ? $item->location->name : '')
144+
->fact(trans('general.qty'), (string) ($this->checkout_qty ?? 1))
145+
->fact(trans('mail.checkedout_from'), $item->location?->name ?: '')
146146
->fact(trans('mail.Accessory_Checkout_Notification').' by ', $admin->display_name)
147147
->fact(trans('admin/consumables/general.remaining'), $item->numRemaining())
148148
->fact(trans('mail.notes'), $note ?: '');

0 commit comments

Comments
 (0)