/** * Get posts with a status of 'published' * @param $query * @return mixed */ public function scopePublished($query) { $status = Status::getStatusByName('published'); return $query->where('status_id', $status->id); }