Issue
I have a null-able relation model, and I am using this standard code to retrieve my records:
$this->paginate = [
'contain' => ['Clients']
];
$coupons = $this->paginate($this->Coupons);
I am getting just the records that have client associated.
what is the best practice to make the contain work like OR
, and not AND
EDIT: the relationship is seted as the following:
$this->belongsTo('Clients', [
'foreignKey' => 'client_id',
'joinType' => 'INNER'
]);
Solution
I have solved it by setting the joinType
to LEFT
:
$this->belongsTo('Clients', [
'foreignKey' => 'client_id',
'joinType' => 'LEFT'
]);
Answered By - Eymen Elkum
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.