From ba95ff711cf24ccaddb2c917c3af07d5c10d07f0 Mon Sep 17 00:00:00 2001 From: Jordan Doyle Date: Mon, 3 Oct 2016 13:10:00 +0100 Subject: [PATCH] Eloquent methods for getting posts by type --- src/Models/Post.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/Models/Post.php b/src/Models/Post.php index a1ac8f9..c33ecc2 100644 --- a/src/Models/Post.php +++ b/src/Models/Post.php @@ -1,6 +1,7 @@ where('post_type', $name); + } + + /** + * Get all the posts which are published. + * + * @param Builder $query query to add the scope to + * @return Builder + */ + public function scopePublished($query) + { + return $query->where('post_status', 'publish'); + } + + /** * Get all the meta values that belong to this post. * * @return HasMany -- libgit2 1.7.2