开发者

Laravel Eloquent model works like referencing when assigning to another variable

I am doing this in laravel and getting unexpected result


$remitter = Remitter::where('mobile', '9946617986')->first();

$new = $remitter;
$new->rohan = 'Rohan';

unset($remitter->rohan);
dd($new);

here I just grabbed one eloquent object $remitter and then I pushed it in another variable $new Now when I created one tag named "rohan" on new it gets added into $remit开发者_JS百科ter too

now when I unset $remitter->rohan

rohan tag was also removed from $new too why this is happening ?

why this is working like referencing ?

any Ideas


$new = collect($remitter->toArray());
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜