Nested Resource : Missing required parameters

Posted 2 years ago by rkhaili

Hello,

I am quite new to Laravel, and to be honest - It is a great framework. I am however, a bit confused about some nested resources - including CRUD'ing them.

For routes I am using

Route::resource('startups','StartupsController');
Route::resource('startups.usecases','UsecasesController');

php artisan route:list

|        | GET|HEAD  | admin/startups                                   | admin.startups.index            | App\Http\Controllers\[email protected]                               | web,admin,auth:admin |
|        | POST      | admin/startups                                   | admin.startups.store            | App\Http\Controllers\[email protected]                               | web,admin,auth:admin |
|        | GET|HEAD  | admin/startups/create                            | admin.startups.create           | App\Http\Controllers\[email protected]                              | web,admin,auth:admin |
|        | DELETE    | admin/startups/{startup}                         | admin.startups.destroy          | App\Http\Controllers\[email protected]                             | web,admin,auth:admin |
|        | GET|HEAD  | admin/startups/{startup}                         | admin.startups.show             | App\Http\Controllers\[email protected]                                | web,admin,auth:admin |
|        | PUT|PATCH | admin/startups/{startup}                         | admin.startups.update           | App\Http\Controllers\[email protected]                              | web,admin,auth:admin |
|        | GET|HEAD  | admin/startups/{startup}/edit                    | admin.startups.edit             | App\Http\Controllers\[email protected]                                | web,admin,auth:admin |
|        | GET|HEAD  | admin/startups/{startup}/usecases                | admin.startups.usecases.index   | App\Http\Controllers\[email protected]                               | web,admin,auth:admin |
|        | POST      | admin/startups/{startup}/usecases                | admin.startups.usecases.store   | App\Http\Controllers\[email protected]                               | web,admin,auth:admin |
|        | GET|HEAD  | admin/startups/{startup}/usecases/create         | admin.startups.usecases.create  | App\Http\Controllers\[email protected]                              | web,admin,auth:admin |
|        | DELETE    | admin/startups/{startup}/usecases/{usecase}      | admin.startups.usecases.destroy | App\Http\Controllers\[email protected]                             | web,admin,auth:admin |
|        | GET|HEAD  | admin/startups/{startup}/usecases/{usecase}      | admin.startups.usecases.show    | App\Http\Controllers\[email protected]                                | web,admin,auth:admin |
|        | PUT|PATCH | admin/startups/{startup}/usecases/{usecase}      | admin.startups.usecases.update  | App\Http\Controllers\[email protected]                              | web,admin,auth:admin |
|        | GET|HEAD  | admin/startups/{startup}/usecases/{usecase}/edit | admin.startups.usecases.edit    | App\Http\Controllers\[email protected]                                | web,admin,auth:admin |

For the parent, here called "startups", everything is fine, i can CRUD everything just fine.

For the child, here called "usecases", index, create, and store are fine. The moment I try to add a link to the edit, delete, or show within my templates I start getting : Missing required parameters for [Route: admin.startups.usecases.destroy] [URI: admin/startups/{startup}/usecases/{usecase}].

A link in my index blade file :

<li><a href="{{ route('admin.startups.usecases.show',$startup->id, $usecase->id) }}">Show</a></li> 

returns that error.

In my UsecasesController

public function show($startup_id, $usecase_id)
    {
        $startups = $startup_id;
        $usecase = Usecase::find($usecase_id);
        return view('admin.startups.usecases.show')
        ->with('usecase', $usecase)
        ->with('startups', $startups);
    }

TLDR: I can access and CRUD everything on parent, "startups". I can create and store for the child, but not edit, show, or delete - for "usecases".

Your help is appreciated.

Please sign in or create an account to participate in this conversation.