Answers for "update or create eloquent"

PHP
5

update or create laravel

$user = User::updateOrCreate(['name' => request()->name], [ 
    'foo' => request()->foo
]);
Posted by: Guest on April-03-2020
6

laravel create or update

// If there's a flight from Oakland to San Diego, set the price to $99.
// If no matching model exists, create one.
$flight = App\Models\Flight::updateOrCreate(
    ['departure' => 'Oakland', 'destination' => 'San Diego'],
    ['price' => 99, 'discounted' => 1]
);
Posted by: Guest on September-27-2020
1

create or update laravel

DB::table('vendor_managements')->where('vendor_code', $vendor_code)->update(array('state'=> $state_namne));
Posted by: Guest on February-06-2021
-1

create new record via model in laravel

$userData = array('username' => 'Me', 'email' => '[email protected]');
User::create($userData);
Posted by: Guest on October-19-2020

Code answers related to "update or create eloquent"

Browse Popular Code Answers by Language