Closed mattpramschufer closed 4 years ago
Currently I have an Organization model with the following relationship
public function cases() { return $this->hasManyDeep('App\Models\CourtCase', ['App\Models\Property', 'App\Models\Lease']); }
The model App\Models\CourtCase has a field called archive which is boolean. I wanted to create a new relationship like
App\Models\CourtCase
archive
public function archivedCases() { return $this->hasManyDeep('App\Models\CourtCase', ['App\Models\Property', 'App\Models\Lease'])->where('archive', '=', 1); }
But that doesn't actually work. Is there another method I can try or am I doing something incorrectly?
Thanks in advance.
Nevermind, I figured it out. I had a global scope present, I needed to then do
public function archivedCases() { return $this->cases()->withoutGlobalScopes()->where('archive', '=', 1)->get(); }
Currently I have an Organization model with the following relationship
public function cases() { return $this->hasManyDeep('App\Models\CourtCase', ['App\Models\Property', 'App\Models\Lease']); }
The model
App\Models\CourtCase
has a field calledarchive
which is boolean. I wanted to create a new relationship likepublic function archivedCases() { return $this->hasManyDeep('App\Models\CourtCase', ['App\Models\Property', 'App\Models\Lease'])->where('archive', '=', 1); }
But that doesn't actually work. Is there another method I can try or am I doing something incorrectly?
Thanks in advance.