Model::updateOrCreateWithoutGlobalScopes feature request #56316
Unanswered
fcanacmarquis
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I use a global scope to automatically fetch a model with multiple join tables where all also have id column. So when ever I updateOrCreate, it triggers a 'id' is ambiguous error because you use find('id') instead of where('modelTableName.id',$id)->first().
So this is a custom solution I use, I think it could be added to the framework.
`
public static function updateOrCreateWithoutGlobalScopes(array $where, array $data)
{
$query = static::withoutGlobalScopes()->where($where);
$model = $query->first();
`
Thank you so much.
Beta Was this translation helpful? Give feedback.
All reactions