| 123456789101112131415161718192021222324252627282930313233 |
- <?php
- namespace App\Models;
- use App\Constants\Util;
- class Banner extends BaseModel
- {
- public const TYPE_BOTH = 'both';
- protected $table = 'banner';
- protected $fillable = ['title', 'image', 'link' ,'type' ,'sort' ,'cny_rate','lang', 'status', 'click_type', 'link_pc', 'link_h5'];
- protected $casts = ['status' => 'integer'];
- protected $appends = ['types'];
- protected function getTypesAttribute(): array
- {
- return match ($this->type) {
- self::TYPE_BOTH => ['app', 'pc'],
- 'app', 'pc' => [$this->type],
- default => [],
- };
- }
- protected function getImageAttribute($value)
- {
- return Util::ensureUrl($value);
- }
- protected function setImageAttribute($value)
- {
- $this->attributes['image'] = Util::replacePartInUrl($value);
- }
- }
|