fix for returning token on company creation

This commit is contained in:
David Bomba 2019-10-09 16:47:12 +11:00
parent 710732a1fb
commit 0469de7466
2 changed files with 5 additions and 2 deletions

View File

@ -234,7 +234,7 @@ class CompanyController extends BaseController
$this->entity_type = CompanyUser::class; $this->entity_type = CompanyUser::class;
//return $this->itemResponse($company); //return $this->itemResponse($company);
$ct = CompanyUser::whereUserId(auth()->user()->id); $ct = CompanyUser::whereUserId(auth()->user()->id)->whereCompanyId($company->id);
return $this->listResponse($ct); return $this->listResponse($ct);

View File

@ -55,9 +55,12 @@ class CompanyUser extends Pivot
return $this->hasOne(Company::class, 'id', 'company_id'); return $this->hasOne(Company::class, 'id', 'company_id');
} }
/*todo monitor this function - may fail under certain conditions*/
public function token() public function token()
{ {
return $this->belongsTo(CompanyToken::class, 'user_id','user_id');
/*
return $this->hasOneThrough( return $this->hasOneThrough(
CompanyToken::class, CompanyToken::class,
CompanyUser::class, CompanyUser::class,
@ -66,6 +69,6 @@ class CompanyUser extends Pivot
'user_id', // Local key on CompanyToken table... 'user_id', // Local key on CompanyToken table...
'company_id' // Local key on CompanyUser table... 'company_id' // Local key on CompanyUser table...
); );
*/
} }
} }