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