User Image Tutorial - can't get profile view...
I'm having a go at the User profile Image tutorial. I can't seem to get the the profile view to show. the error i'm receiving is:
ErrorException in 138d559faab81bd62411fb931f75f3e7a98ce5b8.php line 7: Trying to get property of non-object (View: /home/vagrant/sites/asl_rera/resources/views/profile.blade.php)
the 3 line error in the exception shows this:
at PhpEngine->evaluatePath('/home/vagrant/sites/asl_rera/storage/framework/views/138d559faab81bd62411fb931f75f3e7a98ce5b8.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'user' => null)) in CompilerEngine.php line 59
Basically saying that the name 'user' the was created in the profile fuction return view array is null....
what could be causing this?
Here's my content of my resources/views/profile.blade.php
:
@extends('user.layout.auth')
@section('content')
`<div class="container">
<div class="row">
<div id="main-spread">
<div class="panel panel-default">
<div class="panel-heading" id="panel-title">{{ Auth::user()->username }}'s RERA User Profile</div>
<div class="panel-body" id="pb-zero">
<!-- Main Page Content Goes Here!!-->
<div class="form-container">
<div class="row">
<div class="panel with-nav-tabs panel-primary">
<div class="panel-heading" id="hdg-one">
<ul class="nav nav-tabs" id="click-tabs">
<li role="presentation" class="active" id="hcpro-li"><i class="fa fa-btn fa-address-card-o"></i><a role="tab" href="#dash-home-tab" aria-controls="user profile" data-toggle="tab">User Profile</a></li>
<li role="presentation" id="admin-li"><i class="fa fa-btn fa-bank"></i><a role="tab" href="#wheelchairs-tab" aria-controls="wheelchairs" data-toggle="tab">User Account</a></li>
</ul>
</div>
<div class="panel-body" id="pb-one">
<div class="tab-content">
<div role="tabpanel" class="tab-pane fade in active" id="dash-home-tab">
<div class="form-container">
<div class="row">
<div class="col-md-12">
<div class="panel panel-default" id="form-panel">
<div class="panel-heading" id="form-head">{{ Auth::user()->username }}'s Current Profile</div>
<div class="panel-body" id="pb_inside" >
</div>
<p class="help-desk" align="center">Having trouble with this App? Dial 484.596.HELP (4357)</p>
</div>
</div>
</div>
</div>
</div>
<div class="tab-pane fade" id="wheelchairs-tab">
<div class="form-container">
<div class="row" id="form-row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading" id="wc-panel-head">
<h5 id="wc-req-head-title">{{ Auth::user()->username }}'s User Account</h5>
</div>
<div class="form-horizontal" role="form">
<!-- Start Of 2nd Tab User Account -->{{ csrf_field() }}
<img src="/uploads/avatars/{{ Auth::user()->avatar }}" style="width:150px; height:150px; float:left; border-radius:50%; margin-right:25px;">
<h2>{{ Auth::user()->firstname }} {{ Auth::user()->lastname }}'s Account</h2>
</div>
<p class="help-desk" id="app-help" align="center">Having trouble using this App? Dial 484.596.HELP (4357)</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>`
@endsection
I apologize I'm fairly new to laravel. How would I go about ensuring that the user is authenticated. I'm using laravel 5.3 and I did look over the authentical documentation. Would I use:
` use Illuminate\Support\Facades\Auth;
if (Auth::check()) { // The user is logged in... } ` Or could you point me to a better way of doing it?
Would that be wrapped around the whole HTML tags after the @section
and before the @endsection
?
Now it keeps sending me back to the log in if I click on the profile link...