Laravel FullCalendar (Ajax) Example Tutorial

Laravel FullCalendar (Ajax) Example Tutorial

Laravel fullcalendar using ajax example tutorial. This tutorial demonstrates to you, how you can integrate a fullcalendar in your laravel application.

Here, you will learn step by step how you can easily use a fullcalendar with its events. In this example, We will implement add an event, update event and delete event on the fullcalendar using ajax.

Laravel 6 Fullcalendar Tutorial

Just follow the below steps and integrate full calendar in you laravel application:

  • Install Laravel Fresh App
  • Setup Database
  • Make Route
  • Create Controller & Methods
  • Create Blade View
  • Make Folder
  • Run Development Server
  • Conclusion

1). Install Laravel Fresh App

First, we need to download the laravel fresh setup. Use the below command and download fresh new laravel setup :

composer create-project --prefer-dist laravel/laravel blog

2). Setup Database

After successfully install laravel 6 Application, Go to your project .env file and set up database credential and move next step :

DB_DATABASE=here your database name here
DB_USERNAME=here database username here
DB_PASSWORD=here database password here

3). Generate Migration & Model

Now we will create a table name event and it’s migration file. use the below command :

php artisan make:model Event-m

It command will create one model name Event and also create one migration file for the Events table. After successfully run the command go to database/migrations file and put the below here :


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()

Next, migrate the table using the below command :

php artisan migrate

Make Route

We will create two routes in the web.php file. Go to app/routes/web.php file and create two routes so update your routes in web.php file:

Route::get('fullcalendar','[email protected]');
Route::post('fullcalendar/create','[email protected]');
Route::post('fullcalendar/update','[email protected]');
Route::post('fullcalendar/delete','[email protected]');

4). Create Controller

We need to create a controller name FullCalendarController. Use the below command and create Controller :

php artisan make:controller FullCalendarController

After successfully create controller go to app/controllers/FullCalendarController.php and update the below code :

The first method is index(), it will show you fullcalendar.

The second method is create(), it will store your events into the database.

The third method is update(), it will update your fullcalendar event into database.

The final method is destroy(), it will delete your events into the database and fullcalendar.

namespace App\Http\Controllers;
use App\Event;
use Illuminate\Http\Request;
use Redirect,Response;
class FullCalenderController extends Controller

    public function index()

         $start = (!empty($_GET["start"])) ? ($_GET["start"]) : ('');
         $end = (!empty($_GET["end"])) ? ($_GET["end"]) : ('');

         $data = Event::whereDate('start', '>=', $start)->whereDate('end',   '<=', $end)->get(['id','title','start', 'end']);
         return Response::json($data);
        return view('fullcalender');
    public function create(Request $request)
        $insertArr = [ 'title' => $request->title,
                       'start' => $request->start,
                       'end' => $request->end
        $event = Event::insert($insertArr);   
        return Response::json($event);

    public function update(Request $request)
        $where = array('id' => $request->id);
        $updateArr = ['title' => $request->title,'start' => $request->start, 'end' => $request->end];
        $event  = Event::where($where)->update($updateArr);

        return Response::json($event);

    public function destroy(Request $request)
        $event = Event::where('id',$request->id)->delete();
        return Response::json($event);


5). Create Blade view

In this step we need to create blade view file. Go to app/resources/views and create one file name fullcalendar.blade.php :

<!DOCTYPE html>
  <title>Laravel Fullcalender Add/Update/Delete Event Example Tutorial -</title>
  <meta name="csrf-token" content="{{ csrf_token() }}">
<link rel="stylesheet" href="" />
<script src=""></script>
<link rel="stylesheet" href="" />
<script src="" integrity="sha256-4iQZ6BVL4qNKlQ27TExEhBN1HFPvAvAMbFavKKosSWQ=" crossorigin="anonymous"></script>
<script src=""></script>

  <div class="container">
      <div class="response"></div>
      <div id='calendar'></div>  

Put the script on list.blade.php, after the closing of the body tag
  $(document).ready(function () {
        var SITEURL = "{{url('/')}}";
          headers: {
              'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')

        var calendar = $('#calendar').fullCalendar({
            editable: true,
            events: SITEURL + "fullcalendar",
            displayEventTime: true,
            editable: true,
            eventRender: function (event, element, view) {
                if (event.allDay === 'true') {
                    event.allDay = true;
                } else {
                    event.allDay = false;
            selectable: true,
            selectHelper: true,
            select: function (start, end, allDay) {
                var title = prompt('Event Title:');

                if (title) {
                    var start = $.fullCalendar.formatDate(start, "Y-MM-DD HH:mm:ss");
                    var end = $.fullCalendar.formatDate(end, "Y-MM-DD HH:mm:ss");

                        url: SITEURL + "fullcalendar/create",
                        data: 'title=' + title + '&amp;start=' + start + '&amp;end=' + end,
                        type: "POST",
                        success: function (data) {
                            displayMessage("Added Successfully");
                                title: title,
                                start: start,
                                end: end,
                                allDay: allDay
            eventDrop: function (event, delta) {
                        var start = $.fullCalendar.formatDate(event.start, "Y-MM-DD HH:mm:ss");
                        var end = $.fullCalendar.formatDate(event.end, "Y-MM-DD HH:mm:ss");
                            url: SITEURL + 'fullcalendar/update',
                            data: 'title=' + event.title + '&amp;start=' + start + '&amp;end=' + end + '&amp;id=' +,
                            type: "POST",
                            success: function (response) {
                                displayMessage("Updated Successfully");
            eventClick: function (event) {
                var deleteMsg = confirm("Do you really want to delete?");
                if (deleteMsg) {
                        type: "POST",
                        url: SITEURL + 'fullcalendar/delete',
                        data: "&amp;id=" +,
                        success: function (response) {
                            if(parseInt(response) > 0) {
                                displayMessage("Deleted Successfully");


  function displayMessage(message) {
    $(".response").html("<div class='success'>"+message+"</div>");
    setInterval(function() { $(".success").fadeOut(); }, 1000);

6). Run Development Server

We need to run the development server. Use the php artisan serve command and start your server :

 php artisan serve
If you want to run the project diffrent port so use this below command
php artisan serve --port=8080

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



In this tutorial, We have successfully integrated the fullcalendar in laravel application. Here you have learned how you can show, add, update and delete events on fullcalendar.

If you have any questions or thoughts to share, use the comment form below to reach us.

One reply to Laravel FullCalendar (Ajax) Example Tutorial

  1. To insert information in two tables at a time, how should I do it? For example: event and client tables

Leave a Reply

Your email address will not be published. Required fields are marked *