LoginSignup
15
9

More than 1 year has passed since last update.

Laravelは複数のwhereを配列で一括指定できる

Posted at

Laravelのクエリビルダでwhereで複数条件指定する際は

->where('id', $id)->where('name', $name)

とするのもアリだが、複数指定は下記ように配列で指定するほうが可読性が上がる。

->where([
  ['id', '=', $id],
  ['name', '=', $name],
])

【おまけ】Eloquentとクエリビルダの違いの再確認

下記記事がわかりやすかった。

15
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
9