Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b820693
commit 5d440d0
Showing
5 changed files
with
203 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
use yii\db\Migration; | ||
|
||
class m160115_130125_knockout extends Migration | ||
{ | ||
public function up() | ||
{ | ||
$this->createTable('knockout', [ | ||
'map_id' => $this->integer()->notNull(), | ||
'rule_id' => $this->integer()->notNull(), | ||
'battles' => $this->bigInteger()->notNull(), | ||
'knockouts' => $this->bigInteger()->notNull(), | ||
]); | ||
$this->addPrimaryKey('pk_knockout', 'knockout', ['map_id', 'rule_id']); | ||
$this->addForeignKey('fk_knockout_1', 'knockout', 'map_id', 'map', 'id'); | ||
$this->addForeignKey('fk_knockout_2', 'knockout', 'rule_id', 'rule', 'id'); | ||
} | ||
|
||
public function down() | ||
{ | ||
$this->dropTable('knockout'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
/** | ||
* @copyright Copyright (C) 2016 AIZAWA Hina | ||
* @license https://github.com/fetus-hina/stat.ink/blob/master/LICENSE MIT | ||
* @author AIZAWA Hina <hina@bouhime.com> | ||
*/ | ||
|
||
namespace app\models; | ||
|
||
use Yii; | ||
|
||
/** | ||
* This is the model class for table "knockout". | ||
* | ||
* @property integer $map_id | ||
* @property integer $rule_id | ||
* @property integer $battles | ||
* @property integer $knockouts | ||
* | ||
* @property Map $map | ||
* @property Rule $rule | ||
*/ | ||
class Knockout extends \yii\db\ActiveRecord | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public static function tableName() | ||
{ | ||
return 'knockout'; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function rules() | ||
{ | ||
return [ | ||
[['map_id', 'rule_id', 'battles', 'knockouts'], 'required'], | ||
[['map_id', 'rule_id', 'battles', 'knockouts'], 'integer'] | ||
]; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function attributeLabels() | ||
{ | ||
return [ | ||
'map_id' => 'Map ID', | ||
'rule_id' => 'Rule ID', | ||
'battles' => 'Battles', | ||
'knockouts' => 'Knockouts', | ||
]; | ||
} | ||
|
||
/** | ||
* @return \yii\db\ActiveQuery | ||
*/ | ||
public function getMap() | ||
{ | ||
return $this->hasOne(Map::className(), ['id' => 'map_id']); | ||
} | ||
|
||
/** | ||
* @return \yii\db\ActiveQuery | ||
*/ | ||
public function getRule() | ||
{ | ||
return $this->hasOne(Rule::className(), ['id' => 'rule_id']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters