awtor filter backend

This commit is contained in:
Kerim 2023-01-11 17:05:36 +05:00
parent 5425010b38
commit ec413ac734
3 changed files with 27 additions and 0 deletions

View File

@ -73,3 +73,17 @@ scopes:
ru: RU
en: EN
tm: TM
awtor:
# Filter name
label: Awtor
# Model Class name
modelClass: Tps\Tps\Models\Authors
# Model attribute to display for the name
nameFrom: name
# Apply query scope
scope: FilterAuthors

View File

@ -546,6 +546,13 @@ class Post extends Model
});
}
public function scopeFilterAuthors($query, $authors)
{
return $query->whereHas('awtor', function($q) use ($authors) {
$q->where('id', $authors);
});
}
public function scopeFilterId($query, $id)
{
return $query->where('id', $id);

View File

@ -53,3 +53,9 @@ columns:
sortable: true
select: name
relation: category_groups
author_id:
label: Awtor
type: text
sortable: false
select: name
relation: awtor