From 1bae1214810327ccc2a0dd9ae21ec8feb44c5a4c Mon Sep 17 00:00:00 2001 From: Deon George Date: Wed, 24 Jul 2024 14:53:18 +1000 Subject: [PATCH] Fix search now that supplier_user is account_supplier --- app/Http/Controllers/SearchController.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php index cd9c1c2..b9a233c 100644 --- a/app/Http/Controllers/SearchController.php +++ b/app/Http/Controllers/SearchController.php @@ -44,16 +44,15 @@ class SearchController extends Controller // Look for User by their Supplier ID with some suppliers if (is_numeric($request->input('term'))) - foreach (User::select(['users.*','suppliers.name AS supplier_name','supplier_user.id AS pivot_id']) - ->join('supplier_user',['supplier_user.user_id'=>'users.id']) - ->join('suppliers',['suppliers.id'=>'supplier_user.supplier_id']) - ->whereIN('user_id',$user_ids) - ->where('supplier_user.id','like','%'.$request->input('term').'%') - ->orderBy('lastname') - ->orderBy('firstname') + foreach (Account::select(['user_id','suppliers.name AS supplier_name','account_supplier.supplier_ref AS pivot_id']) + ->join('account_supplier',['account_supplier.account_id'=>'accounts.id']) + ->join('suppliers',['suppliers.id'=>'account_supplier.supplier_id']) + ->whereIN('accounts.id',$account_ids) + ->where('account_supplier.supplier_ref','like','%'.$request->input('term').'%') + ->orderBy('company') ->limit(10)->get() as $o) { - $result->push(['name'=>sprintf('%s (%s:%s)',$o->name,$o->supplier_name,$o->pivot_id),'value'=>'/u/home/'.$o->id,'category'=>'Suppliers']); + $result->push(['name'=>sprintf('%s (%s:%s)',$o->company,$o->supplier_name,$o->supplier_ref),'value'=>'/u/home/'.$o->user_id,'category'=>'Suppliers']); } // Look for Account