Фильтрация статуса = Нет в архиве
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Repositories;
|
||||
|
||||
use App\Models\SI\SttMedicalHistory as SiMedicalHistory;
|
||||
use App\Models\Mis\SttMedicalHistory as MisMedicalHistory;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@@ -221,12 +222,16 @@ class MedicalHistoryRepository
|
||||
});
|
||||
}
|
||||
|
||||
private function applyStatusFilter($query, ?int $value)
|
||||
private function applyStatusFilter(Builder $query, ?int $value)
|
||||
{
|
||||
if ($query->withExists('archiveInfo') && !empty($value)) {
|
||||
$query->withWhereHas('archiveInfo', function ($q) use ($value) {
|
||||
$q->where('status_id', '=', $value);
|
||||
});
|
||||
if ($value === 0) {
|
||||
$query->doesntHave('archiveInfo');
|
||||
} else {
|
||||
if ($query->withExists('archiveInfo') && !empty($value)) {
|
||||
$query->withWhereHas('archiveInfo', function ($q) use ($value) {
|
||||
$q->where('status_id', '=', $value);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user