123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- /**
- * @copyright Copyright (c) 2017 https://www.sapixx.com All rights reserved.
- * @license Licensed (http://www.apache.org/licenses/LICENSE-2.0).
- * @author pillar<ltmn@qq.com>
- * 产品管理
- */
- namespace app\bestbao\model;
- use think\Model;
- class BestbaoProduct extends Model{
- //开通好店订单
- public function category(){
- return $this->hasOne('BestbaoCategory','id','category_id');
- }
- //搜索
- public function searchTitleAttr($query, $value, $data){
- if(!empty($value)){
- $query->where('title','like', $value .'%');
- }
- }
- //添加或编辑
- public static function edit($param){
- $data['category_id'] = $param['category_id'];
- $data['code'] = $param['code'];
- $data['title'] = $param['title'];
- $data['images'] = $param['images'];
- $data['note'] = $param['note'];
- $data['update_time'] = time();
- if(isset($param['id'])){
- return self::update($data,['id'=>(int)$param['id']]);
- }else{
- $data['create_time'] = time();
- $data['member_miniapp_id'] = $param['member_miniapp_id'];
- return self::insert($data);
- }
- }
- }
|