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
48 lines
1.1 KiB
<?php
|
|
|
|
namespace App\Models\v3;
|
|
|
|
use Dcat\Admin\Traits\HasDateTimeFormatter;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Banner extends Model
|
|
{
|
|
use HasDateTimeFormatter;
|
|
use SoftDeletes;
|
|
|
|
protected $table = 'lanzu_banners';
|
|
protected $dateFormat = 'U';
|
|
|
|
protected $appends = [
|
|
'cover_url',
|
|
];
|
|
protected $casts = [
|
|
'market_ids'=>'array',
|
|
];
|
|
|
|
public static $_coverType = [1=>'图片', 2=>'视频'];
|
|
public static $_pathType = ['page'=>'page','webview'=>'webview','applet'=>'applet'];
|
|
public static $_type = [1=>'首页'];
|
|
public static $_status = ['禁用', '正常'];
|
|
|
|
public function getCoverUrlAttribute($value)
|
|
{
|
|
$value = $value ? $value : $this->cover;
|
|
return $this->imageUrl($value);
|
|
}
|
|
|
|
/**
|
|
* 处理旧图片
|
|
* @param $value
|
|
* @return string
|
|
*/
|
|
public function imageUrl($value)
|
|
{
|
|
if(strripos($value,"http") === false){
|
|
return env('OSS_IMG_HOST').'/'.$value;
|
|
}else{
|
|
return $value;
|
|
}
|
|
}
|
|
}
|