Giter Club home page Giter Club logo

laracalendar's Introduction

Build Status License: MIT Latest Stable Version Total Downloads

Documentation is still in development.

Introduction

When building an calendar it can be troublesome when dealing with recurring events, this package is trying to solve this problem by making and easy to use builder syntax with easy extensibility.

Install it via composer

$ composer require uruloke/lara-calendar

Example

Let's say we wan't to create an event which repeats monday, tuesday, wednesday and thursday each week. 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 won't to blacklist from your event, this can be achieved with 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 sirivasv avatar

Watchers

James Cloos avatar Ben Chrisman 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.