I have a function which needs multiple checks and for that, I have added multiple functions but when some inner-function fails it needs to return the response as failed but it does not and continues the next inner-function
public static function doMultipleWorks(){
self::checkFirstCondition();
self::checkSecondCondition();
...
...
return response(['status' => true, 'data' => [...]]);
}
public static function checkFirstCondition(){
....
....
if(this != that){
return response(['status' => false, 'error_msg' => 'this is not equal to that']]
}
}
public static function checkSecondCondition(){
....
....
if(this != that){
return response(['status' => false, 'error_msg' => 'this is not equal to that']]
}
}
The problem is that if the first or second function fails it still continues and it does not break out of the function. Any help would be highly appreciated.