wertyu
wertyu

Reputation: 121

redirect route with # laravel

I use "return redirect()->route()" to routing but I have a tab named "#tab4" but cannot add this to url with redirect()->route. I want to show the same tab after submit but cannot set the url.when I use redirect()->back(), cannot see success message and page does not resresh. How to do that in laravel?

sessionsuccess("asdfghj.");

return  redirect()->route('manage.customers.detail', ['account' => $this->account->id]);

the url I want: http://localhost:8000/manage/customers/detail/9#tab4

Upvotes: 0

Views: 1318

Answers (4)

Syed Ali
Syed Ali

Reputation: 161

You need to save your tab as a flash so whenever you submitted the tab can be active in your controller method

Session::flash('tab', 'table_name');

and in your view you can work like this

Session::has('tab')? 'active' :''

for more details https://laravel.com/docs/5.0/session#flash-data

second way you can work link

return redirect()->route('manage.customers.detail', ['account' => $this->account->id, '#tab4']);

Upvotes: 0

Mohsen Amani
Mohsen Amani

Reputation: 102

Store your current tab inside a session variable. after loading view, sessions can be used and retrieve your last tab

Upvotes: 0

Amede Angel Aulerien
Amede Angel Aulerien

Reputation: 398

Try to use :

return redirect()->to(route('manage.customers.detail', ['account' => $this->account->id]).'#tab4');

Upvotes: 0

Emrah Çalışkan
Emrah Çalışkan

Reputation: 21

web.php on route

Route::view('/#detail', 'manage.customers.detail/{account_id}')->name('detail');

on controller

return  redirect()->route("detail")->with("account_id"=>$this->account_id);

Try this.I believe working this

Upvotes: 1

Related Questions