php - How to get last part of url in blade file (HTML) using laravel 5.2? -


i new laravel. want last part of url in blade file(html file). have done 1 using php functionality . there way can using laravel functionality .

below code ,its working fine

<?php $url = url()->current(); echo $end = end((explode('/', $url))); ?> 

i have used 1

request::segment(2) 

here url http://localhost/blog/public/user/add-user. want add-user in html file.

thank you

the answer question is: "no there not laravel functionality" or more precisely laravel helpers getting last segment, fortunately can use php. end has been mentioned , end works on array, don't think possible use directly on request::segments(). means have put request::segments() variable (like $lastsegment) first , use end on variable.

the best , slimmest way find is:

{{ basename(request::url()) }} 

use in blade, of course mentioned before can add in controller or laravel view composer.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -