49 lines
1.4 KiB
PHP
49 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace app\applet\service;
|
|
|
|
use app\applet\model\AgreementModel;
|
|
use app\mzl\common\services\BaseService;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class AgreementService extends BaseService
|
|
{
|
|
/**
|
|
* 定义模型
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getModel(): string
|
|
{
|
|
return AgreementModel::class;
|
|
}
|
|
|
|
/**
|
|
* 多场景配置
|
|
*/
|
|
public function queryScenes(): array
|
|
{
|
|
return [
|
|
'one' => function ($params) {
|
|
return [
|
|
'filters' => [
|
|
['field' => 'key', 'operator' => '=', 'value' => $params['key']],
|
|
['field' => 'status', 'operator' => '=', 'value' => 1]
|
|
],
|
|
'fields' => ['id', 'key', 'status', 'created_at', 'updated_at'],
|
|
'relations' => [
|
|
'translation' => ['agreement_id', 'title', 'content']
|
|
],
|
|
// 'sorts' => [
|
|
// ['field' => 'created_at', 'direction' => 'desc']
|
|
// ],
|
|
// 'pagination' => [
|
|
// 'page' => $params['page'] ?? 1,
|
|
// 'per_page' => $params['per_page'] ?? 10,
|
|
// ]
|
|
];
|
|
}
|
|
];
|
|
}
|
|
} |