|
@@ -1123,21 +1123,27 @@ class WebsiteController extends AbstractController
|
|
|
$websiteIdKey = ['website_id' => '']; // 创建一个只包含 website_id 键的数组
|
|
|
$diff = array_diff_key($requireData, $websiteIdKey); // 获取 $requireData 中除了 website_id 以外的其他键值对
|
|
|
if(!empty($diff)){
|
|
|
+ $validationRules = [
|
|
|
+ 'page_type' => 'required|array|min:2',
|
|
|
+ 'statement' => 'required',
|
|
|
+ 'organizer' => 'required',
|
|
|
+ 'copyright_information' => 'required',
|
|
|
+ 'project_logo' => 'required|image|max:500',
|
|
|
+ 'record_number' => 'required',
|
|
|
+ 'record_number_url' => 'required',
|
|
|
+ 'icp_number' => 'required',
|
|
|
+ 'icp_number_url' => 'required',
|
|
|
+ 'customer_service_qq' => 'required',
|
|
|
+ 'communications' => 'required'
|
|
|
+ ];
|
|
|
+
|
|
|
+ if (isset($requireData['company_logo'])) {
|
|
|
+ $validationRules['company_logo'] = 'image|max:500';
|
|
|
+ }
|
|
|
+
|
|
|
$validator = $this->validationFactory->make(
|
|
|
$requireData,
|
|
|
- [
|
|
|
- 'page_type' =>'required|array|min:2',
|
|
|
- 'statement' =>'required',
|
|
|
- 'organizer' =>'required',
|
|
|
- 'copyright_information' =>'required',
|
|
|
- 'project_logo' =>'required',
|
|
|
- 'record_number' =>'required',
|
|
|
- 'record_number_url' =>'required',
|
|
|
- 'icp_number' =>'required',
|
|
|
- 'icp_number_url' =>'required',
|
|
|
- 'customer_service_qq' =>'required',
|
|
|
- 'communications' =>'required'
|
|
|
- ],
|
|
|
+ $validationRules,
|
|
|
[
|
|
|
'page_type.required' => '页面类型不能为空',
|
|
|
'page_type.array' => '页面类型必须是数组',
|
|
@@ -1146,15 +1152,20 @@ class WebsiteController extends AbstractController
|
|
|
'organizer.required' => '主办单位不能为空',
|
|
|
'copyright_information.required' => '版权信息不能为空',
|
|
|
'project_logo.required' => '项目logo不能为空',
|
|
|
+ 'project_logo.image' => '项目logo必须是图片',
|
|
|
+ 'project_logo.max' => '项目logo大小不能超过500kb',
|
|
|
'record_number.required' => '网安备案号不能为空',
|
|
|
'record_number_url.required' => '网安备案号链接不能为空',
|
|
|
'icp_number.required' => '网站备案号不能为空',
|
|
|
'icp_number_url.required' => '网站备案号链接不能为空',
|
|
|
'customer_service_qq.required' => '客服qq不能为空',
|
|
|
- 'communications.required' => '通联qq不能为空'
|
|
|
+ 'communications.required' => '通联qq不能为空',
|
|
|
+ 'company_logo.image' => '公司logo必须是图片',
|
|
|
+ 'company_logo.max' => '公司logo大小不能超过500kb'
|
|
|
]
|
|
|
);
|
|
|
- if ($validator->fails()){
|
|
|
+
|
|
|
+ if ($validator->fails()) {
|
|
|
$errorMessage = $validator->errors()->first();
|
|
|
return Result::error($errorMessage);
|
|
|
}
|
|
@@ -1196,24 +1207,28 @@ class WebsiteController extends AbstractController
|
|
|
|
|
|
{
|
|
|
$requireData = $this->request->all();
|
|
|
+ $validationRules = [
|
|
|
+ 'page_type' => 'required|array|min:2',
|
|
|
+ 'statement' => 'required',
|
|
|
+ 'organizer' => 'required',
|
|
|
+ 'copyright_information' => 'required',
|
|
|
+ 'project_logo' => 'required|image|max:500',
|
|
|
+ 'record_number' => 'required',
|
|
|
+ 'record_number_url' => 'required',
|
|
|
+ 'icp_number' => 'required',
|
|
|
+ 'icp_number_url' => 'required',
|
|
|
+ 'customer_service_qq' => 'required',
|
|
|
+ 'communications' => 'required'
|
|
|
+ ];
|
|
|
+
|
|
|
+ if (isset($requireData['company_logo'])) {
|
|
|
+ $validationRules['company_logo'] = 'image|max:500';
|
|
|
+ }
|
|
|
+
|
|
|
$validator = $this->validationFactory->make(
|
|
|
$requireData,
|
|
|
+ $validationRules,
|
|
|
[
|
|
|
- 'website_id' =>'required',
|
|
|
- 'page_type' =>'required|array|min:2',
|
|
|
- 'statement' =>'required',
|
|
|
- 'organizer' =>'required',
|
|
|
- 'copyright_information' =>'required',
|
|
|
- 'project_logo' =>'required',
|
|
|
- 'record_number' =>'required',
|
|
|
- 'record_number_url' =>'required',
|
|
|
- 'icp_number' =>'required',
|
|
|
- 'icp_number_url' =>'required',
|
|
|
- 'customer_service_qq' =>'required',
|
|
|
- 'communications' =>'required'
|
|
|
- ],
|
|
|
- [
|
|
|
- 'website_id.required' => '网站id不能为空',
|
|
|
'page_type.required' => '页面类型不能为空',
|
|
|
'page_type.array' => '页面类型必须是数组',
|
|
|
'page_type.min' => '页面类型至少有两个元素',
|
|
@@ -1221,15 +1236,20 @@ class WebsiteController extends AbstractController
|
|
|
'organizer.required' => '主办单位不能为空',
|
|
|
'copyright_information.required' => '版权信息不能为空',
|
|
|
'project_logo.required' => '项目logo不能为空',
|
|
|
+ 'project_logo.image' => '项目logo必须是图片',
|
|
|
+ 'project_logo.max' => '项目logo大小不能超过500kb',
|
|
|
'record_number.required' => '网安备案号不能为空',
|
|
|
'record_number_url.required' => '网安备案号链接不能为空',
|
|
|
'icp_number.required' => '网站备案号不能为空',
|
|
|
'icp_number_url.required' => '网站备案号链接不能为空',
|
|
|
'customer_service_qq.required' => '客服qq不能为空',
|
|
|
- 'communications.required' => '通联qq不能为空'
|
|
|
+ 'communications.required' => '通联qq不能为空',
|
|
|
+ 'company_logo.image' => '公司logo必须是图片',
|
|
|
+ 'company_logo.max' => '公司logo大小不能超过500kb'
|
|
|
]
|
|
|
);
|
|
|
- if ($validator->fails()){
|
|
|
+
|
|
|
+ if ($validator->fails()) {
|
|
|
$errorMessage = $validator->errors()->first();
|
|
|
return Result::error($errorMessage);
|
|
|
}
|