what does the page url say when you get this?
Too few arguments to function 0 passed and exactly 1 expected
I have this blade that pass parameter to the controller:
@foreach($respondents as $key => $respondent)
<tr>
<td>
{{$key+1}}
</td>
<td>
{{$respondent->employee->employee_code}} - {{$respondent->employee->first_name}} {{$respondent->employee->last_name }}
</td>
<td>
<!--<span data-toggle="tooltip" data-original-title="Click To View Details">-->
<a class="btn btn-xs btn-info" href="{{ route('appraisal.appraisal_msfs.create', ['id'=>$respondent->id]) }}">
<i class="fas fa-search"></i>
Awaiting Response
</a>
</td>
</tr>
@endforeach
route:
Route::get('/appraisal_msfs/index', 'AppraisalMsfsController@index')->name('appraisal_msfs.index');
Route::get('/appraisal_msfs/create/{id}', 'AppraisalMsfsController@create')->name('appraisal_msfs.create');
Route::post('/appraisal_msfs/store/{id}', 'AppraisalMsfsController@store')->name('appraisal_msfs.store');
Route::get('/appraisal_msfs/edit/{id}', 'AppraisalMsfsController@edit')->name('appraisal_msfs.edit');
Route::post('/appraisal_msfs/update/{id}', 'AppraisalMsfsController@update')->name('appraisal_msfs.update');
Route::get('/appraisal_msfs/show/{id}', 'AppraisalMsfsController@show')->name('appraisal_msfs.show');
controller
public function create($id)
{
$userCompany = Auth::user()->company_id;
$userEmployee = Auth::user()->employee_id;
$respondent = AppraisalRespondent::where('id', $id)->first();
$skills = AppraisalSkill::where('company_id', $userCompany)->get();
$ratings = AppraisalRating::where('company_id', $userCompany)->get();
$count_skills = AppraisalSkill::where('company_id', $respondent->company_id)->get()->count();
return view('appraisal.appraisal_msfs.create')
->with('skills', $skills)
->with('ratings', $ratings)
->with('count_skills', $count_skills)
->with('respondent', $respondent);
}
When I submitted, I got this error:
[2020-10-11 20:52:59] production.ERROR: Too few arguments to function App\Http\Controllers\Appraisal\AppraisalMsfsController::create(), 0 passed and exactly 1 expected {"userId":470,"exception":"[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): Too few arguments to function App\Http\Controllers\Appraisal\AppraisalMsfsController::create(), 0 passed and exactly 1 expected at C:\xampp\htdocs\myapp\app\Http\Controllers\Appraisal\AppraisalMsfsController.php:96)
It highlights:
public function create($id)
When I did route:list, I got this:
| | GET|HEAD | appraisal/appraisal_msfs/create | appraisal.appraisal_msfs.create | App\Http\Controllers\Appraisal\AppraisalMsfsController@create | web,auth |
| | GET|HEAD | appraisal/appraisal_msfs/create/{id} | appraisal.appraisal_msfs.create
Why is it giving me 2 create. One is with the parameter {id}
How do I resolve it?
Thanks
have you cached routes? Always use php artisan route:clear in development.
Change your view;
<a class="btn btn-xs btn-info" href="{{ route('appraisal.appraisal_msfs.create', $respondent->id) }}">
Please or to participate in this conversation.