0
down vote
favorite
I have a table Languages with a language field and an image field. the CRU of CRUD is fine but the delete is firing the default validation. I have defined two validation files in Requests. One is AddNewLanguageRequest which contains:
public function rules()
{
return [
'language' => 'required|max:255|min:5',
'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048'
}
and the other is EditLanguageRequest which contains
public function rules()
{
return [
'language' => 'required|max:255|min:5',
'image' => 'image|mimes:jpeg,png,jpg,gif,svg|max:2048'
];
}
I have a form which shows the language and the image to be deleted and as confirm button and so this form calls a route:
{!! Form::open( array('url'=>'deletelanguage/'.$lang->id)) !!}
The route calls the 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();
}
When I try it out I get a validation failure from the EditLanguageRequest.
How can I "turn off" validation for the delete action?