original_string: protected function handleRelationField($method, $arguments)
      {
          if (!method_exists($this->model, $method)) {
              return false;
          }
  
          if (!($relation = $this->model->$method()) instanceof EloquentRelation) {
              return false;
          }
  
          if ($relation    instanceof HasOne
              || $relation instanceof BelongsTo
              || $relation instanceof MorphOne
          ) {
              $this->model->with($method);
  
              if (count($arguments) == 1 && $arguments[0] instanceof \Closure) {
                  return $this->addRelation($method, $arguments[0]);
              }
  
              if (count($arguments) == 2 && $arguments[1] instanceof \Closure) {
                  return $this->addRelation($method, $arguments[1], $arguments[0]);
              }
  
              return $this->addField($method, Arr::get($arguments, 0))->setRelation(Str::snake($method));
          }
  
          if ($relation    instanceof HasMany
              || $relation instanceof MorphMany
              || $relation instanceof BelongsToMany
              || $relation instanceof HasManyThrough
          ) {
              if (empty($arguments) || (count($arguments) == 1 && is_string($arguments[0]))) {
                  return $this->showRelationAsField($method, $arguments[0] ?? '');
              }
  
              $this->model->with($method);
  
              if (count($arguments) == 1 && is_callable($arguments[0])) {
                  return $this->addRelation($method, $arguments[0]);
              } elseif (count($arguments) == 2 && is_callable($arguments[1])) {
                  return $this->addRelation($method, $arguments[1], $arguments[0]);
              }
  
              throw new \InvalidArgumentException('Invalid eloquent relation');
          }
  
          return false;
      }
code: protected function handleRelationField($method, $arguments)
      {
          if (!method_exists($this->model, $method)) {
              return false;
          }
  
          if (!($relation = $this->model->$method()) instanceof EloquentRelation) {
              return false;
          }
  
          if ($relation    instanceof HasOne
              || $relation instanceof BelongsTo
              || $relation instanceof MorphOne
          ) {
              $this->model->with($method);
  
              if (count($arguments) == 1 && $arguments[0] instanceof \Closure) {
                  return $this->addRelation($method, $arguments[0]);
              }
  
              if (count($arguments) == 2 && $arguments[1] instanceof \Closure) {
                  return $this->addRelation($method, $arguments[1], $arguments[0]);
              }
  
              return $this->addField($method, Arr::get($arguments, 0))->setRelation(Str::snake($method));
          }
  
          if ($relation    instanceof HasMany
              || $relation instanceof MorphMany
              || $relation instanceof BelongsToMany
              || $relation instanceof HasManyThrough
          ) {
              if (empty($arguments) || (count($arguments) == 1 && is_string($arguments[0]))) {
                  return $this->showRelationAsField($method, $arguments[0] ?? '');
              }
  
              $this->model->with($method);
  
              if (count($arguments) == 1 && is_callable($arguments[0])) {
                  return $this->addRelation($method, $arguments[0]);
              } elseif (count($arguments) == 2 && is_callable($arguments[1])) {
                  return $this->addRelation($method, $arguments[1], $arguments[0]);
              }
  
              throw new \InvalidArgumentException('Invalid eloquent relation');
          }
  
          return false;
      }
code_tokens: protected function handleRelationField ( $ method , $ arguments ) { if ( ! method_exists ( $ this -> model , $ method ) ) { return false ; } if ( ! ( $ relation = $ this -> model -> $ method ( ) ) instanceof EloquentRelation ) { return false ; } if ( $ relation instanceof HasOne || $ relation instanceof BelongsTo || $ relation instanceof MorphOne ) { $ this -> model -> with ( $ method ) ; if ( count ( $ arguments ) == 1 && $ arguments [ 0 ] instanceof \ Closure ) { return $ this -> addRelation ( $ method , $ arguments [ 0 ] ) ; } if ( count ( $ arguments ) == 2 && $ arguments [ 1 ] instanceof \ Closure ) { return $ this -> addRelation ( $ method , $ arguments [ 1 ] , $ arguments [ 0 ] ) ; } return $ this -> addField ( $ method , Arr :: get ( $ arguments , 0 ) ) -> setRelation ( Str :: snake ( $ method ) ) ; } if ( $ relation instanceof HasMany || $ relation instanceof MorphMany || $ relation instanceof BelongsToMany || $ relation instanceof HasManyThrough ) { if ( empty ( $ arguments ) || ( count ( $ arguments ) == 1 && is_string ( $ arguments [ 0 ] ) ) ) { return $ this -> showRelationAsField ( $ method , $ arguments [ 0 ] ?? '' ) ; } $ this -> model -> with ( $ method ) ; if ( count ( $ arguments ) == 1 && is_callable ( $ arguments [ 0 ] ) ) { return $ this -> addRelation ( $ method , $ arguments [ 0 ] ) ; } elseif ( count ( $ arguments ) == 2 && is_callable ( $ arguments [ 1 ] ) ) { return $ this -> addRelation ( $ method , $ arguments [ 1 ] , $ arguments [ 0 ] ) ; } throw new \ InvalidArgumentException ( 'Invalid eloquent relation' ) ; } return false ; }
docstring: Handle relation field.
  
  @param string $method
  @param array  $arguments
  
  @return $this|bool|Relation|Field
docstring_tokens: Handle relation field .