laravel when query code example
Example 1: laravel sql query
use Illuminate\Support\Facades\DB;
$users = DB::select('select * from users');
foreach ($users as $user) {
echo $user->name;
}
Example 2: Laravel query where and
Table::where('Column', Value)->where('NewColumn', Value)->get();
Example 3: laravel query builder select first
$user = DB::table('users')->where('name', 'John')->first();
var_dump($user->name);
Example 4: laravel find query
foreach (Flight::where('foo', 'bar')->cursor() as $flight) {
//
}