public function apply(Builder $builder, Model $model)
 {
     $builder->published();
     $this->addWithDrafts($builder);
     $this->addOnlyDrafts($builder);
     $this->addOnlyRegistered($builder);
 }
Exemple #2
0
 /**
  * Get $count most recent articles.
  *
  * @param Builder $query
  * @param int     $count
  * @return Builder $query
  */
 public function scopeRecent(Builder $query, $count)
 {
     return $query->published()->orderBy('published_at', 'DESC')->take($count);
 }
 public function publishedByIdOrAliasAndPid(Builder $query, $idOrAlias, $pid)
 {
     return $query->published()->idOrAlias($idOrAlias)->pid($pid);
 }
 /**
  * get has a minimum one published child element of category
  *
  * @param \Illuminate\Database\Eloquent\Builder $query
  * @param string $relation
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public function scopeHasPublishedElement($query, $relation)
 {
     return $query->has($relation, '>=', 1, 'and', function ($query) {
         return $query->published();
     });
 }