Closed aeq-dev closed 1 month ago
Hi, it's an ugly hack, but this is what I did in a project where I needed to do the same:
public function getEvents(array $fetchInfo = []): Collection|array
{
// Store the current "view" (start / end dates)
$this->currentView = [
'start' => data_get($fetchInfo, 'startStr'),
'end' => data_get($fetchInfo, 'endStr'),
];
// Trigger a resource refresh
$this->refreshResources();
// Returns your events as usual
// ...
}
And in the getResources
method you can now read the start/end date from $this->currentView
to query your resources accordingly.
the downside is that the resources are loaded twice each time.
Actually, there's a much simpler option since a few days now.
I didn't test it yet, but you should be able to do this:
public function getOptions () {
return [
'filterResourcesWithEvents' => true,
];
}
It'll only show resources which have events assigned for the current view.
Thank you so much ! the first option helped me, I'll try the second later :)
What happened?
Hello, I have a User as Resourceable model, each user has many tasks. I'm using
$calendarView = 'resourceTimeGridDay'
, I want to display only users having tasks on selected date. How could I achieve that ? ThanksHow to reproduce the bug
It's a question :)
Package Version
1.8
PHP Version
8.2
Laravel Version
10
Which operating systems does with happen with?
No response
Notes
No response