-1

I have this problem, I am trying to register with auth but I keep seeing this error Trying to get property 'name' of non-object

     <div class="wrapper" id="app">
            <div class="sidebar">
<!--Tip 1: You can change the color of the sidebar using: data-color="purple | blue | green | orange | red"
Tip 2: you can also add an image using data-image tag-->


<div class="sidebar-wrapper">
     <div class="logo">
          <a href="http://www.creative-tim.com" class="simple-text">
                    <?php echo e(Auth::user()->name); ?>

                        </a>
                    </div>
                    <ul class="nav">
                        <li class="nav-item active">
                            <a class="nav-link" href="dashboard.html">
                                <i class="nc-icon nc-chart-pie-35"></i>
                                <p>Dashboard</p>
                            </a>
                        </li>

                        <li>
                            <a class="nav-link" href="./user.html">
                                <i class="nc-icon nc-circle-09"></i>

Trying to get property 'name' of non-object

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
  • 1
    This seems to indicate there is no current authenticated user. I assume if they aren't authenticated, they probably shouldn't be seeing the dashboard, so maybe something went wrong in the login process. Is this Laravel? – Don't Panic Jul 03 '19 at 16:04
  • 1
    If this is a page that should be shown to both authenticated and anonymous users, you can check that there is a current user before trying to echo the name. – Don't Panic Jul 03 '19 at 16:06
  • Possible duplicate of [Reference - What does this error mean in PHP?](https://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php) – Alon Eitan Jul 03 '19 at 17:01

1 Answers1

0

you must check auth before you reach the home page , home page ( dashboard ) need to be authenticated user but you reached it without auth ( guess user )

you can check auth from route.php like this :

Route::get('/', 'ExampleController@index')->middleware('auth');

or you can check in controller constructor like this : auth()->check()

or you can use in your view : @guest @else @endguest

Alon Eitan
  • 11,997
  • 8
  • 49
  • 58
Mohamed Ahmed
  • 760
  • 1
  • 4
  • 11