Laravel insert query not working

Laravel insert query is not working. You can use insert statement or create statement to insert record in table.

Answers 1
  • Save record using insert statement in laravel

    $user = DB::table('users')->insert([
                'name' => 'Kayla',
                'email' => '[email protected]',
                'password' => Hash::make('secret')
            ]);
    return $user;
    //Output:
    1
    
    0

    This code snippet will insert a new record in users table using insert statement in laravel. It returns 1 as an output if query executed successfully.

  • Back to code snippet queries related laravel