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.
39 lines
709 B
39 lines
709 B
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
class Special extends BaseModel
|
|
{
|
|
use HasFactory;
|
|
|
|
//轮播图片
|
|
public function getPictureAttribute($value): array
|
|
{
|
|
$value = json_decode($value, true);
|
|
if (is_array($value)) {
|
|
foreach ($value as &$v) {
|
|
$v = $v ? $this->host . $v : '';
|
|
}
|
|
}
|
|
return $value;
|
|
}
|
|
|
|
//首页广告图
|
|
public function getPictureAdAttribute($value): string
|
|
{
|
|
return $value ? $this->host . $value : '';
|
|
}
|
|
|
|
//代理商产品ID
|
|
public function getAgentProductIdAttribute($value)
|
|
{
|
|
return explode(',', $value);
|
|
}
|
|
|
|
public function agentProduct()
|
|
{
|
|
return $this->belongsTo(AgentProduct::class);
|
|
}
|
|
}
|