Support the ongoing development of Laravel.io →
Eloquent Laravel.io
Last updated 1 year ago.
0
  1. You have user_id in your photos() relation. That should probably be album_id and that's why it's 0.

  2. 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.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

ajeeeunni ajeeeunni Joined 28 Nov 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.