Getting Current Route Name : Laravel
'Request URI' retrieve කිරීම සඳහා විවිධ ක්රම ඇතත් ඒවා ක්රියාත්මක කිරීම, විවිධ තත්ත්ව සහ කොන්දේසි මත සිදු වේ.
Route Facadeක භාවිතයෙන්:
Laravel Version 6 සිට මෙම පහසුකම භාවිත කළ හැක.
use Illuminate\Support\Facades\Route;
$route = Route::current(); // Illuminate\Routing\Route
$name = Route::currentRouteName(); // string
$action = Route::currentRouteAction(); // string
Documentation: The following returns URL instead of route name
url()->current();
Imagine, we have menu icon, that changes according to the menu currently we are.
<li class="
{{ (Request::is('products/*') || Request::is('products') || Request::is('product/*') ? 'active' : '')
}} ">
<a href="{{url('products')}}">
<i class="fa fa-code-fork"></i>
Products
</a>
</li>