public function generate($date = null)
    {
        $this->date = $date;

        if (is_null($date)) {
            $this->date = date('Y-m-d');
        }

        $dateAsArray = explode('-', $this->date);

        $today = Carbon::createFromDate($dateAsArray[0], $dateAsArray[1], $dateAsArray[2]);

        foreach (range(1, $today->daysInMonth) as $dayAsNumber) {
            $day = Carbon::createFromDate($today->year, $today->month, $dayAsNumber);

            if ($day->dayOfWeek === 0) {
                $dayOfTheWeek = 7;
            } else {
                $dayOfTheWeek = $day->dayOfWeek;
            }

            $this->weeks[$day->weekOfYear][$dayOfTheWeek] = $day;
        }

        return $this;
    }
public function generate($date = null)
    {
        $this->date = $date;

        if (is_null($date)) {
            $this->date = date('Y-m-d');
        }

        $dateAsArray = explode('-', $this->date);

        $today = Carbon::createFromDate($dateAsArray[0], $dateAsArray[1], $dateAsArray[2]);

        foreach (range(1, $today->daysInMonth) as $dayAsNumber) {
            $day = Carbon::createFromDate($today->year, $today->month, $dayAsNumber);

            if ($day->dayOfWeek === 0) {
                $dayOfTheWeek = 7;
            } else {
                $dayOfTheWeek = $day->dayOfWeek;
            }

            $this->weeks[$day->weekOfYear][$dayOfTheWeek] = $day;
        }

        return $this;
    }
public function generate ( $ date = null ) { $ this -> date = $ date ; if ( is_null ( $ date ) ) { $ this -> date = date ( 'Y-m-d' ) ; } $ dateAsArray = explode ( '-' , $ this -> date ) ; $ today = Carbon :: createFromDate ( $ dateAsArray [ 0 ] , $ dateAsArray [ 1 ] , $ dateAsArray [ 2 ] ) ; foreach ( range ( 1 , $ today -> daysInMonth ) as $ dayAsNumber ) { $ day = Carbon :: createFromDate ( $ today -> year , $ today -> month , $ dayAsNumber ) ; if ( $ day -> dayOfWeek === 0 ) { $ dayOfTheWeek = 7 ; } else { $ dayOfTheWeek = $ day -> dayOfWeek ; } $ this -> weeks [ $ day -> weekOfYear ] [ $ dayOfTheWeek ] = $ day ; } return $ this ; }
Generate a calendar

@param  string $date

@return Grafite\Cms\Services\EventService
Generate a calendar