Multiple modal used another controller get value from model

I have a two model

Job controller get the query
$jobcard = $this->Jobcard->get($jcid, [

        'contain' => []


$this->Jobcard->hasMany(‘Enquiry’, [

                'foreignKey' => 'id']);

$enquiry2 = $this->Jobcard->Enquiry->get($enqid, [

        'contain' => []


it’s working in Job controller. i want the same query run another controller that is passible?

Either use loadModel to add the model in question to what is directly available through $this, or use the TableRegistrty to get that model. Then run the query just as you have it.

Hi @Zuluru
i try TableRegistry::get(‘Jobcard’)->get($id) this one but i can get one model value. but i want to join another modal also. I bit confusion . Send the sample query get the two modal values

i try load modal also



           // $jobcard = $this->Jobcard->get($id, ['Enquiry'

            $enquiry2 = $this->Jobcard->Enquiry->get(350, [

                'contain' => []


i got the error like this
Undefined property Enquiry. You have not defined the Enquiry association on App\Model\Table\JobcardTable.

This call is in your Job controller, not in the JobcardTable initialization function? If so, that’s why the association isn’t available in the other place. Just like it says " You have not defined the Enquiry association".

Thank you @Zuluru. :grinning: :grinning: it works