Laravel insert query not working

Updated at 31-Aug-2021, By samar

Laravel insert query not working

With this article, we’ll look at some examples of how to address the "Laravel insert query not working" problem.

Laravel insert query is not working. You can use insert statement or create statement to insert record in table.
  • 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
    

    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