Stefan Stefan - 2 months ago 11x
PHP Question

Laravel resource controller, return page with message after store()

I have made a page that registers a new company for my system and will then depending on the output return a message to the user. I have now changed my routes and location for php to a resource controller but I am now getting a problem with redirecting to other pages. I want to redirect to my Companies/create page with a message that can say with variables attached to tell the result of the registration.

I have looked at the laravel documentation but can't get it to work properly.

Can somebody help me out here?

Thanks in advance.


You can pass any message with with() method like this:

return view('some.view')->with('message', 'This is a message');

Then in a view:

@if (session('message'))
    {{ session('message') }}


{{ session('message') or '' }}