| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- declare(strict_types=1);
- namespace App\Model;
- use Hyperf\Database\Model\SoftDeletes;
- class VideoModel extends BaseModel
- {
- use SoftDeletes; //此表为假删,需有字段"deleted_at"
- /**
- * 表名.
- *
- * @var string
- */
- protected $table = 'video';
- public function type()
- {
- return $this->belongsToMany(
- TypeModel::class,
- 'type_video',
- 'video_id',
- 'type_id'
- );
- }
- public function user()
- {
- return $this->hasOne(UserModel::class, 'code', 'uid')
- ->select(['code','nick','avatar']);
- }
- public function perfect()
- {
- return $this->hasMany(VideoPerfectModel::class, 'video_id', 'id');
- }
- public function tags()
- {
- return $this->hasMany(TypeVideoModel::class, 'video_id', 'id');
- }
- /**
- * 统一处理0x0的情况.
- * @param $value
- * @return string
- */
- public function getResolutionAttribute($value)
- {
- if ($value == '0x0') {
- return '1x1';
- } else {
- return $value;
- }
- }
- }
|