4. Lấy request path (Retrieving the request path)
https://viblo.asia/p/tap-16-request-laravel-aWj534Y8K6m
1. Lấy request path (Retrieving the request path)
Với method path
sẽ trả về path của request hiện tại. Nếu request hiện tại có url là http://domain.com/foo/bar
thì method path
sẽ trả về foo/bar
.
Các bạn có thể dùng đoạn code trên để test.
Method is
cho phép bạn xác thực rằng request path hiện tại khớp với pattern mà bạn đưa ra. Bạn có thể sử dụng ký tự *
để làm đại diện cho các thành phần phía sau.
Pattern ở đây chính là admin/*
, nếu ta truy cập request path admin/post
thì chắc chắn sẽ trùng khớp.
Previous3. Truy cập request thông qua Route Closure (Accessing the request via route closure)Next5. Lấy request URL (Retrieving the request URL)
Last updated