I'm trying to make a view that will display things that were soft deleted inside the same controller called ServicesController. I made a Route for it as you can see below and when I would click on the link I would get a 404. The links are inside of a form with method="GET" and work if I remove my show route. I don't understand why it works when I remove the show Route, but gives me a 404 when I put it back in. I don't actually have a link for the user to click on to visit the show view and if I type it in manually I get a 404 which is fine since I'm not doing anything with it yet.
Here's my web.php
//Services
Route::get('services', 'ServicesController@index')->name('services.index');
Route::get('services/create', 'ServicesController@create')->name('services.create');
Route::post('services','ServicesController@store')->name('services.store');
//the show function below doesn't actually do anything, but when I remove it the routing works for services/deleted
Route::get('services/{service}', 'ServicesController@show')->name('services.show');
Route::get('services/{service}/edit', 'ServicesController@edit')->name('services.edit');
Route::patch('services/{service}','ServicesController@update')->name('services.update');
Route::delete('services/{service}', 'ServicesController@destroy')->name('services.destroy');
Route::get('services/deleted', 'ServicesController@deleted')->name('services.deleted');
Here are my links
<ul class="nav nav-tabs flex-column">
<li class="nav-item pb-2">
<a class="nav btn-outline-primary text-left nav-link {{ (request()->is('add')) ? 'active' : '' }}"
href="{{route('services.create')}}" name="add" id="add">Add Service</a>
</li>
<li class="nav-item pb-2">
<a class="nav btn-outline-primary text-left nav-link {{ (request()->is('deleted')) ? 'active' : '' }}"
name="deleted" id="deleted" href="{{route('services.deleted')}}">Restore Service</a>
</li>
</ul>
Here is my show function, there's no actual link to it. If I try navigating to it in the url localhost/services/show I also get a 404 which is to be expected
public function show(Service $service)
{
$invoice = Invoice::where('id',$service->invoice_id)->firstOrFail();
$customer = Customer::where('id',$invoice->customer_id)->firstOrFail();
return view('services.show', compact('invoice','service','customer'));
}
Here is my deleted function
public function deleted()
{
$services = Service::onlyTrashed()->paginate(25);
return view('services.deleted', compact('services'));
}
Conclusion. I don't get how or why the show route is messing things up for me, but removing it solves the problem. I'm hoping someone could explain this to me. I would like to know are controllers limited to the number of functions that can be routed by default in laravel? What am I missing here? Please let me know, thank you.