add contraint , that everybody expect admin is limited to 3 days, Add card package
This commit is contained in:
80
common/models/CardPackage.php
Normal file
80
common/models/CardPackage.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
use yii\behaviors\TimestampBehavior;
|
||||
|
||||
/**
|
||||
* This is the model class for table "card_package".
|
||||
*
|
||||
* @property integer $id_card_package
|
||||
* @property integer $id_user
|
||||
* @property integer $count
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
*/
|
||||
class CardPackage extends \common\models\BaseFitnessActiveRecord
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'card_package';
|
||||
}
|
||||
|
||||
public function getUser(){
|
||||
return $this->hasOne(User::className(), ['id' => 'id_user' ]);
|
||||
}
|
||||
public function getCardAssignments(){
|
||||
return $this->hasMany(CardCardPackageAssignment::className(), ['id_card_package' => 'id_card_package' ]);
|
||||
}
|
||||
public function getCards(){
|
||||
return $this->hasMany(Card::className(), ['id_card' => 'id_card' ])->via('cardAssignments');
|
||||
}
|
||||
|
||||
public function getUserName(){
|
||||
$user = $this->user;
|
||||
$result = "";
|
||||
if ( isset($user) ){
|
||||
$result = $this->user->username;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['count'], 'integer',"min" => 1 , "max" => 3000],
|
||||
[['count'], 'required'],
|
||||
];
|
||||
}
|
||||
|
||||
public function getPrintedDate(){
|
||||
if ( $this->printed > 0 ){
|
||||
return $this->updated_at;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id_card_package' => Yii::t('common/card_package', 'Kártya csomag azonosító'),
|
||||
'id_user' => Yii::t('common/card_package', 'Felhasználó'),
|
||||
'count' => Yii::t('common/card_package', 'Mennyiség'),
|
||||
'printed' => Yii::t('common/card_package', 'Letöltve'),
|
||||
'printedDate' => Yii::t('common/card_package', 'Utolsó letöltés ideje'),
|
||||
'count' => Yii::t('common/card_package', 'Mennyiség'),
|
||||
'created_at' => Yii::t('common/card_package', 'Létrehozva'),
|
||||
'updated_at' => Yii::t('common/card_package', 'Nyomtatva'),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user