Closed kielabokkie closed 8 years ago
Have you found a way around this issue?
For version 2 of this package it would be best if the user_id
field is nullable and inviteToTeam
inserts NULL instead of throwing a FatalErrorException
.
I got around it by creating my own version of the inviteToTeam function on my Team.php
class (which extends TeamworkTeam
):
class Team extends TeamworkTeam
{
/**
* Invite a user to the team.
*
* @param string $email
* @param integer $inviterId
* @param callable $success
*/
public function inviteUser($email, $inviterId, callable $success = null)
{
$invite = new TeamInvite;
$invite->user_id = $inviterId;
$invite->team_id = $this->id;
$invite->type = 'invite';
$invite->email = $email;
$invite->accept_token = md5(uniqid(microtime()));
$invite->deny_token = md5(uniqid(microtime()));
$invite->save();
if (is_null($success) === false) {
$success($invite);
}
}
}
This allows me to pass the id of the inviter. Making user_id
nullable is also a possibility to get around the issue but I think it's a good idea to allow the inviter id to be passed in manually so you don't rely on the authenticated user.
Hi,
I'm using Teamwork for a REST API project and I'm having an issue with the
inviteToTeam
function. My API uses OAuth to authentication users so I don't have an "authenticated user" which causes an error on line 71 of Teamwork.php. Basically it tries to get the id of the authenticated user but$this->app->auth->user()
will returnnull
in my case, so getgetKey()
will throw aFatalErrorException
.I can write my own implementation of the
inviteToTeam
function but I wonder if there is a way around it or if you might support this use case in the future?