コード例 #1
0
ファイル: JinrohController.php プロジェクト: asdoda/wolfer
 protected function __findCast($cast)
 {
     $cast = Cast::where('code', '=', $cast)->first();
     return Mate::where('cast_id', '=', $cast->id)->where('room_id', '=', $this->room->id)->where('is_alive', '=', 1);
 }
コード例 #2
0
ファイル: Room.php プロジェクト: asdoda/wolfer
 public function shuffleCast()
 {
     $mates = $this->mates->all();
     $castArray = $this->__getAllSpecialCastAsArray();
     $peopleNumber = $this->mates->count() - count($castArray);
     $castArray = array_merge($castArray, $this->__sameArray('people', $peopleNumber));
     if (empty($castArray)) {
         return null;
     }
     $catchData = range(0, count($castArray) - 1);
     shuffle($catchData);
     $newMate = [];
     foreach ($mates as $mate) {
         $val = array_pop($catchData);
         $cast = Cast::where('code', '=', $castArray[$val])->first();
         $mate->cast_id = $cast->id;
         $mate->save();
         $newMate[] = $mate;
     }
 }