Answers for "update or create laravel query builder"

PHP
1

laravel query builder data insert

use Illuminate\Support\Facades\DB;//use it above
use Illuminate\Support\Facades\Hash;   //Hash for password || use it above

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');
    }
Posted by: Guest on April-21-2021
10

laravel update from query

$affected = DB::table('users')
              ->where('id', 1)
              ->update(['votes' => 1]);
Posted by: Guest on May-07-2020
1

laravel where update query

DB::table('users')
        ->where('id', $id)
        ->update([
            'status'     => 1
        ]);
Posted by: Guest on August-25-2021

Code answers related to "update or create laravel query builder"

Browse Popular Code Answers by Language