`getInstance( "SomeTable" ).whereHas( "status", ( ...
# box-products
e
getInstance( "SomeTable" ).whereHas( "status", ( q ) => q.where( "description", "foo" ) );
Note that this requires a
status
relationship on the
SomeTable
entity.
j
so i actually tried this and the resulting sql was doing an exists clause instead of a simple join, which really gives me pause, but also seems like it wouldn't solve for when i want the description eager loaded. Also, the query actually failed because it was missing a . between the table and the column in the where clause, but i didn't look further into that
i'm just a little surprised it's not more obvious how i would set up the relationships/columns so that i can have status be a normal getter that grabs the description column from a joined table
i'm hoping i'm just missing something glaringly obvious
e
You can either eager load the status (
getInstance( "SomeTable" ).with( "status" )
) or add it as a subselect (
getInstance( "SomeTable" ).addSubselect( "statusDescription", "status.description" )
).
Quick doesn’t grab data as joined tables.
Not without you adding the join and virtual attributes yourself.
j
thanks, i created a scope to add it and join in there and add the virtual attribute... it does what i want now. thanks again!