如何解决 Laravel 中的 softdelete Restore() 问题

我想恢复在 laravel 中用 softdeletes 删除的帖子:



错误:


ArgumentCountError

Too few arguments to function App\Http\Controllers\PostController::restore(), 0 passed and exactly 1 expected


帖子控制器:


public function restore($id)

{

    $post= Post::withTrashed()->findOrFail($id);

    $post->restore();

    return redirect()->action('PostController@index');

}

路线:


Route::get('dashboard/posts/restore', 'PostController@restore');

标签在trash.blade.php中


<a href="{{ action('PostController@restore', ['post' => $post->id]) }}"

  data-toggle="tooltip" data-placement="top" data-original-title="restore">

</a>


呼如林
浏览 73回答 1
1回答

慕码人8056858

您需要指定您的路线接受一个参数:Route::get('dashboard/posts/restore/{post}',&nbsp;'PostController@restore');
打开App,查看更多内容
随时随地看视频慕课网APP