php - Sort All Results In Laravel Model By Separate Model Entity -


i've found way sort laravel model seperate model's(also named model, in model of car) 'hits' using db::table function, want know how same results using eloquent only

ie (db::table way)

db::table('series') ->join('model','model.series_id','=','series.id') ->orderby('model.hits', 'asc') ->get(); 

this returns array of stdclass objects, want find way return array of model objects, again model referring model named model (sorry confusion).

ie (if found 1 model)

model::orderby('hits', 'asc')->get(); 

but want retrieve series. sorry i'm bit new , i'm not sure how explain better this. appreciated!!!

have tried using eager load constraints?

series::with(array('models' => function ($query) {     $query->orderby('hits'); }))->get(); 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -