海南旅游SAAS
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.

39 lines
844 B

  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Factories\HasFactory;
  4. use Illuminate\Database\Eloquent\SoftDeletes;
  5. /**
  6. * 供应商产品
  7. * Class Product
  8. * @package App\Models
  9. */
  10. class Product extends BaseModel
  11. {
  12. use HasFactory, SoftDeletes;
  13. protected $appends = ['picture'];
  14. // 获取所有产品图片
  15. public function getPicturesAttribute($value): array
  16. {
  17. $pictures = $value ? json_decode($value, true) : [];
  18. foreach ($pictures as &$v) {
  19. $v = $this->host . $v;
  20. }
  21. $this->append('picture');
  22. return $pictures;
  23. }
  24. // 获取第一张产品图片
  25. public function getPictureAttribute($value): string
  26. {
  27. return $this->pictures[0] ?? '';
  28. }
  29. /*public function productInfo()
  30. {
  31. return $this->hasOne(ProductInfo::class);
  32. }*/
  33. }