I have two methods in my controller. The first is called uploadsand displays all the records from the database table, it looks like this:
public function uploads()
{
$uploads = Upload::all();
return view('uploads')->with('uploads',$uploads);
}
This function works, and all records are successfully retrieved in my view.
The problem is with the second method upload, the purpose of which is to display data for a single download when you click on a name from the list of downloads.
Currently, I only have this:
public function upload($id)
{
return Upload::find($id);
}
And I'm not sure how to perform this function.
My view is as follows:
@extends('layouts.app')
@section('content')
<h1>Uploads</h1>
@if(count($uploads)>0)
@foreach($uploads as $upload)
<div class="well">
<h3><a href="/uploads/{{$upload->id}}">{{$upload->name}}</a> </h3>
<small>Written on {{$upload->created_at}}</small>
</div>
@endforeach
@else
<p>No uploads found</p>
@endif
@endsection
I was not sure what to add web.php, so my routes look like this:
Route::get('/uploads', function () {
return view('uploads');
});
Auth::routes();
Route::get('/uploads','UploadController@uploads')->name('uploads');
- ? , . ?