public function scopePublishedAt(Builder $query, $year)
    {
        return $this->scopePublished($query)
                    ->where(DB::raw('YEAR(published_at)'), $year);
    }
public function scopePublishedAt(Builder $query, $year)
    {
        return $this->scopePublished($query)
                    ->where(DB::raw('YEAR(published_at)'), $year);
    }
public function scopePublishedAt ( Builder $ query , $ year ) { return $ this -> scopePublished ( $ query ) -> where ( DB :: raw ( 'YEAR(published_at)' ) , $ year ) ; }
Scope only published posts.

@param  \Illuminate\Database\Eloquent\Builder  $query
@param  int                                    $year

@return \Illuminate\Database\Eloquent\Builder
Scope only published posts .