I've already looked at the following, but haven't been able to solve my problem: - "Indirect modification of overloaded element of SplFixedArray has no effect"
I'm using Laravel 4 with Eloquent. To access a user in the database, I create the following query.
$user = User::find(Auth::id())->first();
The $user object is represented as the following.
{
"_id": {
"$id": "56b50fe08525cd0d3e9d8dc4"
},
...
"splits": {
"owned": [],
...
},
...
}
I'm currently trying to append a string to the splits->owned array, but I'm having the error "Indirect modification of overloaded property User::$splits has no effect". The error is raised on the third line below.
private function generateUserSplits($split) {
$user = User::find(Auth::id());
array_push($user->$splits->$owned, $split->id);
$user->save();
}
$split->id contains a string of characters similar to "56b50fe08525cd0d3e9d8dc4". I've already had a browse around stack overflow for similar answers, and as of yet have had no success.
If anyone could provide some help, it would be greatly appreciated. Thanks