广告位
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\service;
|
||||
|
||||
use app\apis\model\AdpModel;
|
||||
use app\mzl\common\services\BaseService;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AdpService extends BaseService
|
||||
{
|
||||
/**
|
||||
* 定义模型
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModel(): string
|
||||
{
|
||||
return AdpModel::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* 多场景配置
|
||||
*/
|
||||
public function queryScenes(): array
|
||||
{
|
||||
return [
|
||||
'default' => function ($params) {
|
||||
return [
|
||||
'filters' => $params['filters'],
|
||||
'fields' => ['id', 'status', 'sort', 'creater', 'created_at', 'updated_at'],
|
||||
'relations' => [
|
||||
'translation' => ['adp_id', 'title'],
|
||||
'ad' => ['id', 'image', 'status', 'sort', 'creater', 'created_at', 'updated_at'],
|
||||
'ad.translation' => ['ad_id', 'alt', 'title'],
|
||||
],
|
||||
'sorts' => [
|
||||
['field' => 'sort', 'direction' => 'desc'],
|
||||
['field' => 'created_at', 'direction' => 'desc'],
|
||||
],
|
||||
'pagination' => [
|
||||
'page' => $params['page'] ?? 1,
|
||||
'per_page' => $params['per_page'] ?? 10,
|
||||
]
|
||||
];
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user