php 如何重定向到传入附加参数的路由?

f0brbegy  于 2022-10-30  发布在  PHP
关注(0)|答案(1)|浏览(132)

控制器:

public function edit(Request $request, Posts $posts) {
        $validatedRequests = $request->validate([
            'title' => 'required|max:255|string|integer',
            'description' => 'required|max:255|string|integer',
            'price' => 'required|integer|max:255|'
        ]);    

        $posts->update([
            'title' => $request->title,
            'description' => $request->description,
            'price' => $request->price    
        ]);    

        $posts->save();

        *return redirect(route('singelPost', ['post'=> $posts->id]))->with('mssg', 'updates successfully');* 
    }

web.php:

Route::get('/post/{post:id}', [PostController::class, 'show'])->name('singlePost');

这就是我得到的错误:* 缺少[Route:显示编辑表单] [URI:post/{post}/editForm] [缺少参数:邮件].*

yfwxisqw

yfwxisqw1#

您是否犯了错误的代码/语法?请尝试以下操作:

return redirect()->route('singlePost', $posts->id)->with('mssg', 'updates successfully');

相关问题