Browse Source

fix: search master

Muhammad Iqbal Afandi 3 years ago
parent
commit
f03259d73d
4 changed files with 7 additions and 7 deletions
  1. 2
    2
      app/Models/Customer.php
  2. 2
    2
      app/Models/Laundry.php
  3. 2
    2
      app/Models/Product.php
  4. 1
    1
      app/Models/User.php

+ 2
- 2
app/Models/Customer.php View File

@@ -30,9 +30,9 @@ class Customer extends Model
30 30
         return $this->hasMany(Transaction::class, 'customer_number', 'customer_number');
31 31
     }
32 32
 
33
-    public function scopeFilter($query, $search)
33
+    public function scopeFilter($query, array $filters)
34 34
     {
35
-        $query->when($search ?? null, function ($query, $search) {
35
+        $query->when($filters['search'] ?? null, function ($query, $search) {
36 36
             $query->where(function ($query) use ($search) {
37 37
                 $query->where('customer_number', 'like', '%' . $search . '%')
38 38
                     ->orWhere('name', 'like', '%' . $search . '%')

+ 2
- 2
app/Models/Laundry.php View File

@@ -43,9 +43,9 @@ class Laundry extends Model
43 43
         return $this->hasMany(TransactionDetail::class);
44 44
     }
45 45
 
46
-    public function scopeFilter($query, $search)
46
+    public function scopeFilter($query, array $filters)
47 47
     {
48
-        $query->when($search ?? null, function ($query, $search) {
48
+        $query->when($filters['search'] ?? null, function ($query, $search) {
49 49
             $query->where(function ($query) use ($search) {
50 50
                 $query->where('name', 'like', '%' . $search . '%')
51 51
                     ->orWhere('price', 'like', '%' . $search . '%')

+ 2
- 2
app/Models/Product.php View File

@@ -43,9 +43,9 @@ class Product extends Model
43 43
         return $this->hasMany(TransactionDetail::class);
44 44
     }
45 45
 
46
-    public function scopeFilter($query, $search)
46
+    public function scopeFilter($query, array $filters)
47 47
     {
48
-        $query->when($search ?? null, function ($query, $search) {
48
+        $query->when($filters['search'] ?? null, function ($query, $search) {
49 49
             $query->where(function ($query) use ($search) {
50 50
                 $query->where('name', 'like', '%' . $search . '%')
51 51
                     ->orWhere('price', 'like', '%' . $search . '%')

+ 1
- 1
app/Models/User.php View File

@@ -82,7 +82,7 @@ class User extends Authenticatable implements MustVerifyEmail
82 82
         return $this->hasMany(Transaction::class);
83 83
     }
84 84
 
85
-    public function scopeFilter($query, $filters)
85
+    public function scopeFilter($query, array $filters)
86 86
     {
87 87
         $query->when($filters['search'] ?? null, function ($query, $search) {
88 88
             $query->where(function ($query) use ($search) {