BestbaoProduct.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2017 https://www.sapixx.com All rights reserved.
  4. * @license Licensed (http://www.apache.org/licenses/LICENSE-2.0).
  5. * @author pillar<ltmn@qq.com>
  6. * 产品管理
  7. */
  8. namespace app\bestbao\model;
  9. use think\Model;
  10. class BestbaoProduct extends Model{
  11. //开通好店订单
  12. public function category(){
  13. return $this->hasOne('BestbaoCategory','id','category_id');
  14. }
  15. //搜索
  16. public function searchTitleAttr($query, $value, $data){
  17. if(!empty($value)){
  18. $query->where('title','like', $value .'%');
  19. }
  20. }
  21. //添加或编辑
  22. public static function edit($param){
  23. $data['category_id'] = $param['category_id'];
  24. $data['code'] = $param['code'];
  25. $data['title'] = $param['title'];
  26. $data['images'] = $param['images'];
  27. $data['note'] = $param['note'];
  28. $data['update_time'] = time();
  29. if(isset($param['id'])){
  30. return self::update($data,['id'=>(int)$param['id']]);
  31. }else{
  32. $data['create_time'] = time();
  33. $data['member_miniapp_id'] = $param['member_miniapp_id'];
  34. return self::insert($data);
  35. }
  36. }
  37. }