Postingan lainnya
Mengambil nilai route / getroute dari link
gimna caranya ngambil kata "/tester/{id}" dari route ini?
Route::get('/tester/{id}','ctestercontroller@oklah');
dulu ane di laravel 5.2 pake
Route::getCurrentRoute()->getPath() itu berhasil
sekarng dilaravel 5.6 muncul error
Method Illuminate\Routing\Route::getPath does not exist
4 Jawaban:
Mau ambil kata semuanya? "/tester/{id}", atau cuma mau ambil param id nya saja?
kalau mau ambil semua
<pre> // Example: http://domain.com/foo/bar $request->path();
//result foo/bar </pre>
kalau mau ambil param id <pre> // Example: http://domain.com/foo/100 $request->id;
//result 100 </pre>
ane mau ngambil sesuai dengan route yaitu <pre> /tester/{id} </pre>
ane udah pake <pre> // Example: http://domain.com/tester/4 //Request::path();
echo Request::path();
hasilnya: /tester/4 </pre>
yg ane maksud itu <pre> // Example: http://domain.com/tester/4 //Request::path();
echo Request::path();
hasilnya: /tester/{id} </pre>
<pre> \Route::current()->getName()
request()->route()->getName()
$route = Route::current();
$name = Route::currentRouteName();
$action = Route::currentRouteAction(); </pre>
ok gan makasih ane pake <pre> Route::current()->uri() </pre>