Closed martin-ro closed 1 year ago
Ok, so investigating this further... in abstract class PageBlock
public static function getName(): string
{
return static::getBlockSchema()->getName();
}
is called which causes the queries to be run. For now, I can get around it by implementing getName()
in each of my blocks and just returning a string.
Passing a closure to ->options()
in Select
ensures, that it is evaluated only when needed
Select::make('users')
->options(fn () => User::pluck('name', 'id'))
Ohhh... good catch! :)
First of all, great plugin! Thanks for your work!
I noticed that queries in
PageBlocks
are fired every time you visit a page. Take for example this block:When visiting the page, the mutated data is cached but the query for the
Select
(User::pluck('name', 'id')
) field is still running every time.Cheers, Martin