and query laravel code example

Example 1: laravel orWhere

$camps = $field->camps()->where('status', 0)->where(function ($q) {
    $q->where('sex', Auth::user()->sex)->orWhere('sex', 0);
})->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 db inserr

DB::table('users')->insert([
    'email' => '[email protected]',
    'votes' => 0
]);

Example 4: Laravel query where and

Table::where('Column', Value)->where('NewColumn', Value)->get();

Tags:

Php Example