From 8a7e53902e19bf604fe74d50a5ddc98d7df57643 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 31 Dec 2022 10:16:48 +0000 Subject: [PATCH] from server 31.12 --- plugins/rainlab/blog/controllers/posts/config_filter.yaml | 7 ++++++- plugins/rainlab/blog/models/Post.php | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/plugins/rainlab/blog/controllers/posts/config_filter.yaml b/plugins/rainlab/blog/controllers/posts/config_filter.yaml index 49e6e5612..fbded84a9 100644 --- a/plugins/rainlab/blog/controllers/posts/config_filter.yaml +++ b/plugins/rainlab/blog/controllers/posts/config_filter.yaml @@ -10,7 +10,12 @@ scopes: modelClass: RainLab\Blog\Models\Post scope: FilterId # conditions: id in (:filtered) - + title: + label: Post Title + type: text + modelClass: RainLab\Blog\Models\Post + scope: FilterId + category: # Filter name diff --git a/plugins/rainlab/blog/models/Post.php b/plugins/rainlab/blog/models/Post.php index 57b67c694..06df23469 100644 --- a/plugins/rainlab/blog/models/Post.php +++ b/plugins/rainlab/blog/models/Post.php @@ -536,6 +536,13 @@ class Post extends Model { return $query->where('id', $id); } + + public function scopeFilterName($query, $q) + { + + return $query = where('title','LIKE','%'.$q.'%') + ->orWhere('slug','LIKE','%'.$q.'%'); + } public function scopeFilterLocale($query, array $types) { foreach ($types as $type) {