'Too few arguments to function App\Http\Controllers\DataPegawaiController::storeDetail(), 1 passed in
i have problem like this. After insert new User to Pegawais table, i want to redirect to another view with user id parameter to define EducationHistory & WorkExperience data. but when i
Too few arguments to function App\Http\Controllers\DataPegawaiController::storeDetail(), 1 passed in C:\xampp\htdocs\data-pegawai\vendor\laravel\framework\src\Illuminate\Routing\Controller.php on line 54 and exactly 2 expected
show method is where i fill my form to insert onto storeDetails method which is use user id parameter from show method route.
public function show($id)
{
$user = User::find($id);
return view('pegawai.create-details',['user'=>$user]);
}
public function storeDetail($id,Request $request)
{
$user = new User;
$user->id_pegawai;
dd($user);
$pendidikanAttribute = [];
$pendidikanAttribute['nama_sekolah'] = $request->nama_sekolah;
$pendidikanAttribute['jurusan'] = $request->jurusan;
$pendidikanAttribute['tahun_masuk'] = $request->tahun_masuk;
$pendidikanAttribute['tahun_lulus'] = $request->tahun_lulus;
$pendidikanAttribute['id_pegawai'] = $user->id_pegawai;;
Pendidikan::create($pendidikanAttribute);
$pengalamanAttribute = [];
$pengalamanAttribute['perusahaan'] = $request->perusahaan;
$pengalamanAttribute['jabatan'] = $request->jabatan;
$pengalamanAttribute['tahun'] = $request->tahun;
$pengalamanAttribute['keterangan'] = $request->keterangan;
$pendidikanAttribute['id_pegawai'] = $user->id_pegawai;;
PengalamanKerja::create($pengalamanAttribute);
return redirect()->route('data-pegawai.index');
}
and this is my store detail view code :
<form method="POST" class="mt-4" action="{{route('data-pegawai.storeDetail',$user->id_pegawai)}}">
@csrf
this is my route :
Route::post('/data-pegawai/{id}/store-detail/', [DataPegawaiController::class,'storeDetail'])->name('data-pegawai.storeDetail');
Solution 1:[1]
Remove $id
from function storedetials
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Suraj Rao |