common/models/base/WalletCategory.php
<?php
/*
* This file is part of the HomeFinanceV2 project.
*
* (c) Rafalsky.com <http://github.com/Rafalsky/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace common\models\base;
/**
* This is the base-model class for table "{{%wallet_category}}".
*
* @property integer $id
* @property string $hash
* @property integer $wallet_id
* @property integer $category_id
*
* @property Category $category
* @property Wallet $wallet
*/
abstract class WalletCategory extends HashedModel
{
/**
* @inheritdoc
*/
public static function tableName()
{
return '{{%wallet_category}}';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['hash'], 'required'],
[['wallet_id', 'category_id'], 'integer'],
[['hash'], 'string', 'max' => 23],
[['hash'], 'unique'],
[['category_id'], 'exist', 'skipOnError' => true, 'targetClass' => Category::className(), 'targetAttribute' => ['category_id' => 'id']],
[['wallet_id'], 'exist', 'skipOnError' => true, 'targetClass' => Wallet::className(), 'targetAttribute' => ['wallet_id' => 'id']],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => \Yii::t('common', 'ID'),
'hash' => \Yii::t('common', 'Hash'),
'wallet_id' => \Yii::t('common', 'Wallet ID'),
'category_id' => \Yii::t('common', 'Category ID'),
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getCategory()
{
return $this->hasOne(Category::className(), ['id' => 'category_id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getWallet()
{
return $this->hasOne(Wallet::className(), ['id' => 'wallet_id']);
}
}