59 lines
1.9 KiB
PHP
59 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace app\apis\service;
|
|
|
|
use app\apis\model\AgreementTranslationModel;
|
|
use app\mzl\common\services\BaseService;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class AgreementTranslationService extends BaseService
|
|
{
|
|
/**
|
|
* 定义模型
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getModel(): string
|
|
{
|
|
return AgreementTranslationModel::class;
|
|
}
|
|
|
|
/**
|
|
* 多场景配置
|
|
*/
|
|
public function queryScenes(): array
|
|
{
|
|
return [
|
|
// 'default' => function ($params) {
|
|
// $keyword = $params['keyword'] ?? '';
|
|
// return [
|
|
// 'filters' => [
|
|
// ['field' => '***', 'operator' => '=', 'value' => '***']
|
|
// ],
|
|
// 'fields' => ['id'],
|
|
// 'relations' => [],
|
|
// 'custom' => function(Builder $q) use ($keyword) {
|
|
// // 示例
|
|
// if ($keyword) {
|
|
// $q->where(function($q2) use($keyword) {
|
|
// $q2->whereHas('***', function($q3) use($keyword) {
|
|
// $q3->where('***', 'like', "%{$keyword}%");
|
|
// })->orWhereHas('***', function($q4) use($keyword) {
|
|
// $q4->where('***', 'like', "%{$keyword}%");
|
|
// });
|
|
// });
|
|
// }
|
|
// },
|
|
// 'sorts' => [
|
|
// ['field' => 'created_at', 'direction' => 'desc']
|
|
// ],
|
|
// 'pagination' => [
|
|
// 'page' => $params['page'] ?? 1,
|
|
// 'per_page' => $params['per_page'] ?? 10,
|
|
// ]
|
|
// ];
|
|
// }
|
|
];
|
|
}
|
|
} |