insert query in laravel 8 code example
Example 1: laravel query builder data insert
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
public function create(Request $request)
{
DB::table('students')->insert([
'email' => $request->email,
'password' => Hash::make($request->password),
'address' => $request->address,
'address2' => $request->address2,
'city' => $request->city,
'country' => $request->country,
'zip' => $request->zip,
]);
return redirect('create');
}
Example 2: insert into laravel 8
DB::insert('insert into users (id, name) values (?, ?)', [1, 'Dayle']);