Giter Club home page Giter Club logo

laracalendar's Introduction

Build Status License: MIT Latest Stable Version Total Downloads codecov StyleCI

Documentation is still in development.

Introduction

Building a calendar can be troublesome, especially when you deal with recurring events. This package tries to solve this problem by making an easy to use event builder with extensibility.

The package is made for Laravel and uses Laravel Collections extensively.

For installing the package, just run and you are good to go.

$ composer require uruloke/lara-calendar

The service providers is autoloaded, so enjoy!

Example

Let's say we want to create an event which repeats every Monday, Tuesday, Wednesday and Thursday. We can generate this simply by doing the following:

$builder = new EventBuilder();
$builder->startsAt(Carbon::parse("2017-09-05 08:00"));
$builder->endsAt(Carbon::parse("2017-09-05 18:00"));
$builder->weekly([Monday::class, Tuesday::class, Wednesday::class, Thursday::class]);

// Dump the results
$builder->getNextEvents(3)

The dumped data for the next 3 events would then be:

Uruloke\LaraCalendar\EventCollection {#221
  #items: array:3 [
    0 => Uruloke\LaraCalendar\Models\Event {#225
      #start: Uruloke\LaraCalendar\Carbon {#230
        +"date": "2017-09-05 08:00:00.000000"
        +"timezone_type": 3
        +"timezone": "UTC"
      }
      #ends: Uruloke\LaraCalendar\Carbon {#231
        +"date": "2017-09-05 18:00:00.000000"
        +"timezone_type": 3
        +"timezone": "UTC"
      }
    }
    1 => Uruloke\LaraCalendar\Models\Event {#232
      #start: Uruloke\LaraCalendar\Carbon {#233
        +"date": "2017-09-06 08:00:00.000000"
        +"timezone_type": 3
        +"timezone": "UTC"
      }
      #ends: Uruloke\LaraCalendar\Carbon {#234
        +"date": "2017-09-06 18:00:00.000000"
        +"timezone_type": 3
        +"timezone": "UTC"
      }
    }
    2 => Uruloke\LaraCalendar\Models\Event {#235
      #start: Uruloke\LaraCalendar\Carbon {#236
        +"date": "2017-09-07 08:00:00.000000"
        +"timezone_type": 3
        +"timezone": "UTC"
      }
      #ends: Uruloke\LaraCalendar\Carbon {#237
        +"date": "2017-09-07 18:00:00.000000"
        +"timezone_type": 3
        +"timezone": "UTC"
      }
    }
  ]
}

Recurrences

Weekly

BiWeekly

EvenWeeks

UnevenWeeks

Filters

Filter days out

There might be a specific day which you want to blacklist from your event. This can be achieved by using the withoutDay method. Just parse in a day and it will ignore that specific day.

$builder = new EventBuilder();
$builder->startsAt(Carbon::parse("2017-09-05 08:00"));
$builder->endsAt(Carbon::parse("2017-09-05 18:00"));
$builder->allWeekDays();
$builder->withoutDay(Carbon::parse("2017-09-07"));

laracalendar's People

Contributors

olivernybroe avatar lexf avatar fragkp avatar twodcube avatar sirivasv avatar chefe avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.