big commit

This commit is contained in:
omair saleh
2021-04-06 16:40:01 +08:00
parent 7c1f467594
commit 88124a56d2
2 changed files with 4 additions and 4 deletions
-1
View File
@@ -18,7 +18,6 @@ class CompanyResource extends JsonResource
*/
public function toArray($request)
{
dd($this->employees);
return [
'id' => $this->id,
'account_no' => $this->reference_no,
+4 -3
View File
@@ -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');
}
/**