在rules()
验证(在app / Http / Requests中),是否可以进行验证以检查color_id
表格表中是否存在colors
?
用户从提交的屏幕中选择一种颜色。每种颜色都有颜色Id(color_id)
public function rules()
{
return [
'name' => 'required'
'color_id' => 'required' // and how to check if color_id is exist in db using rule?
];
}