From 88124a56d22cfb14cdb0b0d39722c50db8ee5afd Mon Sep 17 00:00:00 2001 From: omair saleh Date: Tue, 6 Apr 2021 16:40:01 +0800 Subject: [PATCH] big commit --- app/Http/Resources/CompanyResource.php | 1 - app/Models/Company.php | 7 ++++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Http/Resources/CompanyResource.php b/app/Http/Resources/CompanyResource.php index a8ba429b..309356ed 100644 --- a/app/Http/Resources/CompanyResource.php +++ b/app/Http/Resources/CompanyResource.php @@ -18,7 +18,6 @@ class CompanyResource extends JsonResource */ public function toArray($request) { - dd($this->employees); return [ 'id' => $this->id, 'account_no' => $this->reference_no, diff --git a/app/Models/Company.php b/app/Models/Company.php index 59cf34a2..4da1f167 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -3,6 +3,7 @@ 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,11 +61,11 @@ class Company extends AbstractModel implements Documentable } /** - * @return hasManyThrough + * @return belongsToMany */ - public function employees(): hasManyThrough + public function employees(): belongsToMany { - return $this->hasManyThrough(User::class, CompanyEmployee::class); + return $this->belongsToMany(User::class, (new CompanyEmployee())->getTable(), 'company_id','user_id'); } /**