2022年7月19日星期二

Laravel Eloquent Query Using WHERE with OR AND OR (orWhere)

 Model::where(function ($query) use ($a,$b) {

    $query->where('a', '=', $a)
          ->orWhere('b', '=', $b);
})

===============================
if (isset($_GET["ids"])) {
$ids = $_GET["ids"];
$id_list = explode(",", $ids);
$notes = Note::where(function ($query) use ($id_list) {
$query->where(true);
foreach ($id_list as &$id) {
$query->orWhere('id', $id);
}
});
$notes = $notes->get();
return response()->json($notes);
}

沒有留言:

發佈留言

[Fixed] some windows chrome, scrolling has glitch position not accurate

   [Fixed] some windows chrome, scrolling has glitch position not accurate Smooth Scrolling Flag 📜 Chrome has an experimental "smooth ...