Поиск, работа над query в js

This commit is contained in:
brusnitsyn
2025-12-01 17:38:11 +09:00
parent c9a392f84f
commit 063ddafdfb
8 changed files with 160 additions and 6 deletions

View File

@@ -32,4 +32,18 @@ class SttMedicalHistory extends Model
{
return $this->morphMany(ArchiveHistory::class, 'historyable');
}
public function scopeSearch($query, $searchText)
{
return $query->where(function($q) use ($searchText) {
if (is_numeric($searchText)) {
$q->where('nkarta', 'LIKE', "$searchText%");
} else {
// Ищем по всем частям ФИО
$q->where('fam', 'LIKE', "%$searchText%")
->orWhere('im', 'LIKE', "%$searchText%")
->orWhere('ot', 'LIKE', "%$searchText%");
}
});
}
}