K
K
Konstantin Malyarov2017-10-04 08:58:52
Laravel
Konstantin Malyarov, 2017-10-04 08:58:52

How will the third model be received?

There is a consultation model that pulls the patient model along with it. And now how to make the patient model pull the passport?
Now I have $consultation->patient->surname
And I want %consultation->patient->passport->surname

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
Boris Korobkov, 2017-10-04
@BorisKorobkov

And now how to make the patient model pull a passport?

Same as...
consultation model that pulls the patient model along with it

A
anlamas, 2017-10-08
@anlamas

// контроллер
$consultations = Consultation::with('patient.passports')->get()

// blade

@foreach($consultations as $consultation)
    {{ $consultation->created_at }}
    {{ $consultation->patient->created_at}}
    @foreach($consultation->patient->passports as $client_passport)
        {{ $client_passport->surname }}
    @endforeach
@endforeach

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question