File manager - Edit - /var/www/html/portalHomolog/app/Models/Comunicacao/Boletim.php
Back
<?php namespace App\Models\Comunicacao; use DateTimeInterface; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Notifications\Notifiable; use Illuminate\Support\Str; use Laravel\Sanctum\HasApiTokens; class Boletim extends Model { use HasApiTokens, HasFactory, Notifiable; protected $connection = 'mysql'; public $incrementing = false; protected $keyType = 'string'; protected $table = 'bulletins'; const CREATED_AT = 'created_at'; const UPDATED_AT = 'updated_at'; protected $fillable = [ 'id', 'created_at', 'updated_at', 'publicationDate', 'month', 'number', 'title', 'url', 'fileSizeKB', 'fileName', 'description', 'extraordinaryEdition', 'indexado', 'status', ]; protected $casts = [ 'extraordinaryEdition' => 'boolean', 'publicationDate' => 'date', ]; /** * Alias para compatibilidade com telas que exibem data do BO como dt_publicacao. */ public function getDtPublicacaoAttribute(): mixed { return $this->publicationDate; } /** * Número do BO para exibição enxuta (somente o número). */ public function getNrBoAttribute(): string { $number = trim((string) ($this->attributes['number'] ?? '')); return $number !== '' ? $number : '-'; } /** * Rótulo exibido no lugar do antigo ds_numero (legislação / portarias). */ public function getDsNumeroAttribute(): string { $title = trim((string) ($this->title ?? '')); if ($title !== '') { return $title; } $number = trim((string) ($this->number ?? '')); return $number !== '' ? $number : '-'; } /** * URL pública do PDF do boletim (mesmo critério da listagem em admin/boletins). * Alguns registros têm fileName preenchido e url vazia ou inconsistente no histórico. */ public function getPublicBoPdfUrlAttribute(): ?string { $raw = trim((string) ($this->attributes['url'] ?? '')); if ($raw !== '') { if (preg_match('#^https?://#i', $raw)) { return $raw; } return asset(str_replace('\\', '/', $raw)); } $fileName = trim((string) ($this->attributes['fileName'] ?? '')); if ($fileName === '') { return null; } $base = basename(str_replace('\\', '/', $fileName)); if ($base === '' || $base === '.' || $base === '..') { return null; } return asset('storage/boletins/'.rawurlencode($base)); } public static function boot() { parent::boot(); static::creating(function ($model) { $model->id = Str::uuid(); }); } protected function serializeDate(DateTimeInterface $date) { return $date->format('Y-m-d H:i:s'); } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings