Closed iamike closed 7 years ago
Not yet, but soon: https://octobercms.com/support/article/rn-9
Should be fixed in Build 420+
However this is easy enough to do now with firstOrNew
$wechatPassport = WechatPassport::firstOrNew(['union_id' => $userInfo->unionId]);
$wechatPassport->fill([
'headimgurl' => $userInfo->avatarUrl,
'nickname' => $userInfo->nickName,
'province' => $userInfo->province,
'sex' => $userInfo->gender,
'country' => $userInfo->country,
])->save();
@daftspunk @iamike That method does exist in 5.1, I've used it myself. In fact, it's existed since at least 4.2. (https://github.com/laravel/framework/blob/4.2/src/Illuminate/Database/Eloquent/Model.php#L553) See https://stackoverflow.com/a/20764237/6652884. I believe this is probably some other issue that you are running into.
@LukeTowers You'll find updateOrCreate
doesn't exist. The above code using firstOrNew
is an exact replica of the functionality.
Expected behavior
When I using laravel updateOrCreate feature, which is really cool.
Actual behavior
It says error....I dont recognize this method....
Reproduce steps
check composer.json "require": { "php": ">=5.5.9", "october/rain": "~1.0", "october/system": "~1.0", "october/backend": "~1.0", "october/cms": "~1.0", *"laravel/framework": "5.1.",** "wikimedia/composer-merge-plugin": "dev-master" },
October build
(October build number)