Reputation: 193
i want to restore posts that deleted with softdeletes in laravel:
Error:
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:
Route::get('dashboard/posts/restore', 'PostController@restore');
tag in trash.blade.php
<a href="{{ action('PostController@restore', ['post' => $post->id]) }}"
data-toggle="tooltip" data-placement="top" data-original-title="restore">
</a>
Upvotes: 0
Views: 233
Reputation: 40673
You need to specify that your route accepts a parameter:
Route::get('dashboard/posts/restore/{post}', 'PostController@restore');
Upvotes: 1