app/Http/Controllers/MatchController.php
/**    
      *Method is used to schedule matches between the teams   
      * @param object Request Complete request object
      * @return object response
      
  */
Method is used to schedule matches between the teams
@param object Request Complete request object
@return object response
Method is used to schedule matches between the teams @param object Request Complete request object @return object response
public function createMatch(Request $request)
    {  
      $emptyFlag = $this->matchValidate->isEmpty($request->all());
      if($emptyFlag){
        return response('',Response::HTTP_BAD_REQUEST);
      }else{
       $validationFlag =  $this->matchValidate->validateInputs($request->all());
       if($validationFlag['out']){
          $out = $this->matchValidate->checkIfMatchAlreadyExists($request->all());
           if($out){
               return response('',Response::HTTP_CONFLICT);        
           }else{
               return $this->matchModel->createMatch($request->all());      
           }
       }else{
        if($validationFlag['errorcode'] == 400){
        return response('',Response::HTTP_BAD_REQUEST);                  
        }else if($validationFlag['errorcode'] == 406){
        return response('',Response::HTTP_NOT_ACCEPTABLE);                  
        }else{
        return response('',Response::HTTP_NOT_FOUND);        
        }
       }
      }
    }
public function createMatch ( Request $ request ) { $ emptyFlag = $ this -> matchValidate -> isEmpty ( $ request -> all ( ) ) ; if ( $ emptyFlag ) { return response ( '' , Response :: HTTP_BAD_REQUEST ) ; } else { $ validationFlag = $ this -> matchValidate -> validateInputs ( $ request -> all ( ) ) ; if ( $ validationFlag [ 'out' ] ) { $ out = $ this -> matchValidate -> checkIfMatchAlreadyExists ( $ request -> all ( ) ) ; if ( $ out ) { return response ( '' , Response :: HTTP_CONFLICT ) ; } else { return $ this -> matchModel -> createMatch ( $ request -> all ( ) ) ; } } else { if ( $ validationFlag [ 'errorcode' ] == 400 ) { return response ( '' , Response :: HTTP_BAD_REQUEST ) ; } else if ( $ validationFlag [ 'errorcode' ] == 406 ) { return response ( '' , Response :: HTTP_NOT_ACCEPTABLE ) ; } else { return response ( '' , Response :: HTTP_NOT_FOUND ) ; } } } }
Method is used to schedule matches between the teams
 @param object Request Complete request object
 @return object response
Method is used to schedule matches between the teams @param object Request Complete request object @return object response
//Various validations checked here like empty request,invalid teams //Match already scheduled for respective teams on requested dates 