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.

33 lines
914 B

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