I have a problem downloading a pdf file in laravel with voyager. Someone said, i have to use 'json_decode' but I cant understand how to do so. Here is my controller:
Controller
class HomeController extends Controller
{
public function index()
{
$posts = Post::all();
$files = Download::all();
return view('user.index', compact('posts', 'files'));
}
public function show($id)
{
$files = Download::where('id', $id)->firstOrFail();
$path = storage_path($files->file);
return response()->download($path);
}
}
Route
Route::get('/download/{id}','HomeController@show')->name(downloadFile);
View
@foreach($files as $file)
<a class="primary-btn" href="{{route('downloadFile',$file->id)}}">Download Resume </a>
@endforeach
The file "C:\laragon\www\kbtonmoy.com\storage[{"download_link":"downloads\January2020\tmUxP8s9Tvzzqwnl7nxT.pdf","original_name":"ridita.pdf"}]" does not exist