68 lines
1.8 KiB
PHP
68 lines
1.8 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace app\model;
|
||
|
|
|
||
|
|
use app\model\Base;
|
||
|
|
/**
|
||
|
|
* @property integer $id 主键(ID) - 无注释
|
||
|
|
* @property integer $category_id 分类ID
|
||
|
|
* @property string $country 国别
|
||
|
|
* @property integer $score 积分
|
||
|
|
* @property integer $start_time 开始时间
|
||
|
|
* @property integer $end_time 结束时间
|
||
|
|
* @property string $title 标题
|
||
|
|
* @property integer $total 题目数量
|
||
|
|
* @property string $body 题目详情
|
||
|
|
* @property integer $created_at 创建时间
|
||
|
|
* @property integer $updated_at 更新时间
|
||
|
|
* @property integer $status 状态
|
||
|
|
*/
|
||
|
|
class Questionnaire extends Base
|
||
|
|
{
|
||
|
|
|
||
|
|
function setBodyAttr($v='',$row=[]){
|
||
|
|
if(is_array($v) || is_object($v)){
|
||
|
|
return json_encode($v,JSON_UNESCAPED_UNICODE);
|
||
|
|
}
|
||
|
|
return '[]';
|
||
|
|
}
|
||
|
|
function setStartTimeAttr($v='',$row=[]){
|
||
|
|
if($v){
|
||
|
|
return strtotime($v);
|
||
|
|
}
|
||
|
|
return $v;
|
||
|
|
}
|
||
|
|
// function getStartTimeAttr($v='',$row=[]){
|
||
|
|
// if($v){
|
||
|
|
// return is_numeric($v) ? date('Y-m-d H:i:s',$v) : $v;
|
||
|
|
// }
|
||
|
|
// return '';
|
||
|
|
// }
|
||
|
|
function setEndTimeAttr($v='',$row=[]){
|
||
|
|
if($v){
|
||
|
|
return strtotime($v);
|
||
|
|
}
|
||
|
|
return $v;
|
||
|
|
}
|
||
|
|
// function getEndTimeAttr($v='',$row=[]){
|
||
|
|
// if($v){
|
||
|
|
// return is_numeric($v) ? date('Y-m-d H:i:s',$v) : $v;
|
||
|
|
// }
|
||
|
|
// return '';
|
||
|
|
// }
|
||
|
|
public function getCategoryOptions(){
|
||
|
|
return Category::where('status','1')->where('type','questionnaire')->column('id,title');
|
||
|
|
}
|
||
|
|
function getBodyAttr($v='',$row=[]){
|
||
|
|
if($v){
|
||
|
|
return json_decode($v,true);
|
||
|
|
}
|
||
|
|
return [];
|
||
|
|
}
|
||
|
|
|
||
|
|
public function category()
|
||
|
|
{
|
||
|
|
return $this->belongsTo('Category', 'category_id', 'id');//->setEagerlyType(0);
|
||
|
|
}
|
||
|
|
}
|