Files
ntonpower/app/index/model/Brand.php
2026-10-14 14:00:29 +08:00

76 lines
2.2 KiB
PHP

<?php
declare (strict_types = 1);
namespace app\index\model;
/**
*
*/
class Brand extends BaseModel
{
/**
* 获取首页品牌矩阵
* @param $data
* @param $languageId
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getBrandList($languageId,$data):array
{
$where = [
'site_id' => $languageId,
'status' => 0,
];
if (isset($data['brand_type_id']) && $data['brand_type_id'] != 0) {
$where['brand_type_id'] = $data['brand_type_id'];
}
return $this->where($where)->order('sort','desc')->select()->toArray();
}
/**
* 获取品牌矩阵分类
* @param $languageId
* @param $data
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getBrandTypeList($languageId,$data):array
{
$result = BrandType::where('site_id',$languageId)->select()->toArray();
if (!empty($result)) {
$arr[] = [
'id' => 0,
'name' => '全部',
];
$result = array_merge($arr,$result);
foreach ($result as $key => $item) {
$result[$key]['is_display'] = !empty($data) ? isset($data['brand_type_id']) && $data['brand_type_id'] == $item['id'] : $item['id'] == 0;
}
return $result;
}
return [];
}
/**
* @param $languageId
* @param $data
* @return array|string[]
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getBrandBanner($languageId,$data):array
{
$space = AdvertiseSpace::where('name',$data)->select()->toArray();
if (!empty($space)) {
return $this->getBanner($languageId,$space[0]['id']);
}
return ['image' => ''];
}
}