Files
sam-manage/app/Models/Juil/ConstructionSitePhotoRow.php
김보곤 ca50f65124 feat: [database] codebridge DB 분리 - 118개 MNG 전용 테이블 connection 설정
- config/database.php에 codebridge connection 추가
- 78개 MNG 전용 모델에 $connection = 'codebridge' 설정
  - Admin (15): PM, 로드맵, API Explorer
  - Sales (16): 영업파트너, 수수료, 가망고객
  - Finance (9): 법인카드, 자금관리, 홈택스
  - Barobill (12): 은행/카드 동기화 관리
  - Interview (1), ESign (6), Equipment (2)
  - AI (3), Audit (3), 기타 (11)
2026-03-07 11:27:18 +09:00

56 lines
1.3 KiB
PHP

<?php
namespace App\Models\Juil;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class ConstructionSitePhotoRow extends Model
{
protected $connection = 'codebridge';
protected $table = 'construction_site_photo_rows';
protected $fillable = [
'construction_site_photo_id',
'sort_order',
'before_photo_path',
'before_photo_gcs_uri',
'before_photo_size',
'during_photo_path',
'during_photo_gcs_uri',
'during_photo_size',
'after_photo_path',
'after_photo_gcs_uri',
'after_photo_size',
];
protected $casts = [
'sort_order' => '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;
}
}