Return View or Return Redirect

Posted 8 months 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.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.