63 lines
1.4 KiB
PHP
Executable File
63 lines
1.4 KiB
PHP
Executable File
<?php
|
|
/**
|
|
* 轮播模型
|
|
*/
|
|
|
|
namespace app\common\model;
|
|
|
|
use think\model\concern\SoftDelete;
|
|
|
|
class Slide extends Model
|
|
{
|
|
use SoftDelete;
|
|
public $softDelete = true;
|
|
protected $name = 'slide';
|
|
protected $autoWriteTimestamp = true;
|
|
|
|
//可搜索字段
|
|
protected $searchField = ['name',];
|
|
|
|
public $jumpType = [
|
|
['id' => 1, 'name' => '商品'],
|
|
['id' => 3, 'name' => '网址'],
|
|
];
|
|
|
|
public $BannerList = [
|
|
['bm' => 'carousel', 'name' => '首页轮播图','cc'=>'750*500'],
|
|
['bm' => 'merchant', 'name' => '首页精品推荐','cc'=>'710*289'],
|
|
['bm' => 'goods', 'name' => '产品列表','cc'=>'710*240'],
|
|
];
|
|
|
|
|
|
public function getJumpTypeTextAttr($value, $data)
|
|
{
|
|
$result = '--';
|
|
foreach ($this->jumpType as $item) {
|
|
if ($data['jump_type'] == $item['id']) {
|
|
$result = $item['name'];
|
|
break;
|
|
}
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
|
|
public function getJumpTargetTextAttr($value, $data)
|
|
{
|
|
$result = '--';
|
|
switch ($data['jump_type']) {
|
|
case 1:
|
|
$result = Goods::where('id', $data['jump_target'])->value('name');
|
|
break;
|
|
case 3:
|
|
$result = $data['jump_target'];
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
|
|
}
|