Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// 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