init: 项目初始代码
This commit is contained in:
75
app/index/model/Brand.php
Normal file
75
app/index/model/Brand.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?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' => ''];
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user