79277909

Date: 2024-12-13 10:14:06
Score: 1
Natty:
Report link

Adding onto Erich's answer, Laravel does have a method for non-recursively getting the relations as an array: getRelations().

This means you can do the following to get the whole model as an array without affecting its relations:

array_merge($account->getAttributes(), $account->getRelations());
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Reimar