1234567891011121314151617181920212223242526272829 |
- <?php
- namespace app\common\model;
- use think\Db;
- use think\db\Query;
- use think\Model;
- /**
- * @method static Query|static hot($hot=1)
- */
- class Tag extends Model
- {
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = false;
- public function video(){
- return $this->belongsToMany(Video::class,'video_tag');
- }
- protected static function init()
- {
- self::afterDelete(function (self $tag){
- VideoTag::tag($tag['id'])->delete();
- });
- }
- public function scopeHot(Query $query,$hot=1){
- $query->where('is_hot',$hot);
- }
- }
|