Add whereLike
query to laravel Illuminate\Database\Eloquent\Builder
.
Illuminate\Database\Eloquent\Builder
クラスにwhereLike
メソッドを追加します。
composer require kazuki/laravel-where-like
// Search for Ichiro working in Tokyo
$words = ['Ichiro', 'Tokyo'];
$comulns = ['name', 'company.address'];
$users = User::whereLike($columns, $words)->get();
$position
- -1: Forward Consistency (前方一致)
- 1: Backward Consistency (後方一致)
- 0: Partially Consistent (部分一致) (Default)
$boolean
'and'
: Default'or'
// Search for who working in Tokyo or Osaka
$words = ['Tokyo', 'Osaka'];
$comulns = ['company.address'];
$users = User::whereLike($columns, $words, 0, 'or')->get();