PHP code example of rob-lester-jr04 / laravel-google-calendar

1. Go to this page and download the library: Download rob-lester-jr04/laravel-google-calendar library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rob-lester-jr04 / laravel-google-calendar example snippets


use Lester\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->addAttendee(['email' => '[email protected]']);
$event->addAttendee(['email' => '[email protected]']);

$event->save();

// get all future events on a calendar
$events = Event::get();

// update existing event
$firstEvent = $events->first();
$firstEvent->name = 'updated name';
$firstEvent->save();

$firstEvent->update(['name' => 'updated again']);

// create a new event
Event::create([
   'name' => 'A new event',
   'startDateTime' => Carbon\Carbon::now(),
   'endDateTime' => Carbon\Carbon::now()->addHour(),
]);

// delete an event
$event->delete();

'providers' => [
    ...
    Lester\GoogleCalendar\GoogleCalendarServiceProvider::class,
];

'aliases' => [
	...
    'GoogleCalendar' => Lester\GoogleCalendar\GoogleCalendarFacade::class,
    ...
]

public static function get(Carbon $startDateTime = null, Carbon $endDateTime = null, array $queryParameters = [], string $calendarId = null): Collection

$events = Event::get();

$events[0]->startDate;
$events[0]->startDateTime;
$events[0]->endDate;
$events[0]->endDateTime;

$event = new Event;

$event->name = 'A new event';
$event->startDateTime = Carbon\Carbon::now();
$event->endDateTime = Carbon\Carbon::now()->addHour();

$event->save();

Event::create([
   'name' => 'A new event',
   'startDateTime' => Carbon\Carbon::now(),
   'endDateTime' => Carbon\Carbon::now()->addHour(),
]);

$event = new Event;

$event->name = 'A new full day event';
$event->startDate = Carbon\Carbon::now();
$event->endDate = Carbon\Carbon::now()->addDay();

$event->save();

// get the id of the first upcoming event in the calendar.
$eventId = Event::get()->first()->id;

Event::find($eventId);

$event = Event::find($eventId);

$event->name = 'My updated title';
$event->save();

$event = Event::find($eventId)

$event->update(['name' => 'My updated title']);

$event = Event::find($eventId);

$event->delete();
bash
php artisan vendor:publish --provider="Lester\GoogleCalendar\GoogleCalendarServiceProvider"