新建订单控制器
/apps/index/controller/Order.php
~~~
<?php
namespace app\index\controller;
use app\index\model\Order as OrderModel;
use app\index\model\User as UserModel;
use app\index\model\Template as TplModel;
use think\Controller;
use think\Request;
use think\Db;
use think\Cache;
class Order extends Controller
{
public function index($ap=0)
{
}
}
~~~
编辑订单模型
/apps/index/model/Order.php
~~~
protected $type = [
'stime' => 'timestamp',
'etime' => 'timestamp',
];
// 自动完成显示排序
protected $insert = ['displayorder' => 0];
// 订购开始结束时间 读取器 修改器
protected function getStimeAttr($stime)
{
return date('Y-m-d',$stime);
}
protected function setStimeAttr($value)
{
return strtotime($value);
}
protected function getEtimeAttr($etime)
{
return date('Y-m-d',$etime);
}
protected function setEtimeAttr($value)
{
return strtotime($value);
}
// 关联产品
public function template()
{
return $this->belongsTo('Template','tid','tid');
}
~~~