В этом случае, я думаю, вам нужно создать собственное правило
Класс запроса:
// Read more in bottom
'name' => ['required', new MustMatchCustomValue('rv_id')],
Класс правила (используйте artisan для его создания). )
class ValidateTwoValues implements Rule
{
protected $rvId;
public function __construct($rvId)
{
$this->rvId = $rvId;
}
/**
* Determine if the validation rule passes.
*
* @param string $attribute
* @param mixed $value
* @return bool
*/
public function passes($attribute, $value)
{
// $value contains the user_id
// $this->rvId contains the other value
// Do DB check here using DB::table('')...etc
// return true if it's okay, or false if not
}
/**
* Get the validation error message.
*
* @return string
*/
public function message()
{
return 'You already have the selected RV.';
}
}
ПРИМЕЧАНИЕ: Я уверен, если передача строки атрибута в качестве параметра классу Rule действительно отправит значение или только строку, в случае это просто строка, которую вы должны поменять на new MustMatchCustomValue($this->rv_id)