created color search function

This commit is contained in:
2025-03-16 02:11:38 +01:00
parent 9b3913b68c
commit 820058dab0
3 changed files with 13 additions and 3 deletions
+6 -1
View File
@@ -3,6 +3,7 @@
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Database\Eloquent\Builder;
class AppServiceProvider extends ServiceProvider
{
@@ -19,6 +20,10 @@ class AppServiceProvider extends ServiceProvider
*/
public function boot(): void
{
//
// Search
Builder::macro('search', function ($field, $string) {
return $string ? $this->where($field, 'like', '%' . $string . '%') : $this;
});
}
}