You have user_id in your photos() relation. That should probably be album_id and that's why it's 0.
You have to call the following to count directly from the database:
$album->photos()->count()
Note the () after photos. But this queries the DB every time it is used so you probably better cache the result somewhere.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community