Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel- redirect with variable and display it in the view file

I have a controller

 public function store(Request $request)
{if ($request->input('asc')){
                $image = PropertyUser::where('user_id', '=', Auth::user()->id)->get();
                foreach($image as $property)
                {
                    $id = $property->property_id;
                }
                $image_ = Image::where('property_id', $id)->sortBy('description')->get();
                return redirect('settings/photos');

How can i redirect with the $image_ variable and display it in my view file

@foreach ($image_ as $images)
            <div class="image-warp"><img src="{{$images->filename}}"
                                         style="width:100px;height:100px;"><br/><span style="color: #1b1e21">{{$images->description}}</span>
            </div>
        @endforeach
like image 991
Adokiye Iruene Avatar asked Dec 02 '22 11:12

Adokiye Iruene


1 Answers

You can use the compact function to pass it to your view and reference it by the name.

return redirect('folder.name', compact('variableName');
return redirect()->route('folder.name', [$image]);
like image 84
bgh Avatar answered Dec 23 '22 11:12

bgh