Sunday 15 January 2012

orm - Eloquent Relation Filtering -


Is it possible to filter out the result set in Laravel's elite ORM by related models? I think that the eloquent does not include in the tables, but the results I would like will be the same:

Select position on tickets from select tickets. Status_id = statuses.id where conditions Name! = 'Turned off';

I have the closest functionality found in the eloquent:

 with $ ticket = ticket :: (array ('position' => function ( $ Q) {return $ q-> where ('name', '! =', 'Off');}))) - & gt; get ();   

It will still return all the tickets but only the status relationship if the name is not closed.

In addition to this, I know that it can be done in a flute, but I would like to work with the returned structure of nested objects which provides elf:

  Echo ticket- & gt; Status- & gt; Name;   

Unstable gives a flat result, because there will be a join query.

It seems that this question is outdated, but if you are looking for real answers then We should do our best to avoid getting more inquiries from the database, the approved answer should be done twice, but you can get it from one shot ('position') - & gt; Where ('position', function ($ Q) {return $ q-> where ('name') like this

  $ ticket = ticket ::, '! =', ' Closed ');}) - & gt; get ();    

No comments:

Post a Comment