Created
March 6, 2020 08:20
-
-
Save me7media/1a7bc6fc5f8e9ac79c78e00980c3d207 to your computer and use it in GitHub Desktop.
Laravel WhereNotIn takes null. WhereIn with NULL.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Client model | |
private $notSaleSections = ['ТПМ-УПП', 'ТПМ-МДФ']; | |
public function saleParams() | |
{ | |
return $this->hasMany(ClientParameter::class, 'customer', 'id') | |
->whereHas('param', function ($q) { | |
$q->where('section', null); | |
foreach ($this->notSaleSections as $s){ | |
$q->orWhere('section', '!=', $s); | |
} | |
}); | |
} | |
//ClientParameter model relation to self? you can use other relation | |
public function param(){ | |
return $this->hasOne($this, 'id', 'id'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment