You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

50 lines
818 B

  1. <?php
  2. namespace app\admin\model\unishop;
  3. use think\Model;
  4. class Ads extends Model
  5. {
  6. //数据库
  7. protected $connection = 'database';
  8. // 表名
  9. protected $name = 'unishop_ads';
  10. // 自动写入时间戳字段
  11. protected $autoWriteTimestamp = 'int';
  12. // 定义时间戳字段名
  13. protected $createTime = 'createtime';
  14. protected $updateTime = 'updatetime';
  15. protected $deleteTime = false;
  16. // 追加属性
  17. protected $append = [
  18. ];
  19. protected static function init()
  20. {
  21. self::afterInsert(function ($row) {
  22. $pk = $row->getPk();
  23. $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
  24. });
  25. }
  26. public function product(){
  27. return $this->belongsTo('product')->field('id,title');
  28. }
  29. }