I'm trying to count column from database but when I get data from database with controller, count is returning just 0. It should be more than. I don't know where is the problem. I'm beginner Laravel by the way. So, how can I count data from database?
My controller:
public function getProfile($username){
$follow = Follow::all();
$user = User::where('username', $username)->first();
if(isset($user)) {
return view('design2.profile', ['user'=>$user,'follow'=>$follow]);
} else {
return redirect()->route('home');
}
}
My blade is:
@foreach($user->follows as $followr)
<h6 >
<strong>
{{ count((array)$followr->following_id) }}
</strong>
</h6>
@endforeach
See Question&Answers more detail:os