Tag.php 597 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace app\common\model;
  3. use think\Db;
  4. use think\db\Query;
  5. use think\Model;
  6. /**
  7. * @method static Query|static hot($hot=1)
  8. */
  9. class Tag extends Model
  10. {
  11. // 自动写入时间戳字段
  12. protected $autoWriteTimestamp = false;
  13. public function video(){
  14. return $this->belongsToMany(Video::class,'video_tag');
  15. }
  16. protected static function init()
  17. {
  18. self::afterDelete(function (self $tag){
  19. VideoTag::tag($tag['id'])->delete();
  20. });
  21. }
  22. public function scopeHot(Query $query,$hot=1){
  23. $query->where('is_hot',$hot);
  24. }
  25. }