mpociot / teamwork

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

Non-static method Mpociot\Teamwork\Teamwork::inviteToTeam() should not be called statically, assuming $this from incompatible context #13

Closed minedun6 closed 9 years ago

minedun6 commented 9 years ago

When i try to call this method, there is this error that pops out and says that i can't use it. is there a way to fix ?

mpociot commented 9 years ago

It seems like you're not using the "inviteToTeam" method on the facade. Could you try this again without the whole namespace and just use the Teamwork facade instead?

minedun6 commented 9 years ago

yes how silly of me, i was referencing the actual class rather than the facade. and another bit of an issue come out, i was trying to get the actual number of pending invitations related to the USER but i'm surprised it was on a seperate object.

mpociot commented 9 years ago

What do you mean by separate object? The pending invitations are related to the email address, because there is no other indication available.

minedun6 commented 9 years ago

normally the invitation are related to the user so logically i should be doing

$user->pendingInvitations(); and it should return a collection of objectives such as who's the sender and the receipient.

mpociot commented 9 years ago

Oh you're right. I haven't thought about that. I only thought about having pending invitations to users, that aren't yet registered.

I'll add this feature in the next version :+1:

minedun6 commented 9 years ago

do u have a lock on the next version or is it gonna be for a little while ? Something else to keep in mind, u need to keep track of both the sender and the receipient in the database and u're not doing that, u should make that getting the pending invitations are show to the recepient properly not to the sender. U should see this repo, will help you out greatly.

https://github.com/DraperStudio/Laravel-Friendable

mpociot commented 9 years ago

I'm trying to stick with the current API - so there's at least no version 2 on the horizon. So I'm going to stick to http://semver.org

So the next version will be 1.2.0, as this feature isn't changing existing behaviour

mpociot commented 9 years ago

And the invitations are in fact keeping track of both the sender and the recipient. The sender is referenced via the user_id and the recipient is referenced via the email, because there is no other way to recognize a receiver just right now.

What might be possible is that you could throw in a user (or "Auth") object to the inviteToTeam method as well, and it will extract the user_id and email from it.

mpociot commented 9 years ago

@minedun6 the invites relation for a user already exists. To list all pending invites of a specific user model use the invites relation like:

Auth::user()->invites();