如何解决 laravel 中的 softdelete restore() 问题
How to resolve problem softdelete restore() in laravel
我想恢复在 laravel 中用软删除删除的帖子:
错误:
ArgumentCountError
Too few arguments to function App\Http\Controllers\PostController::restore(), 0 passed and exactly 1 expected
PostsController:
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>
您需要指定您的路由接受一个参数:
Route::get('dashboard/posts/restore/{post}', 'PostController@restore');
我想恢复在 laravel 中用软删除删除的帖子:
错误:
ArgumentCountError
Too few arguments to function App\Http\Controllers\PostController::restore(), 0 passed and exactly 1 expected
PostsController:
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>
您需要指定您的路由接受一个参数:
Route::get('dashboard/posts/restore/{post}', 'PostController@restore');