Knobik
Knobik

Reputation: 383

Laravel 4 ORM find by columns array

Im learining Laravel 4 now, my company is updating and changing frameworks so i've got a question regarding its ORM/QueryBuilder/Whaterver...

Im wondering if its possible to use something like

Users::find(array(
    'role_id' => 2,
    'active' => 1
))

Thats basicly find by 2 columns. I DO NOT want to do something like this:

Users->where(...)->where(...)->get()

i would like the flexibility of an array.

Upvotes: 0

Views: 209

Answers (1)

Dennis Schepers
Dennis Schepers

Reputation: 573

Looking from an OOP stand point, the later option is acctualy much nicer because it improves the readability.

You might benefit from using Laravels query builder (http://laravel.com/docs/queries), where you would not directly query the model itself.

Upvotes: 1

Related Questions