Skip to content

Latest commit

 

History

History
37 lines (28 loc) · 835 Bytes

README.md

File metadata and controls

37 lines (28 loc) · 835 Bytes

laravel-where-like

Add whereLike query to laravel Illuminate\Database\Eloquent\Builder.

Illuminate\Database\Eloquent\BuilderクラスにwhereLikeメソッドを追加します。

install

composer require kazuki/laravel-where-like

Usage

// Search for Ichiro working in Tokyo
$words = ['Ichiro', 'Tokyo'];
$comulns = ['name', 'company.address'];
$users = User::whereLike($columns, $words)->get();

options

  • $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();