Corcel\PostBuilder::type PHP Method

type() public method

Get only posts from a custom post type
public type ( string $type ) : PostBuilder
$type string
return PostBuilder
    public function type($type)
    {
        return $this->where('post_type', $type);
    }

Usage Example

Example #1
0
 /**
  * Overriding newQuery() to the custom PostBuilder with some interesting methods
  *
  * @param bool $excludeDeleted
  * @return Corcel\PostBuilder
  */
 public function newQuery($excludeDeleted = true)
 {
     $builder = new PostBuilder($this->newBaseQueryBuilder());
     $builder->setModel($this)->with($this->with);
     $builder->orderBy('post_date', 'desc');
     if (isset($this->postType) and $this->postType) {
         $builder->type($this->postType);
     }
     if ($excludeDeleted and $this->softDelete) {
         $builder->whereNull($this->getQualifiedDeletedAtColumn());
     }
     return $builder;
 }
All Usage Examples Of Corcel\PostBuilder::type