Type error: Too few arguments to function Illuminate\Routing\PendingResourceRegistration::name(), 1 passed in E:\Xampp\htdocs\ntfp\routes\web.php on line 11 and exactly 2 expected code example
Example: Too few arguments to function Illuminate\Routing\PendingResourceRegistration::name(), 1 passed in D:\xampp\htdocs\routes\web.php on line 30 and exactly 2 expected
i was using resource route and defining it with namespace either use get, post
or other route seperatly or you can use the below solution.
The solution is to change your route to:
Route::resource('siswa', 'SiswaController')->name('*', 'siswa')
This may come very late but I've just encountered the same error. The error
occurs because when we use Route::resource, Laravel expects 2 parameters
instead of just 1. Example, in your:
Route::resource('siswa', 'SiswaController')->name('siswa')
you only defined name. Hence, Laravel has defined the route 'siswa' for you.
But because you are using Route::resource, there are many routes that are
defined in there, such as create, edit, delete and so on. So Laravel needs
to define the routes as 'siswa.create', 'siswa.delete', and so on. Naturally,
we cannot be expected to list out all of the methods, so putting a * helps
Laravel understand that it should be creating the named routes as siswa.* and
the * represents all of the different methods(e.g. create,edit, delete and so
on). Hope this helped!