3 回答
TA贡献1871条经验 获得超8个赞
你应该试试这个:
public function rules()
{
$slug = $this->request->get("slug");
return [
'title' => 'required',
'body' => 'required',
'metaTitle' => 'required',
'metaDescription' => 'required',
'slug' => ['required', Rule::unique('posts')->ignore($slug,'slug')],
];
}
TA贡献2003条经验 获得超2个赞
试试这个希望它会起作用
public function rules(Request $request)
{
return [
'title' => 'required',
'body' => 'required',
'metaTitle' => 'required',
'metaDescription' => 'required',
'slug' => 'required|slug|unique:posts,slug,' . $this->post,
];
}
TA贡献2011条经验 获得超2个赞
请为StoreAndUpdate方法尝试此操作:
'slug' => [
'required',
'slug',
'unique:posts,slug' . (isset($this->post) ? ',' . $this->post : ' ')
],
- 3 回答
- 0 关注
- 124 浏览
添加回答
举报