featured
This commit is contained in:
parent
9cdbc9cbc6
commit
2330cd1ae0
|
|
@ -88,7 +88,8 @@ class Posts extends ComponentBase
|
|||
'featured' => [
|
||||
'title' => 'Featured posts',
|
||||
'description' => 'Filter featured posts',
|
||||
'type' => 'checkbox',
|
||||
'type' => 'dropdown',
|
||||
'options' => ['yes' => 'Yes', 'not' => 'Not']
|
||||
|
||||
],
|
||||
'postsPerPage' => [
|
||||
|
|
@ -208,11 +209,13 @@ class Posts extends ComponentBase
|
|||
*/
|
||||
$isPublished = !$this->checkEditor();
|
||||
|
||||
$featured = $this->property('featured') ? $this->property('featured')=='yes':null;
|
||||
|
||||
$posts = BlogPost::with(['categories'])->listFrontEnd([
|
||||
'page' => $this->property('pageNumber'),
|
||||
'sort' => $this->property('sortOrder'),
|
||||
'perPage' => $this->property('postsPerPage'),
|
||||
'featured' => $this->property('featured'),
|
||||
'featured' => $featured,
|
||||
'search' => trim(input('q')),
|
||||
'category' => $category,
|
||||
'date' => input('date'),
|
||||
|
|
|
|||
|
|
@ -282,8 +282,8 @@ class Post extends Model
|
|||
$query->isPublished();
|
||||
}
|
||||
|
||||
if($featured){
|
||||
$query-> where('featured',1);
|
||||
if(isset($featured)){
|
||||
$query-> where('featured',$featured);
|
||||
}
|
||||
$date = trim($date);
|
||||
|
||||
|
|
@ -399,7 +399,7 @@ class Post extends Model
|
|||
$q->whereIn('id', $categories);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public function scopeFilterLocale($query, array $types) {
|
||||
foreach ($types as $type) {
|
||||
switch ($type) {
|
||||
|
|
@ -411,8 +411,8 @@ class Post extends Model
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
|||
Loading…
Reference in New Issue