Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LARAVEL 5 :: Display 'username' on homepage?

So the new version of Laravel has a login and register system already built in and so I've changed some fields in the register page and now want the 'username' to be displayed instead of the 'name' on the homepage after login. Does anyone have a clue where this is attributed? Have been searching endlessly for this. Thanks.

like image 431
Hyperion Avatar asked Feb 21 '15 19:02

Hyperion


People also ask

What is Auth :: Routes () in Laravel?

Auth::routes() is just a helper class that helps you generate all the routes required for user authentication. You can browse the code here https://github.com/laravel/framework/blob/5.3/src/Illuminate/Routing/Router.php instead.

How do I get Auth username in blade Laravel?

You can call the Auth facade in your views. $userInfo = User::find(Auth::id())->with('personalInfo')->first(); return View::make('page')->with('userInfo',$userInfo); //in your view then you have access to {{$userInfo->name }} {{$userInfo->address}} //the values from the table and related model.


Video Answer


2 Answers

The file you are looking for, is the app view file. This file defines a sample basic template for your website.
It is located here: resources/views/app.blade.php
In your case, you need to change {{ Auth::user()->name }} to {{ Auth::user()->username }}

like image 59
Jad Joubran Avatar answered Oct 17 '22 00:10

Jad Joubran


You can find logged user name with this below code

in any blade template you just write

@if (Auth::user()->name=="user_name")
    //your code after prove authentication                       
@endif
like image 28
purvisha thakarar Avatar answered Oct 17 '22 00:10

purvisha thakarar