1
votes

in laravel version 5.8 when call route() function with empty parameters like this

route('post.edit',['post'=>''])

don't get error.

but in version 6 i get this error

ErrorException (E_ERROR) Missing required parameters for [Route: post.edit] [URI: admin/post/{post}/edit]. (View: /var/www/html/mysite/resources/views/post/list.blade.php)

now how can i generate route() url with null or empty

1
Can you put your controller method and rout that contain in web.php - ashanrupasinghe
is it possible to send empty or null parameter to edit route of resource controller? - Prashant Deshmukh.....

1 Answers

0
votes

Your route is defined to have a parameter, you would have to define it as an optional parameter to be able to generate a URL with the helper:

Route::get('post/{post?}/edit', ....)->name('post.edit'); 

Though, I would imagine the URL that is generated won't match to your route. Kinda odd to have an optional parameter in a middle route segment.