链街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.

48 lines
1.1 KiB

  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 Banner extends Model
  7. {
  8. use HasDateTimeFormatter;
  9. use SoftDeletes;
  10. protected $table = 'lanzu_banners';
  11. protected $dateFormat = 'U';
  12. protected $appends = [
  13. 'cover_url',
  14. ];
  15. protected $casts = [
  16. 'market_ids'=>'array',
  17. ];
  18. public static $_coverType = [1=>'图片', 2=>'视频'];
  19. public static $_pathType = ['page'=>'page','webview'=>'webview','applet'=>'applet'];
  20. public static $_type = [1=>'首页'];
  21. public static $_status = ['禁用', '正常'];
  22. public function getCoverUrlAttribute($value)
  23. {
  24. $value = $value ? $value : $this->cover;
  25. return $this->imageUrl($value);
  26. }
  27. /**
  28. * 处理旧图片
  29. * @param $value
  30. * @return string
  31. */
  32. public function imageUrl($value)
  33. {
  34. if(strripos($value,"http") === false){
  35. return env('OSS_IMG_HOST').'/'.$value;
  36. }else{
  37. return $value;
  38. }
  39. }
  40. }