PHPackages                             ingress-it-solutions/laravel-calendar - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. ingress-it-solutions/laravel-calendar

ActivePackage[Utility &amp; Helpers](/categories/utility)

ingress-it-solutions/laravel-calendar
=====================================

Laravel helper for FullCalendar.io

v2.0(3y ago)010MITPHPPHP &gt;=7.2.5

Since Apr 6Pushed 3y agoCompare

[ Source](https://github.com/ingress-it-solutions/laravel-calendar)[ Packagist](https://packagist.org/packages/ingress-it-solutions/laravel-calendar)[ RSS](/packages/ingress-it-solutions-laravel-calendar/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)Dependencies (1)Versions (8)Used By (0)

Laravel 7 &amp; 8 Full Calendar 5 Helper
========================================

[](#laravel-7--8-full-calendar-5-helper)

This is a simple helper package to make generating  in Laravel apps easier.

Thanks to [@maddhatter](https://github.com/maddhatter) for the [initial repo](https://github.com/maddhatter/laravel-fullcalendar) for laravel &lt; 7

Thanks to [@acaronlex](https://github.com/acaronlex) for the [initial repo](https://github.com/acaronlex/laravel-fullcalendar) from laravel &lt; 8

Installing
----------

[](#installing)

Require the package with composer using the following command:

```
composer require ingress-it-solutions/laravel-calendar

```

The provider and `Calendar` alias will be registered automatically.

You will also need to include [fullcalendar.io](http://fullcalendar.io/)'s files in your HTML.

Usage
-----

[](#usage)

### Creating Events

[](#creating-events)

#### Using `event()`:

[](#using-event)

The simpliest way to create an event is to pass the event information to `Calendar::event()`:

```
$event = \Calendar::event(
  "Valentine's Day", //event title
  true, //full day event?
  '2015-02-14', //start time, must be a DateTime object or valid DateTime format (http://bit.ly/1z7QWbg)
  '2015-02-14', //end time, must be a DateTime object or valid DateTime format (http://bit.ly/1z7QWbg),
  1, //optional event ID
  [
    'url' => 'http://full-calendar.io',
  ]
);
```

#### Implementing `Event` Interface

[](#implementing-event-interface)

Alternatively, you can use an existing class and have it implement `IngressITSolutions\LaravelCalendar\Event`. An example of an Eloquent model that implements the `Event` interface:

```
class EventModel extends Eloquent implements
  \IngressITSolutions\LaravelCalendar\Event
{
  protected $dates = ['start', 'end'];

  /**
   * Get the event's id number
   *
   * @return int
   */
  public function getId()
  {
    return $this->id;
  }

  /**
   * Get the event's title
   *
   * @return string
   */
  public function getTitle()
  {
    return $this->title;
  }

  /**
   * Is it an all day event?
   *
   * @return bool
   */
  public function isAllDay()
  {
    return (bool) $this->all_day;
  }

  /**
   * Get the start time
   *
   * @return DateTime
   */
  public function getStart()
  {
    return $this->start;
  }

  /**
   * Get the end time
   *
   * @return DateTime
   */
  public function getEnd()
  {
    return $this->end;
  }
}
```

#### `IdentifiableEvent` Interface

[](#identifiableevent-interface)

If you wish for your existing class to have event IDs, implement `\IngressITSolutions\LaravelCalendar\IdentifiableEvent` instead. This interface extends `\IngressITSolutions\LaravelCalendar\Event` to add a `getId()` method:

```
class EventModel extends Eloquent implements \IngressITSolutions\LaravelCalendar\IdentifiableEvent
{

    // Implement all Event methods ...

    /**
     * Get the event's ID
     *
     * @return int|string|null
     */
    public function getId();

}
```

### Additional Event Parameters

[](#additional-event-parameters)

If you want to add [additional parameters](http://fullcalendar.io/docs/event_data/Event_Object) to your events, there are two options:

#### Using `Calendar::event()`

[](#using-calendarevent)

Pass an array of `'parameter' => 'value'` pairs as the 6th parameter to `Calendar::event()`:

```
$event = \Calendar::event(
  "Valentine's Day", //event title
  true, //full day event?
  '2015-02-14', //start time, must be a DateTime object or valid DateTime format (http://bit.ly/1z7QWbg)
  '2015-02-14', //end time, must be a DateTime object or valid DateTime format (http://bit.ly/1z7QWbg),
  1, //optional event ID
  [
    'url' => 'http://full-calendar.io',
    //any other full-calendar supported parameters
  ]
);
```

#### Add an `getEventOptions` method to your event class

[](#add-an-geteventoptions-method-to-your-event-class)

```
