Learn How To Use Calendar in Laravel

laravel calendar logo

In our last Laravel tutorial we learnt about Models in Laravel, today in this Laravel tutorial we will learn how to use a calendar class in our application.

We can use a calendar into our application by just including some files in our application.
The calendar in Laravel 4 supports month, week and day views and multiple events per date.

Let us see how to install the calendar for use:
There are many calendar packages available which we can use to add calendar directly into our application. Among them we will go through the makzumi calendar.

Step1: To install the calendar add the following statement as “require” in composer.json:

"makzumi/calendar": "dev-master"

Step2: Now run the composer update and then after that add the following in app.php:

'providers' => array(

Step3: Now we can add several options to calendar and generate it as shown in the example below:

$events = array(
        "2014-04-09 10:30:00" => array(
            "Event 1",
            "Event 2 <strong> with html</stong>",
        "2014-04-12 14:12:23" => array(
            "Event 3",
        "2014-05-14 08:00:00" => array(
            "Event 4",

    $cal = Calendar::make();
    /**** OPTIONAL METHODS ****/
    $cal->setDate(Input::get('cdate')); //Set starting date
    $cal->setBasePath('/dashboard'); // Base path for navigation URLs
    $cal->showNav(true); // Show or hide navigation
    $cal->setView(Input::get('cv')); //'day' or 'week' or null
    $cal->setStartEndHours(8,20); // Set the hour range for day and week view
    $cal->setTimeClass('ctime'); //Class Name for times column on day and week views
    $cal->setEventsWrap(array('<p>', '</p>')); // Set the event's content wrapper
    $cal->setDayWrap(array('<div>','</div>')); //Set the day's number wrapper
    $cal->setNextIcon('>>'); //Can also be html: <i class='fa fa-chevron-right'></i>
    $cal->setPrevIcon('<<'); // Same as above
    $cal->setDayLabels(array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat')); //Label names for week days
    $cal->setMonthLabels(array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December')); //Month names
    $cal->setDateWrap(array('<div>','</div>')); //Set cell inner content wrapper
    $cal->setTableClass('table'); //Set the table's class name
    $cal->setHeadClass('table-header'); //Set top header's class name
    $cal->setNextClass('btn'); // Set next btn class name
    $cal->setPrevClass('btn'); // Set Prev btn class name
    $cal->setEvents($events); // Receives the events array
    /**** END OPTIONAL METHODS ****/

    echo $cal->generate() // Return the calendar's html;

Thus we studied how to use Calendar class in our application in this Calendar Class in Laravel Tutorial.


Please enter your comment!
Please enter your name here