I have two methods in my controller. The first is called uploads
and it displays all the records from a DB table, it looks like this :
public function uploads()
{
//return Upload::all();
$uploads = Upload::all();
return view('uploads')->with('uploads',$uploads);
}
This function is working and all the records are successfully retrieved in my view.
The issue is with the second method upload
which aims to show a data for a single upload when its name is clicked from the list of uploads.
Currently, I have just this :
public function upload($id)
{
return Upload::find($id);
}
And I am not sure how to complete this functionality.
My view is looking like this :
@extends('layouts.app')
@section('content')
<h1>Uploads</h1>
@if(count($uploads)>0)
@foreach($uploads as $upload)
<div class="well">
<h3><a href="/uploads/"></a> </h3>
<small>Written on </small>
</div>
@endforeach
@else
<p>No uploads found</p>
@endif
@endsection
I wasn't really sure what to put in web.php
, so my routes look like this :
Route::get('/uploads', function () {
return view('uploads');
});
Auth::routes();
Route::get('/uploads','UploadController@uploads')->name('uploads');
Can someone help me make this work? I just want to see the associative array with the record from the database when I click on an upload's name.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire