0
votes

I have an encrypted URL slug and it's displaying like this http://localhost/pending/$2y$10$r3N01R19/M4UURceDSNGkuEInQ1LQC5OvBoEiugYOhpla8f3wHZU2.

Now, how do I get the only encrypted slug $2y$10$r3N01R19/M4UURceDSNGkuEInQ1LQC5OvBoEiugYOhpla8f3wHZU2, in Laravel controller and dump?

Controller

public function pending(Request $request, $enc_code)
{
    $slug = $request->get($enc_code);
    dd($slug);
}

Route

Route::get('/pending/{enc_code}', 'PagesController@pending')->name('page.pending');
2
Should this sort of route setup not pass the value into your controller as $enc_code already?CBroe
@CBroe I have realized there is a slash / in encrypted slug which assumes there is another slug in URL, now how do I hash variable and omit slash /Dominic
if you try dd($enc_code); it should show your slugDmitry
You don’t have control over what result these hash functions produce. Properly URL-encode the value, before you insert it into the URL context, so that any / will become %2F instead.CBroe
@CBroe Thanks, I have got solution, I used str_replace ('/', '', Hash::make($request->get('enc_code'))); to remove forward and it works.Dominic

2 Answers

0
votes

use Illuminate\Support\Facades\Request;

....

Request::segment(count(Request::segments()))

0
votes

May be it could be help in your case.

use Illuminate\Support\Facades\Request;
Request::segment(count(Request::segments()))