From 3d7f8da114f57870be8a3de3fd709b534c65f474 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Tue, 6 Apr 2021 16:42:17 +0800 Subject: [PATCH] big commit --- app/Http/Resources/CompanyResource.php | 5 +++-- app/Models/Company.php | 8 -------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/app/Http/Resources/CompanyResource.php b/app/Http/Resources/CompanyResource.php index 309356ed..77a67f34 100644 --- a/app/Http/Resources/CompanyResource.php +++ b/app/Http/Resources/CompanyResource.php @@ -18,11 +18,12 @@ class CompanyResource extends JsonResource */ public function toArray($request) { + $companyModule = $this->modules->first(); return [ 'id' => $this->id, 'account_no' => $this->reference_no, - 'marking' => CompanyConnections::where('module_one', $this->modules->first()->id)->first()->marking, - 'email' => $this->employees->first()->email, + 'marking' => CompanyConnections::where('module_one', $companyModule->id)->first()->marking, + 'email' => $companyModule->employees->first()->email, 'name' => $this->name, 'type' => $this->type, 'status' => (int) $this->status, diff --git a/app/Models/Company.php b/app/Models/Company.php index 4da1f167..d007fea0 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -3,7 +3,6 @@ namespace App\Models; use App\Classes\General\Interfaces\Documentable; -use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasManyThrough; use Illuminate\Database\Eloquent\Relations\HasOne; @@ -60,13 +59,6 @@ class Company extends AbstractModel implements Documentable return $this->hasMany(CompanyModule::class); } - /** - * @return belongsToMany - */ - public function employees(): belongsToMany - { - return $this->belongsToMany(User::class, (new CompanyEmployee())->getTable(), 'company_id','user_id'); - } /** * @return HasManyThrough