find(); if ($existingCompany) { throw new \Exception('公司名称已存在'); } $result = Companys::create($data); return $result; } public function addOperator($data){ # 判断运营人员是否存在 $existingOperator = CompanyOperators::where('operator_name', $data['operator_name'])->find(); if ($existingOperator) { throw new \Exception('运营人员已存在'); } $result = CompanyOperators::create($data); return $result; } }