laravel in query code example
Example 1: laravel where like
$users = DB::table('users')
->where('name', 'like', 'T%')
->get();
Example 2: laravel sql query
use Illuminate\Support\Facades\DB;
$users = DB::select('select * from users');
foreach ($users as $user) {
echo $user->name;
}
Example 3: laravel wher in
$users = DB::table('users')
->whereIn('id', [1, 2, 3])
->get();
Example 4: DB::table('users')->get();
DB::select('select * from users ');
Example 5: laravel find query
$model = App\Models\Flight::where('legs', '>', 100)
->firstOr(['id', 'legs'], function () {
});