Route [partner.file.download] not defined. is the error i get, but this route is defined. and yes i am logged in as a ‘partner’
Web.php
Route::group(['middleware' => 'role:partner', 'prefix' => 'partner', 'as' => 'partner.'], function(){
Route::resource('/dashboard', AppHttpControllerspartnerPartnerController::class);
Route::resource('/profile', AppHttpControllerspartnerProfileController::class);
Route::resource('/file', AppHttpControllerspartnerFileController::class);
});
controller
public function show($id)
{
$file = File::findOrFail($id);
return view('partner.file.viewfile', compact('file'));
}
public function download($id)
{
return view('partner.file.index', compact('file));
}
index.blade
<tbody>
@foreach($files as $file)
<tr>
<td>{{$file->title}} </td>
<td>
<a class="btn btn-big btn-succes" style="background: orange;" href="{{ route('partner.file.show', $file->id) }}">View</a>
</td>
<td>
<a class="btn btn-big btn-succes" style="background: green;" href="{{ route('partner.file.download', $file->id) }}"></a>
</td>
<td>{{@$file->language->name}} </td>
@foreach($file->tag as $tags)
<td style="background:{{$tags['color']}} ;">{{@$tags->name}} </td>
@endforeach
</tr>
@endforeach
</tbody>
2
Answers
When using Route::resource() the only accessible methods to the controller are index, create, store, show, edit, update and delete.
You can check this at the documentation
PLEASE READ THE DOCS
as @aynber mentioned in the comments, when you create routes using
resource()
, it will createindex, create, store, show, edit, update and delete
. There is no "download" route here.If you need a route that is not in the list of default routes (here you need download), you should create that one explicitly as below: