99 lines
2.5 KiB
PHP
99 lines
2.5 KiB
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: zn
|
|
* Date: 2017/6/21
|
|
* Time: 17:22
|
|
*/
|
|
|
|
namespace common\models;
|
|
|
|
|
|
use yii\behaviors\TimestampBehavior;
|
|
use yii\db\ActiveRecord;
|
|
|
|
/**
|
|
* 公告
|
|
* Class Muchang
|
|
* @property int $id
|
|
* @property string $title 标题
|
|
* @property string $message
|
|
* @property integer $created_at
|
|
* @property integer $updated_at
|
|
*/
|
|
class Muchang extends ActiveRecord
|
|
{
|
|
public function behaviors()
|
|
{
|
|
return [
|
|
TimestampBehavior::className(),
|
|
];
|
|
}
|
|
|
|
public function rules()
|
|
{
|
|
return [
|
|
['id', 'default', 'value' => 0],
|
|
|
|
['user_id', 'required'],
|
|
['user_id', 'number', 'integerOnly' => true],
|
|
|
|
['item_config_id', 'default', 'value' => 0],
|
|
['item_config_id', 'number', 'integerOnly' => true],
|
|
|
|
['crop_config_id', 'default', 'value' => 0],
|
|
['crop_config_id', 'number', 'integerOnly' => true],
|
|
|
|
['type', 'default', 'value' => 0],
|
|
['type', 'number', 'integerOnly' => true],
|
|
|
|
['is_ripe', 'default', 'value' => 0],
|
|
['is_ripe', 'number', 'integerOnly' => true],
|
|
|
|
['is_output', 'default', 'value' => 0],
|
|
['is_output', 'number', 'integerOnly' => true],
|
|
|
|
['has_gather', 'default', 'value' => 0],
|
|
['has_gather', 'number', 'integerOnly' => true],
|
|
|
|
['num', 'default', 'value' => 0],
|
|
['num', 'number', 'integerOnly' => true],
|
|
|
|
['output', 'default', 'value' => 0],
|
|
['output', 'number', 'integerOnly' => true],
|
|
|
|
['steal_count', 'default', 'value' => 0],
|
|
['steal_count', 'number', 'integerOnly' => true],
|
|
|
|
|
|
['created_at', 'default', 'value' => 0],
|
|
['updated_at', 'default', 'value' => 0],
|
|
['start_time', 'default', 'value' => 0],
|
|
['gather_time', 'default', 'value' => 0],
|
|
];
|
|
}
|
|
|
|
public static function findByID($id)
|
|
{
|
|
return self::findOne(['id' => $id]);
|
|
}
|
|
|
|
/**
|
|
* 生成要发送给客户的数据
|
|
* @return array
|
|
*/
|
|
public function genClientData()
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'crop_config_id' => $this->crop_config_id,
|
|
'start_time' => $this->start_time,
|
|
'gather_time' => $this->gather_time,
|
|
'is_ripe' => $this->is_ripe,
|
|
'num' => $this->num,
|
|
'has_gather' => $this->has_gather,
|
|
'is_output' => $this->is_output,
|
|
];
|
|
}
|
|
|
|
} |