12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
- namespace App\Providers\Macros;
- use Illuminate\Database\Eloquent\Builder;
- use Illuminate\Support\ServiceProvider;
- class BuilderProvider extends ServiceProvider
- {
-
- public function register(): void
- {
-
- }
-
- public function boot(): void
- {
-
- Builder::macro('whereLike', function (string $attribute, string $searchTerm) {
- return $this->orWhere($attribute, 'LIKE', $searchTerm);
- });
-
- Builder::macro('whereILike', function (string $attribute, string $searchTerm) {
- return $this->orWhere($attribute, 'ILIKE', $searchTerm);
- });
- }
- }
|