Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

blackshtef's avatar

Showing data in template directly or via the controller

So, let's say I want to show username of a logged in user - "Welcome to the site, John" I'm just wondering what approach would be better, putting Welcome to the site, {{Auth::user()->username}} into the blade template or getting that info through a controller and then showing it with Welcome to the site, {{$username}} I know it's a basic example, but I'm trying to figure out the best approach.

0 likes
3 replies
Snapey's avatar
Snapey
Best Answer
Level 122

it's fine to access it directly since the framework already holds the authenticated user

no point in creating a temporary variable for this

Please or to participate in this conversation.