Skip to content
Advertisement

how to use success message in view function along with withDeatils?

my return tag containing withhDetails and success message.. while return is perform the success msg is not printing and my code is below controller:

public function listing($id)
{

    $data=Registration::where('id',$id)->get();      
    return view('search')->withDetails($data)->with('sucess','data updated');
}

view:

@if($message=Session::get('sucess'))
                                <div class="alert alert-sucess">
                                  <p>{{$message}}</p>
                                </div>
                              @endif

Advertisement

Answer

If you are passing the data to the blade file then you can access it as below:

@if(isset($sucess) && $sucess != '')
    <div class="alert alert-sucess">
     <p>{{$sucess}}</p>
   </div>
@endif

There is no need to use session variable as you are not passing data to the session varible just use above code and you are good to access that variable in your blade file because you are just rendering the list file and not redirecting to any other URL.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement