Last active
November 23, 2021 15:01
-
-
Save calebporzio/a85538fd506421448f68a97309355f1b to your computer and use it in GitHub Desktop.
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
// Add this to the "boot()" method of your "AppServiceProvider" | |
<?php | |
\Illuminate\Database\Eloquent\Builder::macro('search', function ($name, $search) { | |
return $this->where($name, 'LIKE', $search ? '%'.$search.'%' : ''); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment