I have code that is using the withTrashed() and restore() methods. Its working but it is restoring everything, not just the ID I want restored. Not sure how to fix that.
Restore function
public function Restore($id){
$delete = Category::find($id)->withTrashed()->restore();
return redirect()->back()->with('success','Category has been restored successfully!');
}
Link and route for restore
<a href="{{ url('category/restore/'.$category->id) }}" class="btn btn-info btn-sm">Restore</a>
Route::get('/category/restore/{id}', [CategoryController::class, 'Restore']);
Model
public function user()
{
return $this->hasOne(User::class,'id','user_id');
}