php - How can I do subqueries in Laravel's fluent? -


say have bit of sql:

select *  `fluents` inner join `tests` on `fluents`.`id` = `tests`.`fluent_test_id` inner join (     select `fluents`.`id` `fluents` order `fluents`.`id` desc limit 10 ) j on `fluents`.`id` = `j`.`id` order `fluents`.`created_at`; 

i know run raw sql learning exercise i'm trying convert fluent , failing miserably, possible?

i have done way in project:

db::table('fluents')->join('tests','tests.fluent_test_id','=','fluents.id')                     ->join(db::raw("(select fluents.id fluents order `fluents`.`id` desc limit 10) j"),'j.id','=','fluents.id')                     ->orderby('fluents.created_at'); 

i hope can of help.


Comments