嗨,我是laravel和mongodb的新人。我在许多关系中编写了关于团队,用户和董事会的一些关系。但它不起作用!我应该怎么做控制器。
(我使用jenssegers / laravel-mongodb https://github.com/jenssegers/laravel-mongodb))
关系是用户1 .. * --- *团队* ---- 1 .. *董事会
class User extends ...
public function teams()
{
return $this->belongsToMany('Team', null, 'teamMembers', 'teams');
}
class Taskboard extends ...
public function teams()
{
return $this->belongsToMany('Team', null, 'taskboards', 'teams');
}
class Team extends ...
public function teamMembers()
{
return $this->belongsToMany('User', null, 'teams', 'teamMembers');
}
public function taskboards()
{
return $this->belongsToMany('Taskboard', null, 'teams', 'taskboards');
}
public function store()
{
$team = new Team;
$team->name = Input::get('teamname');
$team->master = Auth::user()->_id;
$team = Auth::user()->teams()->save($team); // OK just work!
$team->save();
return Redirect::route('main');
}
public function store()
{
$taskboard = new Taskboard;
$taskboard->name = Input::get('boardname');
$taskboard->teams = Input::get('team');
$taskboard = Auth::user()->teams()->save(taskboard); // Not work! What should I do to store boards in team
return Redirect::route('main');
}