Created
August 29, 2019 17:36
-
-
Save mackhankins/454d4114e34d5c885fd66fcdf0081550 to your computer and use it in GitHub Desktop.
Laravel Scout Elastic whereIn Macro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Providers; | |
use Laravel\Scout\Builder; | |
use Illuminate\Support\ServiceProvider; | |
class ScoutMacroServiceProvider extends ServiceProvider | |
{ | |
/** | |
* Register services. | |
* | |
* @return void | |
*/ | |
public function register() | |
{ | |
// | |
} | |
/** | |
* Bootstrap services. | |
* | |
* @return void | |
*/ | |
public function boot() | |
{ | |
Builder::macro('whereIn', function ($field, array $value) { | |
foreach ($value as $val) { | |
$this->where($field, $val); | |
} | |
return $this; | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment