Я новичок в веб-разработке, и пытаюсь создать панель управления с laravel, и пытаюсь передать свои данные laravel, но я не могу этого сделать, я получаю сообщение об ошибке выше,
Trying to get property 'count' of non-object
Итак, как я могу получить данные подсчета и данные пользователей в моих представлениях, вот мой контроллер:
public function dashboard()
{
$countActiveUser = User::where('status',0)->get();
$countLatestUser = User::latest()->get();
$countBlockedUser = User::where('status',1)->get();
$countTotalUser = User::all();
$dataCount['activeUserCount'] = count($countActiveUser);
$dataCount['blockedUserCount'] = count($countBlockedUser);
$dataCount['latestUserCount'] = count($countLatestUser);
$dataCount['allUserCount'] = count($countTotalUser);
$data['users']=$countTotalUser;
$data['count']=$dataCount;
return view('dashboard',['data'=>$data,]);
}
и вот как я пытаюсь получить свои значения в dashboard.blade \
<span class="h2 font-weight-bold mb-0">{{$data->count->activeUserCount}}</span>
возвращаемые данные:
{
"data": {
"user": [
{
"id": 1,
"name": "user0",
"email": "nabrajkhadka43@gmail.com",
"phone": null,
"email_verified_at": null,
"profile_pic_url": null,
"lat": null,
"lon": null,
"bio": null,
"created_at": null
},
{
"id": 2,
"name": "user1",
"email": "email1@gmail.com",
"phone": null,
"email_verified_at": "Apr 15 2020",
"profile_pic_url": null,
"lat": null,
"lon": null,
"bio": null,
"created_at": "Apr 22 2020"
},
{
"id": 3,
"name": "user2",
"email": "email2@gmail.com",
"phone": null,
"email_verified_at": null,
"profile_pic_url": null,
"lat": null,
"lon": null,
"bio": null,
"created_at": null
},
{
"id": 4,
"name": "user3",
"email": "email3@gmail.com",
"phone": null,
"email_verified_at": null,
"profile_pic_url": null,
"lat": null,
"lon": null,
"bio": null,
"created_at": null
},
{
"id": 5,
"name": "user4",
"email": "email4@gmail.com",
"phone": null,
"email_verified_at": null,
"profile_pic_url": null,
"lat": null,
"lon": null,
"bio": null,
"created_at": null
},
{
"id": 6,
"name": "user5",
"email": "email5@gmail.com",
"phone": null,
"email_verified_at": null,
"profile_pic_url": null,
"lat": null,
"lon": null,
"bio": null,
"created_at": null
},
{
"id": 7,
"name": "user6",
"email": "email6@gmail.com",
"phone": null,
"email_verified_at": null,
"profile_pic_url": null,
"lat": null,
"lon": null,
"bio": null,
"created_at": null
},
{
"id": 8,
"name": "user7",
"email": "email7@gmail.com",
"phone": null,
"email_verified_at": null,
"profile_pic_url": null,
"lat": null,
"lon": null,
"bio": null,
"created_at": null
},
{
"id": 9,
"name": "user8",
"email": "email8@gmail.com",
"phone": null,
"email_verified_at": null,
"profile_pic_url": null,
"lat": null,
"lon": null,
"bio": null,
"created_at": null
},
{
"id": 10,
"name": "user9",
"email": "email9@gmail.com",
"phone": null,
"email_verified_at": null,
"profile_pic_url": null,
"lat": null,
"lon": null,
"bio": null,
"created_at": null
},
{
"id": 24,
"name": "hari Khadka",
"email": "password@gmail.com",
"phone": null,
"email_verified_at": null,
"profile_pic_url": "2020-04-01-1324237408.jpg",
"lat": null,
"lon": null,
"bio": null,
"created_at": "Apr 01 2020"
},
{
"id": 26,
"name": "hari Khadka",
"email": "emaiasdl1@gmail.com",
"phone": null,
"email_verified_at": null,
"profile_pic_url": "2020-04-10-1742149546.jpg",
"lat": null,
"lon": null,
"bio": null,
"created_at": "Apr 10 2020"
},
{
"id": 27,
"name": "alfredaosd",
"email": "nabrajkhssadka43@gmail.com",
"phone": null,
"email_verified_at": null,
"profile_pic_url": null,
"lat": null,
"lon": null,
"bio": null,
"created_at": "Apr 10 2020"
}
],
"count": {
"activeUserCount": 9,
"blockedUserCount": 4,
"latestUserCount": 13,
"allUserCount": 13
}
}
}
я знаю, что это дублирующий вопрос, но, пожалуйста, помогите мне.