public function asHtml($config)
    {
        $class = $config['class'];
        $dates = $config['dates'];

        $daysOfTheWeek = [
            'Monday',
            'Tuesday',
            'Wednesday',
            'Thursday',
            'Friday',
            'Saturday',
            'Sunday',
        ];

        $output = '<table class="'.$class.'">';
        $output .= '<thead>';
        foreach ($daysOfTheWeek as $day) {
            $output .= '<th>'.$day.'</th>';
        }
        $output .= '</thead>';

        foreach ($this->weeks as $week) {
            $output .= '<tr>';
            foreach (range(1, 7) as $dayAsNumber) {
                if (isset($week[$dayAsNumber])) {
                    $content = '';
                    if (isset($dates[$week[$dayAsNumber]->toDateString()])) {
                        $content = $dates[$week[$dayAsNumber]->toDateString()];
                    }

                    if (is_array($content)) {
                        $itemString = '';
                        foreach ($content as $item) {
                            if (config('app.locale') !== config('cms.default-language')) {
                                if ($item->translationData(config('app.locale'))) {
                                    $itemString .= '<a href="'.url('events/event/'.$item->id).'">'.$item->translationData(config('app.locale'))->title.'</a><br>';
                                }
                            } else {
                                $itemString .= '<a href="'.url('events/event/'.$item->id).'">'.$item->title.'</a><br>';
                            }
                        }
                        $content = $itemString;
                    }

                    $output .= '<td><span class="date"><a href="'.url('events/date/'.$week[$dayAsNumber]->format('Y-m-d')).'">'.$week[$dayAsNumber]->toFormattedDateString().'</a></span><span class="content">'.$content.'</span></td>';
                } else {
                    $output .= '<td>&nbsp;</td>';
                }
            }
            $output .= '</tr>';
        }
        $output .= '</table>';

        return $output;
    }
public function asHtml($config)
    {
        $class = $config['class'];
        $dates = $config['dates'];

        $daysOfTheWeek = [
            'Monday',
            'Tuesday',
            'Wednesday',
            'Thursday',
            'Friday',
            'Saturday',
            'Sunday',
        ];

        $output = '<table class="'.$class.'">';
        $output .= '<thead>';
        foreach ($daysOfTheWeek as $day) {
            $output .= '<th>'.$day.'</th>';
        }
        $output .= '</thead>';

        foreach ($this->weeks as $week) {
            $output .= '<tr>';
            foreach (range(1, 7) as $dayAsNumber) {
                if (isset($week[$dayAsNumber])) {
                    $content = '';
                    if (isset($dates[$week[$dayAsNumber]->toDateString()])) {
                        $content = $dates[$week[$dayAsNumber]->toDateString()];
                    }

                    if (is_array($content)) {
                        $itemString = '';
                        foreach ($content as $item) {
                            if (config('app.locale') !== config('cms.default-language')) {
                                if ($item->translationData(config('app.locale'))) {
                                    $itemString .= '<a href="'.url('events/event/'.$item->id).'">'.$item->translationData(config('app.locale'))->title.'</a><br>';
                                }
                            } else {
                                $itemString .= '<a href="'.url('events/event/'.$item->id).'">'.$item->title.'</a><br>';
                            }
                        }
                        $content = $itemString;
                    }

                    $output .= '<td><span class="date"><a href="'.url('events/date/'.$week[$dayAsNumber]->format('Y-m-d')).'">'.$week[$dayAsNumber]->toFormattedDateString().'</a></span><span class="content">'.$content.'</span></td>';
                } else {
                    $output .= '<td>&nbsp;</td>';
                }
            }
            $output .= '</tr>';
        }
        $output .= '</table>';

        return $output;
    }
public function asHtml ( $ config ) { $ class = $ config [ 'class' ] ; $ dates = $ config [ 'dates' ] ; $ daysOfTheWeek = [ 'Monday' , 'Tuesday' , 'Wednesday' , 'Thursday' , 'Friday' , 'Saturday' , 'Sunday' , ] ; $ output = '<table class="' . $ class . '">' ; $ output .= '<thead>' ; foreach ( $ daysOfTheWeek as $ day ) { $ output .= '<th>' . $ day . '</th>' ; } $ output .= '</thead>' ; foreach ( $ this -> weeks as $ week ) { $ output .= '<tr>' ; foreach ( range ( 1 , 7 ) as $ dayAsNumber ) { if ( isset ( $ week [ $ dayAsNumber ] ) ) { $ content = '' ; if ( isset ( $ dates [ $ week [ $ dayAsNumber ] -> toDateString ( ) ] ) ) { $ content = $ dates [ $ week [ $ dayAsNumber ] -> toDateString ( ) ] ; } if ( is_array ( $ content ) ) { $ itemString = '' ; foreach ( $ content as $ item ) { if ( config ( 'app.locale' ) !== config ( 'cms.default-language' ) ) { if ( $ item -> translationData ( config ( 'app.locale' ) ) ) { $ itemString .= '<a href="' . url ( 'events/event/' . $ item -> id ) . '">' . $ item -> translationData ( config ( 'app.locale' ) ) -> title . '</a><br>' ; } } else { $ itemString .= '<a href="' . url ( 'events/event/' . $ item -> id ) . '">' . $ item -> title . '</a><br>' ; } } $ content = $ itemString ; } $ output .= '<td><span class="date"><a href="' . url ( 'events/date/' . $ week [ $ dayAsNumber ] -> format ( 'Y-m-d' ) ) . '">' . $ week [ $ dayAsNumber ] -> toFormattedDateString ( ) . '</a></span><span class="content">' . $ content . '</span></td>' ; } else { $ output .= '<td>&nbsp;</td>' ; } } $ output .= '</tr>' ; } $ output .= '</table>' ; return $ output ; }
Get a calendar as html

@param  array $config

@return string
Get a calendar as html