65 lines
1.7 KiB
PHP
65 lines
1.7 KiB
PHP
<?php
|
|
declare (strict_types = 1);
|
|
|
|
namespace app\index\model;
|
|
|
|
/**
|
|
* @mixin \think\Model
|
|
*/
|
|
class ReCenter extends BaseModel
|
|
{
|
|
protected $name = 'resource';
|
|
|
|
/**
|
|
* 获取页面banner
|
|
* @param $languageId
|
|
* @param $data
|
|
* @return array
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
*/
|
|
public function getResourceBanner($languageId,$data):array
|
|
{
|
|
$space = AdvertiseSpace::where('name',$data)->select()->toArray();
|
|
if (!empty($space)) {
|
|
return $this->getBanner($languageId,$space[0]['id']);
|
|
}
|
|
return ['image' => ''];
|
|
}
|
|
|
|
/**
|
|
* @param $languageId
|
|
* @param $data
|
|
* @return array
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
*/
|
|
public function getResourceList($languageId,$data):array
|
|
{
|
|
return $this->where('site_id',$languageId)->where('status',0)->order('sort','desc')->select()->toArray();
|
|
}
|
|
|
|
|
|
/**
|
|
* 获取上一篇,下一篇
|
|
*/
|
|
public function getPreNexInfo($data)
|
|
{
|
|
if (isset($data['id'])) {
|
|
// 下一条
|
|
$next = $this->field(['id','title'])->where('id','>',$data['id'])->limit(1)->select()->toArray();
|
|
// 上一条
|
|
$pre = $this->field(['id','title'])->where('id','<',$data['id'])->limit(1)->select()->toArray();
|
|
|
|
return [
|
|
'pre' => empty($pre) ? [] : $pre[0],
|
|
'next' => empty($next) ? [] : $next[0]
|
|
];
|
|
}
|
|
return [];
|
|
}
|
|
|
|
}
|