'integer', 'before_photo_size' => 'integer', 'during_photo_size' => 'integer', 'after_photo_size' => 'integer', ]; public function constructionSitePhoto(): BelongsTo { return $this->belongsTo(ConstructionSitePhoto::class); } public function hasPhoto(string $type): bool { return ! empty($this->{$type.'_photo_path'}); } public function getPhotoCount(): int { $count = 0; foreach (['before', 'during', 'after'] as $type) { if ($this->hasPhoto($type)) { $count++; } } return $count; } }