awtor filter backend
This commit is contained in:
parent
5425010b38
commit
ec413ac734
|
|
@ -73,3 +73,17 @@ scopes:
|
||||||
ru: RU
|
ru: RU
|
||||||
en: EN
|
en: EN
|
||||||
tm: TM
|
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
|
||||||
|
|
|
||||||
|
|
@ -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)
|
public function scopeFilterId($query, $id)
|
||||||
{
|
{
|
||||||
return $query->where('id', $id);
|
return $query->where('id', $id);
|
||||||
|
|
|
||||||
|
|
@ -53,3 +53,9 @@ columns:
|
||||||
sortable: true
|
sortable: true
|
||||||
select: name
|
select: name
|
||||||
relation: category_groups
|
relation: category_groups
|
||||||
|
author_id:
|
||||||
|
label: Awtor
|
||||||
|
type: text
|
||||||
|
sortable: false
|
||||||
|
select: name
|
||||||
|
relation: awtor
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue