Answers for "how to select query in laravel"

PHP
0

laravel sql query

use Illuminate\Support\Facades\DB;

$users = DB::select('select * from users');

foreach ($users as $user) {
    echo $user->name;
}
Posted by: Guest on January-07-2021
0

laravel query when

$role = $request->input('role');

$users = DB::table('users')
                ->when($role, function ($query, $role) {
                    return $query->where('role_id', $role);
                })
                ->get();
Posted by: Guest on September-14-2020

Code answers related to "how to select query in laravel"

Browse Popular Code Answers by Language