Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why pathInfo shows null if is not null?

The dd($request) shows a pathInfo #pathInfo: "/nova-api/post-tags/20/update-fields". And I want to get that value, more specifically I want to check if "post-tags" is in the url.

However dd($request->pathInfo); shows:

null

But its not null as can be seen below:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Laravel\Nova\Http\Requests\NovaRequest {#1703
  #container: Illuminate\Foundation\Application {#2
    #basePath: "/var/www/src"
    #hasBeenBootstrapped: true
    #booted: true
    ....
      "request" => Illuminate\Http\Request {#43
        ...
        #routeResolver: Closure() {#655
          class: "Illuminate\Routing\Router"
          ...
          }
          file: "/var/www/src/vendor/laravel/framework/src/Illuminate/Routing/Router.php"
          line: "650 to 652"
        }
        +attributes: Symfony\Component\HttpFoundation\ParameterBag {#45
          #parameters: []
        }
        +request: Symfony\Component\HttpFoundation\ParameterBag {#51
          #parameters: array:5 [ …5]
        }
        +query: Symfony\Component\HttpFoundation\ParameterBag {#51}
        +server: Symfony\Component\HttpFoundation\ServerBag {#47
          #parameters: array:63 [ …63]
        }
        +files: Symfony\Component\HttpFoundation\FileBag {#48
          #parameters: []
        }
        +cookies: Symfony\Component\HttpFoundation\ParameterBag {#46
          #parameters: array:4 [ …4]
        }
        +headers: Symfony\Component\HttpFoundation\HeaderBag {#49
          #headers: array:21 [ …21]
          #cacheControl: array:1 [ …1]
        }
        #content: ""
        #languages: null
        #charsets: null
        #encodings: null
        #acceptableContentTypes: null
        #pathInfo: "/nova-api/post-tags/20/update-fields"
        #requestUri: "/nova-api/post-tags/20/update-fields?editing=true&editMode=update&viaResource=&viaResourceId=&viaRelationship="
        #baseUrl: ""
        #basePath: null
        #method: "GET"
        #format: null
        ...
      }
      ....
}

Do you know what can be the issue?

>Solution :

According to the API docs, you should be able to do:

$request->path()

to get the path info for the request.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading