add basic event objects

This commit is contained in:
Roland Schneider
2018-12-12 20:42:17 +01:00
parent 5599d2ef4b
commit b6e590f196
54 changed files with 2811 additions and 0 deletions

83
common/models/Room.php Normal file
View File

@@ -0,0 +1,83 @@
<?php
namespace common\models;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\helpers\ArrayHelper;
/**
* This is the model class for table "room".
*
* @property integer $id
* @property string $name
* @property integer $seat_count
* @property string $created_at
* @property string $updated_at
*/
class Room extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'room';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['name', 'seat_count'], 'required'],
[['seat_count'], 'integer'],
[['name'], 'unique'],
[['name'], 'string', 'max' => 255]
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => Yii::t('room', 'ID'),
'name' => Yii::t('room', 'Name'),
'seat_count' => Yii::t('room', 'Seat Count'),
'created_at' => Yii::t('room', 'Created At'),
'updated_at' => Yii::t('room', 'Updated At'),
];
}
public function behaviors()
{
return ArrayHelper::merge( [
[
'class' => TimestampBehavior::className(),
'value' => function(){ return date('Y-m-d H:i:s' ); }
]
],
parent::behaviors());
}
public function asOptions(){
$items = ArrayHelper::map(Room::find()->all(),'id','name');
return ArrayHelper::merge(['' => \Yii::t('event-type','All')],$items);
}
public static function roomOptions($all = false, $emtpyString = false){
$items = ArrayHelper::map(Room::find()->all(),'id','name');
$extra = [];
if ( $all ) {
$extra = ['' => \Yii::t('room','All')];
}
if ( $emtpyString ) {
$extra = ['' => '' ];
}
return ArrayHelper::merge($extra,$items);
}
}