mpociot / teamwork

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

Missing argument 1 for Mpociot\Teamwork\Teamwork::__construct(), called in C:\wamp\www\LOLPLATFORM\app\Http\Controllers\TeamsController.php on line 30 and defined #10

Closed minedun6 closed 9 years ago

minedun6 commented 9 years ago

i did exactly as the documentation said and i got this error when i tried to execute it -_-

Here's what i wrote

public function create(Request $request) { $team = new Team(); $team->owner_id = User::find($request->get('leader')); $team->name = $request->get('name'); $team->save();

}
mpociot commented 9 years ago

Hi,

Did you add Mpociot\Teamwork\TeamworkServiceProvider::class To your config/app.php ?

minedun6 commented 9 years ago

yes i did, I followed all steps

mpociot commented 9 years ago

Can you tell me, what line 30 in the TeamsController is? Which version of laravel are you using?

minedun6 commented 9 years ago

here's the code : public function create(Request $request) { $team = new Team(); $team->owner_id = User::where('username', '=', 'sebastian')->first()->getKey(); $team->name = 'My awesome team'; $team->save(); }

and I'm using L5

mpociot commented 9 years ago

I need the code on line 30, not the whole block

minedun6 commented 9 years ago

$team = new Team();

mpociot commented 9 years ago

Hm, OK. Can you give me the full error output? The issue title got truncated.

And how does your Team model look like?

minedun6 commented 9 years ago

For the team model it's just
class Team extends TeamWork{}

As for the full error it's

ErrorException in Teamwork.php line 24: Missing argument 1 for Mpociot\Teamwork\Teamwork::__construct(), called in C:\wamp\www\IAmLegend\app\Http\Controllers\TeamsController.php on line 30 and defined

mpociot commented 9 years ago

Ah, that's the problem. The team model should extend TeamworkTeam.

Like this:

class Team extends TeamworkTeam { }

minedun6 commented 9 years ago

Yeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaah My bad !! I was really stupid to forget that !!