I am getting this error in my view , My view source code is here. Everything was working but suddenly I am getting this error and unable to find from where this problem occurs.
There are three tables in DB Users regulars and posts I want to retrieve the data of the authenticated user in this profile view but getting this exception.I will be highly thankful to stack overflow members for providing me the solution.
<div class="panel panel-danger">
<div class="panel-body">
<blockquote class="col-md-3">
<img style="width:210px ; height: 230px " src="">
<h2></h2>
</blockquote>
<div class="well col-md-9 details">
<h4>Email : </h4>
<h3>Phone No: </h3>
<h4>Gender: </h4>
<h4>Country: </h4>
</div>
</div>
</div>
<div class="panel panel-danger">
<div class="panel-body">
@foreach($posts as $post)
<blockquote class="col-md-3">
<p></p>
<div class="info">
Posted by <h4> </h4>on
</div>
<div class="interaction">
<a href="#">Like</a> |
<a href="#">Dislike</a>
@if(Auth::user() == $post->user)
|<a href="#">Edit</a> |
<a href="">Delete</a>
@endif
</blockquote>
@endforeach
My controller function for retrieving data is here . Here I am accessing data of authenticated user from 3 tables of database.
public function userProfile() {
$user_id = Auth::user()->id;
$user1 = User::where('id',$user_id)->first();
$user2 = Regular::where('user_id',$user_id)->first();
$posts = Post::where('id',$user_id)->first();
return view('frontend.layouts.Profile',compact('user1','user2','posts'));
}
via Taiba Rani