Created
May 16, 2020 00:28
-
-
Save inxilpro/629ed61eb941ef36bc9e911db6e433f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class User extends Model | |
{ | |
public function avatar() | |
{ | |
return $this->belongsTo(Avatar::class); | |
} | |
} | |
class Avatar extends Model | |
{ | |
public function uploader() | |
{ | |
return $this->bellongsTo(User::class); | |
} | |
} | |
$user = new User(); | |
$avatar = new Avatar(); | |
$avatar->uploader()->associate($user); | |
$user->avatar()->associate($avatar); | |
$user->toArray(); // Maximum function nesting level of '256' reached | |
$user->getQueueableRelations(); // Maximum function nesting level of '256' reached | |
$user->toSearchableArray(); // Maximum function nesting level of '256' reached |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So, as noted on Twitter, I wonder if you can solve this by simply breaking the variable reference in PHP. Something like this:
Calling
withoutRelations()
will clone the model and unset all the relationships.