Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Eloquentを使用して列にエイリアスを与える方法を見つけようとしています。
つまり、Eloquent を使用して次の mysql クエリを実行するにはどうすればよいでしょうか?
SELECT occupation AS test FROM users WHERE occupation = 'PIMP';
前もってThx!
Eloquent は通常の Fluent クエリを返します。したがって、次のようなことを試すことができます (モデル名が「ユーザー」であると仮定します):
$user = User::where_occupation('pimp')->get(array('occupation as test'));