Call to a member function increment() on null

try {
// we store registrations as subpages of the current pageincrement(string $field, int $by = 1, int $max = null)
$countries = $page->update([
**'daystoarrive'     => page($data['title'])->increment('daystoarrive', $by = $data['daystoarrive']),**
'orders' => page($data['title'])->increment('orders'),

I’m having an error with this, highlighted by ** ** the code works if the page title is a single word, for example; australia, however when the page title is more than one word, for example, united states, it’ll throw up this error.

Not sure why it won’t work on a page title of multiple words.

That doesn’t make sense, you can’t call the increment() method inside your update method. Increment first, then when that’s done, update the page with the values from those pages.

Also, do not call a class method without checking if an instance of the class exists, first.

if ($p = page($data['title'])) {
  // increment

I’ll retake a look at my code, however in it’s current condition the code does as I wanted it to.

Would a change in the code to your method fix the issue of it throwing up errors on multiple word titles?

'daystoarrive'     => ($p = page($data['title'])) ? $p->increment('daystoarrive', $by = $data['daystoarrive']) : '',

But to me that doesn’t make sense, the return value of $page->increment() is a page object, why do you want to store that in the daystoarrive field?