enexspecial's avatar

Please I want Help on how to solve this issue

I trying to create a system where a user can click on an image then a modal open and user can view the picture and also read the comment of other users; Now i have this routes:

Route::get('/upload','GalleryController@index')->name('upload');==> This render the page

Route::post('/picture', 'GalleryController@pictureUpload'); ==> This is button that upload the picture file to serve and it is a bootstrap modal.

Route::get('upload/show/{id}', 'GalleryController@showUpload');==> This is modal that display the image file and the comment edit and delete

The error here is this (Undefined variable: albums)

Here is the controller:

public function index() { $photos = DB::table('upload_galleries')->get();

  return view('community.gallery', compact('photos'));
}

public function showUpload($id) {

  $albums = DB::table('upload_galleries')->where('id', $id)->first();

  return view('community.gallery.upload', compact('albums'));
}

Here is my view:

Gallery Picture ×

Picture Upload

{{Form::open(['file'=>true,'url'=>'/picture', 'method'=>'post', 'enctype'=>'multipart/form-data'])}} {{csrf_field()}} {{Form::label('details','Details')}} {{Form::textarea('details','',['class'=>'form-control input-sm', 'rows'=>'2'])}} {{Form::label('upload','Upload Picture')}} {{Form::file('picture',['class'=>'form-control input-sm', 'rows'=>'3'])}} Upload
                    {{Form::close()}}
                  </div>
                  <div class="modal-footer">
                        <button type="button" class="btn btn-default btn-sm" data-dismiss="modal">Close</button>
                  </div>
                </div>
              </div>
            </div>
      

@foreach($photos as $photo) @endforeach ×

{{strtoupper(Auth::user()->slug)}} Picture

@foreach($albums as $album) {{$album->details}} {{Form::open()}} {{Form::textarea('comment','',['class'=>'form-control input-sm', 'rows'=>2])}} &nbsp| &nbsp| {{Form::close()}} @endforeach

                    </div>
                  </div>
                </div>
              </div>
            </div>
      </div>
    </div>
  </div>

</div>
0 likes
0 replies

Please or to participate in this conversation.