Like previously mentioned we're currently building a new dashboard to display on our wall mounted TV at the office. One of the things we want to show on that dashboard are important events for our company. Things like when a site goes live, when there's a conference we're going to visit, when we're doing our monthly visit to our favourite Italian restaurant and so on. We manage these events on a Google Calendar. To make working with such a calendar real easy we've made a new package called laravel-google-calendar.
The steps required to install the package should be very familiar: pull it in via Composer, register a service provider / facade and finally publish a config file. After that you'll need to get some authentication credentials from Google. Normally this takes quite some time as the google docs are very confusing, but if you follow my previous blogpost on the subject you'll be set up in no time.
With the package fully installed you can do these things:
use Spatie\GoogleCalendar\Event; //create a new event $event = new Event; $event->name = 'A new event'; $event->startDateTime = Carbon\Carbon::now(); $event->endDateTime = Carbon\Carbon::now()->addHour(); $event->save(); //create a new full day event $event = new Event; $event->name = 'A new full day event'; $event->startDate = Carbon\Carbon::now(); $event->endDate = Carbon\Carbon::now()->addDay(); $event->save(); // create a new event with the static method Event::create([ 'name' => 'A new event', 'startDateTime' => Carbon\Carbon::now(), 'endDateTime' => Carbon\Carbon::now()->addHour(), ]); // get all future events on a calendar, returns a Collection $events = Event::get(); $firstEvent = $events->first(); // find a specific event and update item $event = Event::find($eventId) $event->name = 'My updated title' $event->save(); // delete an event $event->delete();
It's also possible to work with multiple calendars. The
find methods take a second parameter
The Google Calendar API provides many options. It's a big beast really. This package doesn't support all those options. For instance recurring events cannot be managed properly with our code. But if you stick to creating events with a name, a description and a date(time) you should be fine.
We hope you'll like our package. If you have any questions or remarks on it let me know in the comments below or the issue tracker on GitHub. We've made a bunch of other packages in the past. Check out this list on our site to find out if there's something else we've made that you can use on your next project.