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 9bac127..4e10263 100644 --- a/app/Http/Controllers/CompanyController.php +++ b/app/Http/Controllers/CompanyController.php @@ -22,16 +22,19 @@ class CompanyController extends Controller { foreach ($matchedTerms as $key => $matchedTerm) { - array_push($output, ['recipient_id'=> $matchedTerm->id, 'company_name' => $matchedTerm->company_name, 'tel_no' => $matchedTerm->tel_no, 'contact_person'=>$matchedTerm->contact_person ]); + 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); } else - { - return response()->json(['error'=>'Company not found'], 404); - } + { + return response()->json(['error'=>'Company not found'], 404); + } } public function update(Request $request) diff --git a/app/Http/Controllers/ContactController.php b/app/Http/Controllers/ContactController.php index ec155cd..841d875 100644 --- a/app/Http/Controllers/ContactController.php +++ b/app/Http/Controllers/ContactController.php @@ -37,15 +37,6 @@ class ContactController extends Controller } } - // foreach ($contacts2 as $contact => $value) { - // print_r($value->sender_company_name); - // //if($value['sender_company_id'] == Auth::user()->company()->first()->id){ - // // var_dump($contact); - // //print_r($value['sender_company_id']); - // //} - - // //$contact->helo - // } return response()->json($contacts2, 200); } diff --git a/public/contacts.html b/public/contacts.html index f9a59eb..dc33762 100644 --- a/public/contacts.html +++ b/public/contacts.html @@ -97,7 +97,7 @@
@@ -142,7 +142,7 @@ @@ -150,6 +150,53 @@ + + + + + @@ -166,7 +213,7 @@ success:function(data){ console.log(data); data.forEach(function(entry) { - console.log(entry.status); + //console.log(entry.status); //console.log(entry.company_name); if(entry.status === 0) { @@ -177,6 +224,7 @@ else //to display sent requests { //sent requwsts code go here + $('#sent-req').append(' ' + entry.recipient_company_name + '