0

How can I edit or delete data in google calendar event description?

I'm using Laravel with Google Calendar (i.e., a spatie package). When I update an event description, it overwrites the entire content, but I only need to change a part of the data.

I currently get the data from a form and add it to a variable like this:

$variable = [
"Name: " . $name . "<br/>" .
"Product: " . $product . "<br/>
];

$event->description = $variable;
$event->save();

After I save it in the Google Calendar, I would like to change only "Name", for example, is it possible?

Mihai
  • 2,807
  • 4
  • 28
  • 53
  • Can you share proper code? If you concatenate some big string, how do you want to change data within? – Nico Haase Feb 06 '19 at 16:38
  • thanks for reply. the google calendar $event->description, only accepts strings.I need to change some data from this string after it was written to the calendar and I was not finding a "smart" solution. – Renato Nascimento Feb 07 '19 at 16:00

1 Answers1

0

If I understand correctly, all you are doing is saving a string. If that is indeed the case, a possiblity would be that:

  • next time when you retrieve the string to parse it and use Name: and <br\> as delimiters
  • then you can perform a substring replacement for the string in between your delimiters

This post shows you an implementation for how to achieve this using php. Also, take a look at str_replace, but keep in mind that it replaces all occurrences.

Mihai
  • 2,807
  • 4
  • 28
  • 53