Search code examples
ormlaraveleloquentsql-like

Using Eloquent ORM in Laravel to perform search of database using LIKE


I want to use Eloquent's active record building to build a search query, but it is going to be a LIKE search. I have found the User::find($term) or User::find(1), but this is not generating a like statement. I'm not looking for a direct answer, but if someone could at least give me a direction to look in that'd be great!


Solution

  • You're able to do database finds using LIKE with this syntax:

    Model::where('column', 'LIKE', '%value%')->get();