php - how to perform this join in laravel -
i have table in database called jobcardops , model jobcardop.php. fields of table include opnum, jobcardnum, prevopnum, opstatus. row uniquely identified jobcardnum , opnum pair. now, considered having field called previousopstatus contains status of previous op, wondered whether join.
so clarify, when retrieve group of jobcardop models database want add field on end; 'previousopstatus'. know ill need like;
$ops = jobcardop::where('jobcardnum', '=', $somejobnum) ->join('jobcardops jobcardops_1, constraint) ->select('jobcardops.*', 'jobcardops_1.opstatus previousopstatus') ->get();
where jobcardops_1 somehow offset 1 if makes sense. can if can done?
thanks
Comments
Post a Comment