|
@@ -5,7 +5,7 @@ namespace App\Http\Controllers\manager\washConfig;
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Controllers\Controller;
|
|
|
use App\Http\Requests\Manager\WashConfig\CompanyCategory as Request;
|
|
use App\Http\Requests\Manager\WashConfig\CompanyCategory as Request;
|
|
|
use App\Models\Manager\WashConfig\CompanyCategory as CompanyCategoryModel;
|
|
use App\Models\Manager\WashConfig\CompanyCategory as CompanyCategoryModel;
|
|
|
-
|
|
|
|
|
|
|
+use App\Models\Manager\WashConfig\ViolationStore as ViolationStoreModel;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 清洗配置-公司分类
|
|
* 清洗配置-公司分类
|
|
@@ -172,13 +172,20 @@ class CompanyCategory extends Controller
|
|
|
* @date 2025-12-19
|
|
* @date 2025-12-19
|
|
|
*
|
|
*
|
|
|
*/
|
|
*/
|
|
|
- public function set_status(Request $request, CompanyCategoryModel $CompanyCategoryModel)
|
|
|
|
|
|
|
+ public function set_status(Request $request, CompanyCategoryModel $CompanyCategoryModel,ViolationStoreModel $ViolationStoreModel)
|
|
|
{
|
|
{
|
|
|
// 验证参数
|
|
// 验证参数
|
|
|
$request->scene('set_status')->validate();
|
|
$request->scene('set_status')->validate();
|
|
|
// 接收数据
|
|
// 接收数据
|
|
|
$id = request('id', 0);
|
|
$id = request('id', 0);
|
|
|
$status = request('status', 0);
|
|
$status = request('status', 0);
|
|
|
|
|
+ //如果是禁用,校验是否被使用
|
|
|
|
|
+ if ($status == 1) {
|
|
|
|
|
+ $violation_store_count = $ViolationStoreModel->where(['category_id' => $id])->count();
|
|
|
|
|
+ if ($violation_store_count > 0) {
|
|
|
|
|
+ return json_send(['code' => 'error', 'msg' => '该分类下存在公司配置,禁用失败']);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
// 查询用户
|
|
// 查询用户
|
|
|
$where = ['id' => $id];
|
|
$where = ['id' => $id];
|
|
|
$CompanyCategory = $CompanyCategoryModel->where($where)->first();
|
|
$CompanyCategory = $CompanyCategoryModel->where($where)->first();
|