mpociot / teamwork

User to Team associations with invitation system for the Laravel 5 Framework
MIT License
1.07k stars 170 forks source link

working with Join #57

Closed Alexmg86 closed 7 years ago

Alexmg86 commented 8 years ago

Hi! How i can use teamwork, if i need Join in query?

Laravel ask me error: "SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'team_id' in where clause is ambiguous (SQL: select tasks.*, price_types.name as name_type from tasks inner join price_types on tasks.type_list = price_types.id where project_id = 9 and team_id = 1 order by id asc)"

Alexmg86 commented 8 years ago

i change trait UsedByTeams static::addGlobalScope('team', function (Builder $builder) { static::teamGuard(); $builder->where($builder->getQuery()->from . '.team_id', auth()->user()->currentTeam->getKey()); });

mpociot commented 8 years ago

Could you provide a pull request with that modification?