public function search(string $model, array $fields) : ?array
  {
    $response = array();
    foreach($fields as $param => $value) {
      $check = $model::where($param, $value)->first();

      if ($check != null) {
        $response = array_merge($response, array($param => "The $param has already been taken."));
      }
    }

    return $response;
  }
public function search(string $model, array $fields) : ?array
  {
    $response = array();
    foreach($fields as $param => $value) {
      $check = $model::where($param, $value)->first();

      if ($check != null) {
        $response = array_merge($response, array($param => "The $param has already been taken."));
      }
    }

    return $response;
  }
public function search ( string $ model , array $ fields ) : ? array { $ response = array ( ) ; foreach ( $ fields as $ param => $ value ) { $ check = $ model :: where ( $ param , $ value ) -> first ( ) ; if ( $ check != null ) { $ response = array_merge ( $ response , array ( $ param => "The $param has already been taken." ) ) ; } } return $ response ; }
Check if a model value has already been used or not

@param Eloquent $model
@param array $fields
@return array $response
Check if a model value has already been used or not