45 lines
927 B
PHP
45 lines
927 B
PHP
<?php
|
|
|
|
namespace app\common\service;
|
|
|
|
use app\common\validate\UsedCarValidate;
|
|
use app\common\traits\crud\CrudServiceTrait;
|
|
use app\common\model\UsedCar;
|
|
use support\exception\BusinessException;
|
|
use support\Request;
|
|
|
|
class UsedCarService
|
|
{
|
|
|
|
use CrudServiceTrait;
|
|
|
|
/**
|
|
* 指定当前要操作的模型
|
|
*/
|
|
protected string $modelClass = UsedCar::class;
|
|
|
|
/**
|
|
* 验证器
|
|
*/
|
|
protected $validator = UsedCarValidate::class;
|
|
|
|
/**
|
|
* 获取验证器
|
|
*/
|
|
public function getValidator()
|
|
{
|
|
return new $this->validator;
|
|
}
|
|
|
|
|
|
public function beforeServiceStore($data, Request $request): array
|
|
{
|
|
if(empty($data['product_name'])){
|
|
throw new BusinessException('产品名称不能为空');
|
|
}
|
|
if(empty($data['images'])){
|
|
throw new BusinessException('产品图片不能为空');
|
|
}
|
|
return $data;
|
|
}
|
|
} |