vendredi 13 novembre 2020

Inner join query missing inside where closure

I am using Laravel 5.6

The following code

BusinessAgreement::where(function ($q) {
   $q->join('business_agreements as middleman', 'middleman.type_id', '=', 'business_agreements.type_id')
     ->join('business_agreement_users', 'business_agreement_users.business_agreement_id', '=', 'middleman.id')
     ->where('business_agreement_users.user_id', '=', $this->user->id);
})->toSql()

creates the following query:

select * from business_agreements where (business_agreement_users.user_id = ?) and business_agreements.deleted_at is null"

This causes my query to fail because table business_agreement_users is unknown.

Why is the inner join missing?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire