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.

41 lines
965 B

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. <?php
  2. namespace App\Model\v3;
  3. use App\Constants\v3\OssThumbnail;
  4. use App\Model\Model;
  5. use App\Service\v3\Interfaces\AttachmentServiceInterface;
  6. use Hyperf\Database\Model\SoftDeletes;
  7. use Hyperf\Di\Annotation\Inject;
  8. class GoodsBanner extends Model
  9. {
  10. /**
  11. * @Inject
  12. * @var AttachmentServiceInterface
  13. */
  14. protected $attachmentService;
  15. use SoftDeletes;
  16. protected $table = 'lanzu_goods_banners';
  17. protected $appends = [
  18. 'banner_url',
  19. ];
  20. protected $fillable = [
  21. 'id',
  22. 'goods_id',
  23. 'path',
  24. 'type'
  25. ];
  26. public function getBannerUrlAttribute()
  27. {
  28. if($this->attributes['type'] == 1){
  29. return $this->attachmentService->switchImgToAliOss($this->attributes['path'], OssThumbnail::THUMBNAIL_600_Q90);
  30. }elseif ($this->attributes['type'] == 2){
  31. return $this->attachmentService->switchImgToAliOss($this->attributes['path']);
  32. }
  33. }
  34. }