public function up()
 {
     Schema::create('matches', function (Blueprint $table) {
         $table->increments('id');
         $table->integer('tournamentId')->unsigned();
         $table->integer('homeTournamentTeamId')->unsigned();
         $table->integer('awayTournamentTeamId')->unsigned();
         $table->tinyInteger('homeScore')->unsigned();
         $table->tinyInteger('awayScore')->unsigned();
         $table->tinyInteger('homePenaltyScore')->unsigned();
         $table->tinyInteger('awayPenaltyScore')->unsigned();
         $table->enum('gameType', Match::getAvailableGameTypes());
         $table->enum('resultType', Match::getAvailableResultTypes());
         $table->enum('status', Match::getAvailableStatuses())->default(Match::STATUS_NOT_STARTED);
         $table->timestamps();
     });
     Schema::table('matches', function (Blueprint $table) {
         $table->foreign('homeTournamentTeamId')->references('id')->on('tournament_teams')->onDelete('restrict')->onUpdate('restrict');
         $table->foreign('awayTournamentTeamId')->references('id')->on('tournament_teams')->onDelete('restrict')->onUpdate('restrict');
     });
 }
示例#2
0
 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     return ['match.homeScore' => 'required|integer', 'match.awayScore' => 'required|integer', 'match.status' => 'required|in:' . join(',', Match::getAvailableStatuses())];
 }