链街Dcat后台
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.

34 lines
747 B

6 years ago
6 years ago
6 years ago
  1. <?php
  2. namespace App\Models;
  3. use Dcat\Admin\Traits\HasDateTimeFormatter;
  4. use Illuminate\Database\Eloquent\SoftDeletes;
  5. use Illuminate\Database\Eloquent\Model;
  6. class Goods extends Model
  7. {
  8. use HasDateTimeFormatter;
  9. use SoftDeletes;
  10. protected $table = 'lanzu_goods';
  11. protected $dateFormat = 'U';
  12. protected $appends = [
  13. 'cover_img_url',
  14. ];
  15. public function getCoverImgUrlAttribute($value)
  16. {
  17. $value = $value ? $value : $this->cover_img;
  18. return $this->imageUrl($value);
  19. }
  20. // 处理图片
  21. public function imageUrl($value)
  22. {
  23. if(strripos($value,"http") === false){
  24. return env('OSS_IMG_HOST').'/'.$value;
  25. }else{
  26. return $value;
  27. }
  28. }
  29. }