mpociot/teamwork

TeamworkTeamTrait owner() method should be a BelongsTo relationship

spriggsey opened this issue · 1 comments

Currently the relationship of the Team model is using the incorrect join.

The owner() relationship on the Team model should be a belongsTo() relationship as the Team model has the owner_id column.

The original code does work but with implementation of Laravel Nova it becomes an issue as they require a BelongsTo join to properly function.

/**
* Has-One relation with the user model.
* This indicates the owner of the team
*
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
public function owner()
{
$userModel = Config::get( 'teamwork.user_model' );
$userKeyName = ( new $userModel() )->getKeyName();
return $this->hasOne(Config::get('teamwork.user_model'), $userKeyName, "owner_id");
}

This should be fixed now.