scopeFilterCategories() public method

Allows filtering for specifc categories
public scopeFilterCategories ( Illuminate\Query\Builder $query, array $categories ) : Illuminate\Query\Builder
$query Illuminate\Query\Builder QueryBuilder
$categories array List of category ids
return Illuminate\Query\Builder QueryBuilder
Exemplo n.º 1
2
 public function onStart()
 {
     $slug = $this->param('slug');
     $this['category'] = Category::where('slug', '=', $slug)->first();
     if ($this['category']) {
         $post = new Post();
         $query = $post->isPublished()->orderBy('published_at', 'desc')->with('categories');
         $this['posts'] = $post->scopeFilterCategories($query, [$this['category']->id])->get();
     }
 }