1

How to Redirect Url in following format:

My code:

return Redirect::to('home/viewcustomer/$cusid')
    ->with('status','success')
    ->with('message','success');

Example :

home/viewcustomer/8

1
  • 1
    try this Redirect::to('home/viewcustomer/'.$cusid) Commented Jul 14, 2016 at 6:01

2 Answers 2

5

You need to take care about your string quotes while using variables within string quotes. Just update your code

Redirect::to('home/viewcustomer/$cusid')

into

Redirect::to("home/viewcustomer/$cusid")
            ^^                        ^^
Sign up to request clarification or add additional context in comments.

Comments

0

Well i usually use

Session and Redirect so you have to define it in your controller

Use Session;
Use Redirect;

Then

public function example(){
 Session::flash('status','Your message');
 return Redirect::to('/yourRoute');
}

If you want to show your message in your view you have to do this...

@if(Session::has('status'))
        <div class="alert alert-success alert-dismissible" role="alert">
            <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                <span aria-hidden="true">&times;</span>
            </button>
            <p><strong>Success!!</strong> </p>
            <ul>
                <li>{{ Session::get('status') }}</li>
            </ul>
        </div>
    @endif

Hope this helps!!

Ps: Sorry for the bad english :)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.