vendredi 1 décembre 2017

How to get object of object within an object through laravel model

I am making Web App in laravel 5.2....I have patient data stored in patient table(Patient Table does not contain doctor and area of treatment data) in database and then i have billing table which contains the data of patient's billing.In Billing table i want to retrieve the data from two columns(doctor_id and area_of_treatment_id) like i retrieved billing by defining relation in Patient Model...

I have already retrieve the patients along with their billing but i also need the doctor and area of treatment tables data by using their id stored in billing table....I have defined the relation of billing in Patient Model..Please help me to resolve my problem

Billing relation in Patient Model:

public function billing()
    {
        return $this->belongsTo(Billing::class,'mr','mr');
    }

Patient Controller:

$patients = \App\Patient::with(['billing'])->get();

Patient Data along with billing:

enter image description here



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2zUJOuV
via IFTTT

Aucun commentaire:

Enregistrer un commentaire