我有一个表语言字段和图像字段的表格。 CRUD的CRU很好,但删除是触发默认验证。我在请求中定义了两个验证文件。一个是AddNewLanguageRequest,其中包含:
public function rules()
{
return [
'language' => 'required|max:255|min:5',
'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048'
}
另一个是包含
的EditLanguageRequestpublic function rules()
{
return [
'language' => 'required|max:255|min:5',
'image' => 'image|mimes:jpeg,png,jpg,gif,svg|max:2048'
];
}
我有一个表单,显示要删除的语言和图像以及确认按钮,因此此表单调用路径:
{!! Form::open( array('url'=>'deletelanguage/'.$lang->id)) !!}
路由调用LanguageController
public function delete(Requests\EditLanguageRequest $request){
//is there an image? If so delete it
$lang = Language::find($request->id);
if (isset($lang->image))
{
if (Storage::exists($lang->image) )
{Storage::delete($lang->image);}
}
$lang->delete();
}
当我试用它时,我从EditLanguageRequest获得验证失败。
我怎样才能"关闭"验证删除操作?
答案 0 :(得分:0)
问题在于这一行:
public function delete(Requests\EditLanguageRequest $request
当然是调用请求所以将其更改为
public function delete(Request $request)
解决了它