F
Filament6mo ago
Keika

How to get current viewing resource ID in a Widget

Hello all, I'm trying to build a simple widget showing a customer's bookings over time. So far I have the widget chart showing all booking for all users, using the Trend library as stated in the docs. No problem. Thing is the widget is in a View page of a single customer, How can I get the ID of the current viewed customer, to pass it to the Trend request?
$data = Trend::query(Booking::where('customer_id', 1)) // << Want to replace the 1 here
->between(
start: now()->startOfYear(),
end: now()->endOfYear(),
)
->perMonth()
->count();
$data = Trend::query(Booking::where('customer_id', 1)) // << Want to replace the 1 here
->between(
start: now()->startOfYear(),
end: now()->endOfYear(),
)
->perMonth()
->count();
2 Replies
Solution
Keika
KeikaOP6mo ago
Obviously not. Didn't even think to look in the Panel for info about the widgets. Thanks a lot for that, works like a charm
Want results from more Discord servers?
Add your server