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.
|
|
<?php
namespace App\Models\v3;
use Dcat\Admin\Traits\HasDateTimeFormatter;use Illuminate\Database\Eloquent\SoftDeletes;use Illuminate\Database\Eloquent\Model;
class Banners extends Model{ use HasDateTimeFormatter; use SoftDeletes;
protected $table = 'lanzu_banners'; protected $dateFormat = 'U';
protected $appends = [ 'cover_url', 'cover_type_text', 'path_type_text', 'type_text', 'status_text' ]; 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); }
public function getCoverTypeTextAttribute($value) { $value = $value ? $value : $this->cover_type; return isset(self::$_coverType[$value]) ? self::$_coverType[$value] : ''; } public function getPathTypeTextAttribute($value) { $value = $value ? $value : $this->path_type; return isset(self::$_pathType[$value]) ? self::$_pathType[$value] : ''; } public function getTypeTextAttribute($value) { $value = $value ? $value : $this->type; return isset(self::$_type[$value]) ? self::$_type[$value] : ''; } public function getStatusTextAttribute($value) { $value = $value ? $value : $this->stauts; return isset(self::$_status[$value]) ? self::$_status[$value] : ''; } /** * 处理旧图片 * @param $value * @return string */ public function imageUrl($value) { if(strripos($value,"http") === false){ return env('OSS_IMG_HOST').'/'.$value; }else{ return $value; } }}
|