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'); } /**