Laravel / Model / Get latest record using model relation
Get Latest Record using relationship
-
STEP
public function currentJob() { return $this->hasOne(Ejob::class, ...)->latest(); } Sort option
$users = User::all()->with('currentJob')->get()->sortBy('currentJob.id', 'DESC');