Return View or Return Redirect

Posted 1 year ago by Sun

My original url looks like this: http://localhost:8888/textapp/public/receivers?organization_id=2

In my receiver controller, I have code below. Which is working, but the success message can't show up. Also, the url will change to http://localhost:8888/textapp/public/receivers. Which is not correct.

return view('receivers.index', compact('organization', 'receivers'))->with('success', $user->phone_number . ' created successfully.');

If I do the code below. The page will not work, it will just say "Oops, something goes wrong".

redirect->route('receivers.index', compact('organization', 'receivers'))->with('success', $user->phone_number . ' created successfully.');

Any ideas on how to fix this? I am assuming my route list is not right. I should have something like (/organization/receivers/{id}/, 'ReceiverController')?

Route::get('receivers/find', '[email protected]')->name('receivers.find');

Route::resource('receivers', 'ReceiverController');

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.