mercredi 1 mars 2017

PHP refactor if else

I have this if else structure and I want to refactor the else out since I want to clean up the code a bit. Only I am not sure how I can refactor the else out.

if ($validator->fails()) {
   return Redirect::back()
       ->with('error_code', 5)
       ->withErrors($validator->errors())
       ->withInput();
} else {
    // do something if validator does not fail
    return Redirect::back();
}

Anyone has any idea how I can refactor the else out?

Many thanks in advance!

Aucun commentaire:

Enregistrer un commentaire