2026-03-12 21:11:21 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models\Juil;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
|
|
|
|
|
|
class PmisNoticeAttachment extends Model
|
|
|
|
|
{
|
2026-03-19 20:21:42 +09:00
|
|
|
protected $connection = 'codebridge';
|
|
|
|
|
|
2026-03-12 21:11:21 +09:00
|
|
|
protected $fillable = [
|
|
|
|
|
'notice_id',
|
|
|
|
|
'original_name',
|
|
|
|
|
'file_path',
|
|
|
|
|
'file_size',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
public function notice(): BelongsTo
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(PmisNotice::class, 'notice_id');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function formatSize(int $bytes): string
|
|
|
|
|
{
|
|
|
|
|
if ($bytes >= 1073741824) {
|
|
|
|
|
return round($bytes / 1073741824, 1).' G';
|
|
|
|
|
}
|
|
|
|
|
if ($bytes >= 1048576) {
|
|
|
|
|
return round($bytes / 1048576, 1).' M';
|
|
|
|
|
}
|
|
|
|
|
if ($bytes >= 1024) {
|
|
|
|
|
return round($bytes / 1024, 1).' K';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $bytes.' B';
|
|
|
|
|
}
|
|
|
|
|
}
|