- ConstructionSitePhotoRow 모델 추가 - 부모 모델에서 사진 컬럼 제거, rows() 관계 추가 - 서비스/컨트롤러에 행 추가/삭제 기능 추가 - 라우트를 행 기반 URL 구조로 변경 - 프론트엔드 멀티행 UI 전면 개편 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
53 lines
1.1 KiB
PHP
53 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Juil;
|
|
|
|
use App\Models\User;
|
|
use App\Traits\BelongsToTenant;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class ConstructionSitePhoto extends Model
|
|
{
|
|
use BelongsToTenant, SoftDeletes;
|
|
|
|
protected $table = 'construction_site_photos';
|
|
|
|
protected $fillable = [
|
|
'tenant_id',
|
|
'user_id',
|
|
'site_name',
|
|
'work_date',
|
|
'description',
|
|
];
|
|
|
|
protected $casts = [
|
|
'work_date' => '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;
|
|
}
|
|
}
|