コード例 #1
0
ファイル: PlayerCreator.php プロジェクト: BibleBowl/account
 /**
  * @param User  $guardian
  * @param array $attributes
  *
  * @return static
  */
 public function create(User $guardian, array $attributes)
 {
     $attributes['guardian_id'] = $guardian->id;
     DB::beginTransaction();
     $player = Player::create($attributes);
     if ($guardian->isNotA(Role::GUARDIAN)) {
         $role = Role::where('name', Role::GUARDIAN)->firstOrFail();
         $guardian->assign($role);
     }
     DB::commit();
     return $player;
 }
コード例 #2
0
ファイル: Group.php プロジェクト: BibleBowl/account
 public function addHeadCoach(User $user)
 {
     $user->groups()->attach($this->id);
     //dd($user->id, $this->id, $user->isNot(Role::HEAD_COACH));
     // make the owner a head coach if they aren't already
     if ($user->isNotA(Role::HEAD_COACH)) {
         $role = Role::where('name', Role::HEAD_COACH)->firstOrFail();
         $user->assign($role);
     }
 }