- ConstructionSitePhotoRow 모델 추가 - 부모 모델에서 사진 컬럼 제거, rows() 관계 추가 - 서비스/컨트롤러에 행 추가/삭제 기능 추가 - 라우트를 행 기반 URL 구조로 변경 - 프론트엔드 멀티행 UI 전면 개편 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
55 lines
1.3 KiB
PHP
55 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 $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;
|
|
}
|
|
}
|