Missing required parameters for [Route: addapplication.edit]

Viewed 73

I'm having trouble on passing application_id from application@edit controller to addapplication@index controller. Please help me.

application@edit controller

$application->application_id = $request->application_id;
              
$application->save();
              
return redirect(route('addapplication.index'))->with('application_id',$request->application_id);

addapplication@index controller

$application_id = Session::get('application_id');

$applications = addapplication::where('application_id', $application_id)->get();

return view('user.addapplication.index',compact('applications'));

blade.php

@foreach ($applications as $application)
  <tr>
    <td>{{ $loop->index +1 }}</td>
    <td>{{ $application->application_id }}</td>
    <td>{{ $application->created_at }}</td>
    <td>{{ $application->surname }}, {{ $application->firstname }} {{ $application->middlename }}</td>
    <td><a href = "{{ route('addapplication.edit', $application->id)}}"><img src = {{ asset('assets/img/eye.ico') }}/></a>
    </td>
  </tr>
@endforeach

I'm getting this error:

Missing required parameters for [Route: addapplication.edit] [URI: addapplication/{addapplication}/edit]. (View: D:\path\index.blade.php)

here is my route.php

Route::resource('application', 'ApplicationController');
Route::resource('addapplication', 'AddApplicationController');

Please help me. Thank you!

2 Answers

The route helper requires an array as the secondary argument.

{{ route('addapplication.edit', ['addapplication' => $application->id])}}

You can figure out the required key (in any scenario) by using the artisan route:list command and looking at the values between the curly braces in the URI column.

In your case the route should look like this:

/addapplications/{addapplication}/edit

You have to use like this

{{route('addapplication.edit',['addapplication'=>$application->id])}}
Related