formId = $formId; $this->fieldName = $fieldName; } public function passes($attribute, $value) { // Получаем все записи для данного custom_form_id $responses = DB::table('custom_form_responses') ->where('custom_form_id', $this->formId) ->pluck('answers'); // Проверяем, есть ли значение в JSON foreach ($responses as $response) { $answers = json_decode($response, true); if (isset($answers[$this->fieldName]) && $answers[$this->fieldName] === $value) { return false; // Значение не уникально } } return true; // Значение уникально } public function message() { return 'Поле должно быть уникальным'; } }