73 lines
2.1 KiB
PHP
73 lines
2.1 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace app\model;
|
||
|
|
|
||
|
|
use app\model\Base;
|
||
|
|
/**
|
||
|
|
* 产品模型
|
||
|
|
*
|
||
|
|
* @package app\model
|
||
|
|
* @property integer $id 主键(ID) - 无注释
|
||
|
|
* @property string $title 标题
|
||
|
|
* @property string $image 封面
|
||
|
|
* @property float $price 价格
|
||
|
|
* @property float $accelerate_price 加速包价格
|
||
|
|
* @property integer $min_score 最少获得积分
|
||
|
|
* @property integer $max_score 最多获得积分
|
||
|
|
* @property integer $sales 銷售量
|
||
|
|
* @property integer $total 问卷数量
|
||
|
|
* @property integer $assign_count 每日分配
|
||
|
|
* @property integer $accelerate_assign_times 加速包分配次数
|
||
|
|
* @property integer $accelerate_assign_count 加速包每日分配
|
||
|
|
* @property integer $user_quantity 用户累计限购
|
||
|
|
* @property string $memo 备注
|
||
|
|
* @property integer $weight 权重
|
||
|
|
* @property integer $created_at 创建时间
|
||
|
|
* @property integer $updated_at 更新时间
|
||
|
|
* @property integer $status 状态
|
||
|
|
*/
|
||
|
|
class Product extends Base
|
||
|
|
{
|
||
|
|
function getCycleTypeList(){
|
||
|
|
return [
|
||
|
|
'hour' => '小时',
|
||
|
|
'day' => '天',
|
||
|
|
];
|
||
|
|
}
|
||
|
|
public function getCategoryOptions($type='product'){
|
||
|
|
return Category::where('status','1')->where('type',$type)->column('id,title');
|
||
|
|
}
|
||
|
|
public function category()
|
||
|
|
{
|
||
|
|
return $this->belongsTo('Category', 'category_id', 'id');//->setEagerlyType(0);
|
||
|
|
}
|
||
|
|
public function questionnaire()
|
||
|
|
{
|
||
|
|
return $this->belongsTo('Questionnaire', 'questionnaire_id', 'id');//->setEagerlyType(0);
|
||
|
|
}
|
||
|
|
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 '';
|
||
|
|
// }
|
||
|
|
}
|