[英]Too few arguments to update function ERROR Laravel 8
Im getting error too few arguments when i try to update my data.当我尝试更新我的数据时,我收到的错误太少 arguments。 I need to use the second id($menuUtama) to redirect to previous page where it need $menuUtama id's to display its data on the page.
我需要使用第二个 id($menuUtama) 重定向到需要 $menuUtama id 在页面上显示其数据的上一页。
I managed to get the $menuUtama ids in URL.我设法在 URL 中获得了 $menuUtama id。 But how can I pass it to my update function parameter, so that it can read to redirect to the required page?
但是如何将它传递给我的更新 function 参数,以便它可以读取以重定向到所需的页面?
here's my update function这是我的更新 function
public function updateSubmenu(Request $request, Chatbot $button, $menuUtama)
{
$button->update([
'test' => $request->test,
]);
return redirect()->route('admin.botman.edit',compact('menuUtama'))->withSuccess('You have successfully update the main menu title.');
}
my route我的路线
Route::get('/admin/botman/{button}/{menuUtama}/editSubmenu', [ChatbotController::class, 'editSubmenu'])->name('admin.botman.editSubmenu');
my button at blade.php我在刀片上的按钮。php
<a href="{{ route('admin.botman.editSubmenu', [$button, $menuUtama]) }}" type="button" class="btn bg-primary-light btn-sm">
<i class="fa fa-edit"></i>
</a>
Can i know what is my mistake?我能知道我的错误是什么吗?
I suspect that your button should pass the route parameters as an associative array, so rather than:我怀疑您的按钮应该将路由参数作为关联数组传递,而不是:
{{ route('admin.botman.editSubmenu', [$button, $menuUtama]) }}
you should be using:你应该使用:
{{ route('admin.botman.editSubmenu', ['button' => $button, 'menuUtama ' => $menuUtama]) }}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.