I hope I understand correctly, it sounds like you are confused about how to show content in a sidebar to only logged in users?
If so, here is a good example in a blade template from the generated auth app layout:
I would make the sidebar part of the layout (or at least a partial template included in the layout with the sidebar code) if it will be used on every page.
You can also access user data in controllers with the request object:
request()->user()
Or if you Inject the request in your controller method:
public function show(\Illuminate\Http\Request $request)
{
$user = $request->user();
// ....
}
To answer this:
I heard that the most important thing is that you should never write code twice and there is the problem
Keeping code clean is important, but a little duplication won't hurt, don't obsess about DRY, try to keep it clean, test, refactor, and the codebase will improve over time. Maintainability can be more important than holding fast to principles no matter what. Including tests will help with maintainability.
Those are my opinions, but don't obsess over DRY or SRP to the point where you can't make the best decision in each case without paying tribute to the <insert pattern here> god.