From e34df92ef6c582bde406a251e0aa68abf114b083 Mon Sep 17 00:00:00 2001 From: Aqeeb Imtiaz Harun Date: Mon, 6 Aug 2018 15:10:25 +0800 Subject: [PATCH] changed files according to discussions on Gitlab and tweaked search function --- app/Company.php | 36 +++++++++++----------- app/Contact.php | 2 +- app/Http/Controllers/CompanyController.php | 3 ++ 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/app/Company.php b/app/Company.php index 2a1fde2..b2a0918 100644 --- a/app/Company.php +++ b/app/Company.php @@ -6,38 +6,38 @@ use Illuminate\Database\Eloquent\Model; class Company extends Model { - + protected $fillable = [ - - 'company_profile', - 'reg_cert', - 'company_name', - 'registration_no', - 'tax_no', - 'tel_no', - 'fax', - 'address', - 'city', - 'postcode', - 'state', - 'country', + + 'company_profile', + 'reg_cert', + 'company_name', + 'registration_no', + 'tax_no', + 'tel_no', + 'fax', + 'address', + 'city', + 'postcode', + 'state', + 'country', 'contact_person', - 'user_id', + 'user_id', ]; - + public function user() { return $this->belongsTo('App\User'); } - public function deliveryinfo() { + public function deliveryInfo() { return $this->hasMany('App\Deliveryinfo'); } - public function warehouse() { + public function warehouses() { return $this->hasMany('App\Warehouse'); diff --git a/app/Contact.php b/app/Contact.php index 514be63..e97f5be 100644 --- a/app/Contact.php +++ b/app/Contact.php @@ -14,7 +14,7 @@ class Contact extends Model } - public function companies(){ + public function company(){ return $this->belongsTo('App\Company'); diff --git a/app/Http/Controllers/CompanyController.php b/app/Http/Controllers/CompanyController.php index 78aaa40..4e10263 100644 --- a/app/Http/Controllers/CompanyController.php +++ b/app/Http/Controllers/CompanyController.php @@ -22,7 +22,10 @@ class CompanyController extends Controller { foreach ($matchedTerms as $key => $matchedTerm) { + if($matchedTerm->id != Auth::user()->company()->first()->id) + { array_push($output, ['recipient_id'=> $matchedTerm->id, 'company_name' => $matchedTerm->company_name, 'tel_no' => $matchedTerm->tel_no, 'contact_person'=>$matchedTerm->contact_person ]); + } } return response($output);