Laravel full calendar tutorial example using maddhatter/laravel-fullcalendar

  668821 views   5 years ago Laravel jQuery

In this post we are share with you how to implement full calendar (JavaScript Event Calendar) in laravel application. using full calendar we will represent our daily tasks, events and schedule one daly basis and also start date to end date. in this post we are create basic example for full calendar with dummy data but you can implement it with your dynamic data. we are also show this how to handle dynamic data in it.

After completed this tutorials your output look like this.



Step - 1 : Installation Package

We are use here maddhatter/laravel-fullcalendar laravel package for integrate full calendar in our laravel application. simple run following command and install this package.

composer require maddhatter/laravel-fullcalendar

Step - 2 : Configure Pacckage

After install successfully maddhatter/laravel-fullcalendar package in our application we need to set their Service Provider. so, open your config/app.php file and add following provider in it.

'providers' => [
'aliases' => [
	'Calendar' => MaddHatter\LaravelFullcalendar\Facades\Calendar::class,

Step - 3 : Create Event Table Migration

Now create event table migration run by following command.

php artisan make:migration create_events_table

After run this command you can see one migration file automatic create in database/migrations folder. open it and copy past following code in it.

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateEventsTable extends Migration
     * Run the migrations.
     * @return void
    public function up()
        Schema::create('events', function (Blueprint $table) {
     * Reverse the migrations.
     * @return void
    public function down()

Now run your migration using following command.

php artisan migrate

Step - 4 : Create Event Model

Now create events table model run by this command.

php artisan make:model Event

After run this command open app/Event.php file and put following code in it

namespace App;
use Illuminate\Database\Eloquent\Model;

class Event extends Model
    protected $fillable = ['title','start_date','end_date'];

Step - 5 : Create Events Table Seeder

Now we are need some dummy data in events table. so, we are insert dummy data created by seeder. run following command create seed file.

php artisan make:seeder AddDummyEvent

After run this command open database/seeds/AddDummyEvent.php file and put following code in it.

use Illuminate\Database\Seeder;
use App\Event;

class AddDummyEvent extends Seeder
    public function run()
        $data = [
        	['title'=>'Demo Event-1', 'start_date'=>'2017-09-11', 'end_date'=>'2017-09-12'],
        	['title'=>'Demo Event-2', 'start_date'=>'2017-09-11', 'end_date'=>'2017-09-13'],
        	['title'=>'Demo Event-3', 'start_date'=>'2017-09-14', 'end_date'=>'2017-09-14'],
        	['title'=>'Demo Event-3', 'start_date'=>'2017-09-17', 'end_date'=>'2017-09-17'],
        foreach ($data as $key => $value) {

Now run this seed by following command.

php artisan db:seed --class=AddDummyEvent
Step - 6 : Create Route

Nex, create following route by display all events in full caleendar. open your routes/web.php file and create following route.

Route::get('events', '[email protected]');

Step - 7 : Create Controller

Now create EventController.php file in app/Http/Controllers/ folder.

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Calendar;
use App\Event;

class EventController extends Controller
    public function index()
        $events = [];
        $data = Event::all();
        if($data->count()) {
            foreach ($data as $key => $value) {
                $events[] = Calendar::event(
                    new \DateTime($value->start_date),
                    new \DateTime($value->end_date.' +1 day'),
                    // Add color and link on event
	                    'color' => '#f05050',
	                    'url' => 'pass here url and any route',
        $calendar = Calendar::addEvents($events);
        return view('fullcalender', compact('calendar'));

Step - 8 : Create Blade File

Next, create fullcalender.blade.php file in resources/views folders and put into it folloawing content.


<link rel="stylesheet" type="text/css" href="">
<link rel="stylesheet" href=""/>

<div class="container">
    <div class="row">
        <div class="col-md-8 col-md-offset-2">
            <div class="panel panel-default">
                <div class="panel-heading">Full Calendar Example</div>

                <div class="panel-body">
                    {!! $calendar->calendar() !!}

<script src=""></script>
<script src=""></script>
{!! $calendar->script() !!}

Now we are ready to run our example so run bellow command ro quick run:

php artisan serve

Now you can open bellow URL on your browser:


If you face any problem then please write a comment or give some suggestions for improvement. Thanks...

Author : Harsukh Makwana
Harsukh Makwana

Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]