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

45 lines
1.0 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. public static $_coverType = [1=>'图片', 2=>'视频'];
  16. public static $_pathType = ['page'=>'page','webview'=>'webview','applet'=>'applet'];
  17. public static $_type = [1=>'首页'];
  18. public static $_status = ['禁用', '正常'];
  19. public function getCoverUrlAttribute($value)
  20. {
  21. $value = $value ? $value : $this->cover;
  22. return $this->imageUrl($value);
  23. }
  24. /**
  25. * 处理旧图片
  26. * @param $value
  27. * @return string
  28. */
  29. public function imageUrl($value)
  30. {
  31. if(strripos($value,"http") === false){
  32. return env('OSS_IMG_HOST').'/'.$value;
  33. }else{
  34. return $value;
  35. }
  36. }
  37. }