Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

redlik's avatar

Livewire and scopes

I'm looking for a best way to implement my local scope in the Livewire component. I have bunch of students in database and I've created a local scope age that filters by d.o.b all students - either all or over 18 yrs old. Works fine. I've created a livewire component that lists all of them in a table. I've created a checkbox above the table to only show adults and I was wondering what's the best way to implement the state of the checkbox in the query. Right now I just have if statement in component logic: if selected the query has ->age() in it, if not it hasn't.

Is there a better way to do it - just changing the query the return function spits out?

0 likes
1 reply

Please or to participate in this conversation.