Answers for "laravel query builder save"

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
0

laravel find query

<?php

$flights = App\Models\Flight::all();

foreach ($flights as $flight) {
    echo $flight->name;
}
Posted by: Guest on October-08-2020

Browse Popular Code Answers by Language