laravel:how to use LOWERCASE Function in Eloquent Query?

前端 未结 1 376
囚心锁ツ
囚心锁ツ 2021-01-17 12:16

I want to implement case insensitive search following is my code for search

/*get the title to search*/
$newsTitle=Input::get(\'srach_newsTitle\')?Input:         


        
相关标签:
1条回答
  • 2021-01-17 12:36

    Use LOWER()

    $query->whereRaw('LOWER(`newsTitle`) LIKE ? ',[trim(strtolower($newsTitle)).'%']);
    
    0 讨论(0)
提交回复
热议问题