File manager - Edit - /var/www/html/portal/app/Models/Contratos/ContratoArquivo.php
Back
<?php namespace App\Models\Contratos; use App\Http\Services\ContratoService; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Support\Facades\Storage; class ContratoArquivo extends Model { use HasFactory; protected $table = 'contratos_arquivos'; protected $primaryKey = 'id_arquivo'; protected $fillable = [ 'arq_id_contrato', 'arq_sequencia', 'arq_arquivo', 'arq_numero', 'arq_titulo', 'arq_dataini', 'arq_datafim', ]; public function contrato(): BelongsTo { return $this->belongsTo(Contrato::class, 'arq_id_contrato', 'id'); } public function getArquivoUrlAttribute(): ?string { $rawPath = trim((string) $this->arq_arquivo); if ($rawPath === '') { return null; } if (preg_match('#^https?://#i', $rawPath)) { return $rawPath; } $normalizedPath = ltrim(str_replace('\\', '/', $rawPath), '/'); if ($normalizedPath === '' || str_contains($normalizedPath, '..')) { return null; } $storagePath = str_starts_with($normalizedPath, 'storage/') ? ltrim(substr($normalizedPath, strlen('storage/')), '/') : $normalizedPath; if ($storagePath !== '' && Storage::disk('public')->exists($storagePath)) { $fileName = basename($storagePath); return asset(ContratoService::UPLOAD_PUBLIC_PREFIX . '/' . rawurlencode($fileName)); } return 'https://angra.rj.gov.br/SAPO/_licitacao/adm/contratos/' . rawurlencode(basename($normalizedPath)); } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.01 |
proxy
|
phpinfo
|
Settings