Reputation: 751
I have this function in the controller.
public function newsedit($id)
{
$editNews = $this->agro->find($id);
//return $editNews;
return Redirect::back()->with('editNews',$editNews);
//return View::make('agro.show')->with('editNews',$editNews);
}
The return $editNews displays data, so there is data in $editNews.Now i am trying to pass the same data to the view using redirect as shown in the above code. But apparently the value is not passed. The following code shows the value is not availabel in the view
@if(isset($editNews))
<h1> value availabel</h1>
@else
<h1> No value </h1>
@endif
It displays No value . Please help me pass the data to view.I don't understant where have i gone wrong.
Upvotes: 0
Views: 2689
Reputation: 3205
Laravel 4:
@if(Session::has('editNews'))
Laravel 5:
@if(session()->has('editNews'))
If you want to get the data, replace has()
with get()
Upvotes: 5
Reputation: 2867
You can simply use
@if( Session::get( 'editNews' ) )
// show something
@endif
in Laravel 4 - it will return false to the @if block if the variable is not set
Upvotes: 0