File manager - Edit - /var/www/html/portalHomolog/app/Models/Demandas/DemandaAnexo.php
Back
<?php namespace App\Models\Demandas; use App\Models\User; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; class DemandaAnexo extends Model { protected $table = 'demanda_anexos'; protected $fillable = [ 'demanda_id', 'log_id', 'user_id', 'nome_original', 'caminho', 'mime_type', 'tamanho', ]; public function demanda(): BelongsTo { return $this->belongsTo(Demanda::class); } public function log(): BelongsTo { return $this->belongsTo(DemandaLog::class, 'log_id'); } public function autor(): BelongsTo { return $this->belongsTo(User::class, 'user_id'); } public function getTamanhoLegivel(): string { $bytes = (int) ($this->tamanho ?? 0); if ($bytes < 1024) return $bytes . ' B'; if ($bytes < 1_048_576) return round($bytes / 1024, 1) . ' KB'; return round($bytes / 1_048_576, 1) . ' MB'; } public function getIcone(): string { $mime = $this->mime_type ?? ''; if (str_starts_with($mime, 'image/')) return 'fa-image'; if ($mime === 'application/pdf') return 'fa-file-pdf'; if (str_contains($mime, 'word')) return 'fa-file-word'; if (str_contains($mime, 'excel') || str_contains($mime, 'spreadsheet')) return 'fa-file-excel'; if (str_contains($mime, 'zip') || str_contains($mime, 'rar')) return 'fa-file-zipper'; return 'fa-file'; } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.01 |
proxy
|
phpinfo
|
Settings