In my laravel
-application I want to include my google-calendar
by using the Cronofy API and the package from cronofy-php.
Now when I try to update an event, the event gets duplicated and I don't really know why:
Here is my code:
public function updateEvent(){
$cronofy = new Cronofy\Cronofy([
"client_id" => config('cronofy.client_id'),
"client_secret" => config('cronofy.client_secret'),
"access_token" => $access_token->value,
"refresh_token" => $refresh_token->value
]);
$new_start_date = date("Y-m-d\TH:m:s\Z", strtotime(request()->event['changes']['start']['_date']));
$new_end_date = date("Y-m-d\TH:m:s\Z", strtotime(request()->event['changes']['end']['_date']));
$params = [
'calendar_id' => (string)request()->event['schedule']['calendarId'],
'event_id' => (string)request()->event['schedule']['id'],
'summary' => request()->event['schedule']['title'],
'description' => request()->event['schedule']['body'],
'start' => (object)['time' => $new_start_date, 'tzid' => 'Etc/UTC'],
'end' => (object)['time' => $new_end_date, 'tzid' => 'Etc/UTC'],
];
$updated_event = $cronofy->upsertEvent($params);
return response(['success' => true, 'event' => $params]);
}
As mentioned above, this creates a duplicate of the event, which I intentionally want to update/edit.
Can someone help me out?