LoginSignup
3
2

Eloquentのwhereメソッドを簡潔に書く

Last updated at Posted at 2023-12-10

概要

普段Eloquentでwhereメソッドを使う際、こんな感じで書いていると思います

$users = User::where('is_active',true)->get();

実は「=」の式ならメソッド名とカラムをくっつけてクエリが組み立てれちゃいます

$users = User::whereIsActive(true)->get();

where + アッパーキャメルケースのカラム名 で実現出来ます。

3
2
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
3
2