'date', 'created_at' => 'datetime', 'updated_at' => 'datetime', 'deleted_at' => 'datetime', ]; public function user(): BelongsTo { return $this->belongsTo(User::class); } public function rows(): HasMany { return $this->hasMany(ConstructionSitePhotoRow::class)->orderBy('sort_order'); } public function getPhotoCount(): int { $count = 0; foreach ($this->rows as $row) { $count += $row->getPhotoCount(); } return $count; } }