al-one / laravel-replace-into
SQL replace into for Laravel
Installs: 4 422
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 3
Forks: 1
Open Issues: 0
Requires
- php: >=5.6.4
- illuminate/contracts: ^5.3|^6.0|^7.0|^8.0|^9.0
This package is auto-updated.
Last update: 2024-11-17 09:08:26 UTC
README
Installing
# composer.json
"minimum-stability": "dev",
"prefer-stable": true,
$ composer require "al-one/laravel-replace-into" -vvv
Usage
# optional if >= 5.5 # config/app.php <?php return [ 'providers' => [ Alone\LaravelReplaceInto\ServiceProvider::class, ], ];
use Illuminate\Support\Facades\DB; DB::table('user_attrs')->replace( ['uid' => 10000,'type' => 'key','value' => 'val'], ['uid','type'] // uniqueKeys ); DB::table('user_attrs')->replace([ ['uid' => 10000,'type' => 'key1','value' => 'val1'], ['uid' => 10001,'type' => 'key2','value' => 'val2'], ],['uid','type']);
use Illuminate\Database\Eloquent\Model; class UserAttr extends Model { public function uniqueKeys() { return ['uid','type']; } } UserAttr::replace( ['uid' => 10000,'type' => 'key','value' => 'val'] ); UserAttr::replace([ ['uid' => 10000,'type' => 'key1','value' => 'val1'], ['uid' => 10001,'type' => 'key2','value' => 'val2'], ]);
License
MIT