Skip to content

Instantly share code, notes, and snippets.

@saeedvir
Last active January 5, 2024 03:52
Show Gist options
  • Save saeedvir/4c61a61bdd77c6f99aa319f92c96f732 to your computer and use it in GitHub Desktop.
Save saeedvir/4c61a61bdd77c6f99aa319f92c96f732 to your computer and use it in GitHub Desktop.
Laravel UpdateOrCreateOrIncrement
<?php
YourModel::updateOrCreate(
[
'user_id' => '1',
'user_type' => 'admin'
],
[
'user_id' => '1',
'user_type' => 'admin',
'value' => DB::raw('value + 1'),
]
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment