Answers for "insert data using query builder in laravel"

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
7

laravel not in query

DB::table(..)->select(..)->whereNotIn('book_price', [100,200])->get();
Posted by: Guest on September-26-2020
0

laravel find query

// Retrieve a model by its primary key...
$flight = App\Models\Flight::find(1);

// Retrieve the first model matching the query constraints...
$flight = App\Models\Flight::where('active', 1)->first();

// Shorthand for retrieving the first model matching the query constraints...
$flight = App\Models\Flight::firstWhere('active', 1);
Posted by: Guest on October-08-2020

Code answers related to "insert data using query builder in laravel"

Browse Popular Code Answers by Language