public function scopeDate($query, $year = '', $month ='', $day ='')
    {
        if($year) {
            $query->whereMonth($this->getTable().'.created_at', $year);
        }

        if($month) {
            $query->whereYear($this->getTable().'.created_at', $month);
        }

        if($day) {
            $query->whereDay($this->getTable().'.created_at', $day);
        }
        return $query;
    }
public function scopeDate($query, $year = '', $month ='', $day ='')
    {
        if($year) {
            $query->whereMonth($this->getTable().'.created_at', $year);
        }

        if($month) {
            $query->whereYear($this->getTable().'.created_at', $month);
        }

        if($day) {
            $query->whereDay($this->getTable().'.created_at', $day);
        }
        return $query;
    }
public function scopeDate ( $ query , $ year = '' , $ month = '' , $ day = '' ) { if ( $ year ) { $ query -> whereMonth ( $ this -> getTable ( ) . '.created_at' , $ year ) ; } if ( $ month ) { $ query -> whereYear ( $ this -> getTable ( ) . '.created_at' , $ month ) ; } if ( $ day ) { $ query -> whereDay ( $ this -> getTable ( ) . '.created_at' , $ day ) ; } return $ query ; }
Scope a query to include posts by a specific date.

@param Builder $query
@param string  $year
@param string  $month
@param string  $day

@return mixed
Scope a query to include posts by a specific date .