- PMIS 모델 21개 + DailyWorkLog 2개에 $connection = 'codebridge' 추가 - MNG 마이그레이션 파일 18개 전체 삭제 (API에서 관리) - 원칙: MNG는 마이그레이션 파일을 생성하지 않고 API에서만 관리
52 lines
1.1 KiB
PHP
52 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Juil;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class PmisArchiveFolder extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $connection = 'codebridge';
|
|
|
|
protected $fillable = [
|
|
'tenant_id',
|
|
'parent_id',
|
|
'name',
|
|
'sort_order',
|
|
'options',
|
|
];
|
|
|
|
protected $casts = [
|
|
'options' => 'array',
|
|
];
|
|
|
|
public function scopeTenant($query, $tenantId)
|
|
{
|
|
return $query->where('tenant_id', $tenantId);
|
|
}
|
|
|
|
public function children(): HasMany
|
|
{
|
|
return $this->hasMany(self::class, 'parent_id')->orderBy('sort_order');
|
|
}
|
|
|
|
public function files(): HasMany
|
|
{
|
|
return $this->hasMany(PmisArchiveFile::class, 'folder_id');
|
|
}
|
|
|
|
public function allDescendantIds(): array
|
|
{
|
|
$ids = [$this->id];
|
|
foreach ($this->children as $child) {
|
|
$ids = array_merge($ids, $child->allDescendantIds());
|
|
}
|
|
|
|
return $ids;
|
|
}
|
|
}
|