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

前端 未结 5 1814
清歌不尽
清歌不尽 2020-12-04 15:14

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:

5条回答
  •  醉话见心
    2020-12-04 15:32

    FYI, the list of operators (containing like and all others) is in code:

    /vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php
    
    protected $operators = array(
        '=', '<', '>', '<=', '>=', '<>', '!=',
        'like', 'not like', 'between', 'ilike',
        '&', '|', '^', '<<', '>>',
        'rlike', 'regexp', 'not regexp',
    );
    

    disclaimer:

    Joel Larson's answer is correct. Got my upvote.

    I'm hoping this answer sheds more light on what's available via the Eloquent ORM (points people in the right direct). Whilst a link to documentation would be far better, that link has proven itself elusive.

提交回复
热议问题