Friday, March 10, 2017

Mad hatter full calendar color events Laravel 5.4

Hi i got some problem with change event color when i set title like 'Wydzial 1' etc. I know i must fetch title from db next use if to check title but next i dont know what to do. I must do somethink like that: I create event with title 'Wydzial 1' and get event with color:red, Next i want make event with title 'Wydzial 2' with blue color. Somethink like that. Now its working all adding event with time and other but i dont know how make diffrents color for event.

Controller:

$titles = HomeModel::where('title')->get();
        
           
        
            if($titles == "Wydzial 1")
            {
                $color = '#378006'; 
            }
            elseif($titles == "Wydzial 2") 
            {
                $color = '#ff0000';
            }
            elseif($titles == "Wydzial 3") 
            {
                $color = '#73e600';
            }
            else 
            {
                $color = '#0066ff';
            }
        

        $calendar = \Calendar::addEvents($events,array('color'=> $color))
            ->setOptions([
                'FirstDay' => 1,
                'contentheight' => 650,
                'editable' => false,
                'allDay' => false,
                'aspectRatio' => 2,
                'slotLabelFormat' => 'HH:mm:ss',
                'timeFormat' => 'HH:mm',
                             
                ])->setCallbacks([]);

        return view('home', compact('calendar'));


via Mariusz

Advertisement