From be6bd73762f51fb0385eedb87529aa81c9695eef Mon Sep 17 00:00:00 2001 From: philipp lang Date: Thu, 15 Jul 2021 20:59:06 +0200 Subject: [PATCH] Fixed: Dont search for anything if search is empty --- app/Member/Member.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Member/Member.php b/app/Member/Member.php index 673d78ae..4e236678 100644 --- a/app/Member/Member.php +++ b/app/Member/Member.php @@ -14,7 +14,7 @@ use App\Subactivity; use Zoomyboy\LaravelNami\NamiUser; use App\Payment\Subscription; use App\Payment\Payment; -use Illuminate\Database\Query\Builder; +use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\HasMany; use App\Confession; @@ -42,7 +42,8 @@ class Member extends Model 'is_confirmed' => 'boolean', ]; - public function scopeSearch(Builder $q, string $text): Builder { + public function scopeSearch(Builder $q, ?string $text): Builder { + if (is_null($text)) { return $q; } return $q->where('firstname', 'LIKE', '%'.$text.'%') ->orWhere('lastname', 'LIKE', '%'.$text.'%') ->orWhere('address', 'LIKE', '%'.$text.'%')