0

Hello People here is my code i have used in controller...

public function bulk()
{
    return View::make('bulk')->with('message','hii there');

}

my route file contains...

Route::get('bulk',array('uses'=>'HomeController@bulk'))->before('auth');

In my view Iam testing it by ...

@if(Session::has('message')) 
Present
@else
not Present
@endif

The page is making a view with the message 'not Present' why is it?? I even tried

return Redirect::to('bulk')->with('message','hii there');

I get an erro mesage on Console

 mypro/public/bulk net::ERR_TOO_MANY_REDIRECTS 

What could be the problem?? is there any issues with name?? I tried this method earlier which worked fine for me.... :(

Iam using Blade Template..

2 Answers 2

3

You are confusing Redirect and View. You use Session::get to access variables passed to redirects. For views (as in your case), with will pass an simple PHP variable into your view. So your check should be:

@if(isset($message)) 
  {{{ $message }}}
@else
  No message!
@endif

Read more here

Sign up to request clarification or add additional context in comments.

2 Comments

Use {{{ $message }}} to echo blade data (or {{ $message }} to not escape). Read more here
Great it seems to be working, But in my other pages i have used @if(Session::has('message')) :( any ways thanks dear...
0

As per the docs, you need to access the "with" value in the view using a PHP variable, it's not passed via the session. In your case, that would be $message. If you want to use the session, you should use Session::flash() or Session::put().

1 Comment

Iam using blade template... my view file is bulk.blade.php ...let me try u r suggestion...

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.