This PR adds support for passing an array or collection of IDs to State::load(), to load multiple states. load() will return a StateCollection of loaded states.
$states = MyState::load([1, 2, 5, 8]);
The caveat here is that this just wraps up the existing load functionality, so it does cause n+1 issues.
I looked into creating a load method that can load multiple states with only a couple of queries, but due to the state event queries using the after_event_id makes the query a lot more difficult.
This PR adds support for passing an array or collection of IDs to
State::load()
, to load multiple states.load
() will return a StateCollection of loaded states.The caveat here is that this just wraps up the existing load functionality, so it does cause n+1 issues.
This saves people having to do this manually
I looked into creating a load method that can load multiple states with only a couple of queries, but due to the state event queries using the
after_event_id
makes the query a lot more difficult.So for now I have just opted to keep it simple.