Answers for "laravel create data"

PHP
1

how to insert multiple data at a time with create method in laravel

$data = [
    ['user_id'=>'Coder 1', 'subject_id'=> 4096],
    ['user_id'=>'Coder 2', 'subject_id'=> 2048],
    //...
];

Model::insert($data); // Eloquent approach
DB::table('table')->insert($data); // Query Builder approach
Posted by: Guest on April-30-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 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 "laravel create data"

Browse Popular Code Answers by Language