Initial commit
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\service;
|
||||
|
||||
use app\apis\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 [
|
||||
'default' => function ($params) {
|
||||
return [
|
||||
'filters' => [
|
||||
['field' => 'status', 'operator' => '=', 'value' => '1']
|
||||
],
|
||||
'fields' => ['id', 'key', 'status', 'created_at', 'updated_at'],
|
||||
'relations' => [
|
||||
'translation' => ['agreement_id', 'title', 'content']
|
||||
],
|
||||
'sorts' => [
|
||||
['field' => 'id', 'direction' => 'desc']
|
||||
],
|
||||
'pagination' => [
|
||||
'page' => $params['page'] ?? 1,
|
||||
'per_page' => $params['per_page'] ?? 10,
|
||||
]
|
||||
];
|
||||
},
|
||||
'one' => function ($params) {
|
||||
return [
|
||||
'filters' => [
|
||||
['field' => 'status', 'operator' => '=', 'value' => '1'],
|
||||
['field' => 'key', 'operator' => '=', 'value' => 'privacy_web']
|
||||
],
|
||||
'fields' => ['id', 'key', 'status', 'created_at', 'updated_at'],
|
||||
'relations' => [
|
||||
'translation' => ['agreement_id', 'title', 'content']
|
||||
],
|
||||
'sorts' => [
|
||||
['field' => 'id', 'direction' => 'desc']
|
||||
],
|
||||
'pagination' => [
|
||||
'page' => $params['page'] ?? 1,
|
||||
'per_page' => $params['per_page'] ?? 10,
|
||||
]
|
||||
];
|
||||
}
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user