You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
736 B
PHP
36 lines
736 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
|
class ComunicadoImagen extends Model
|
|
{
|
|
protected $table = 'comunicado_imagenes';
|
|
|
|
protected $fillable = [
|
|
'comunicado_id',
|
|
'imagen_path',
|
|
'orden',
|
|
];
|
|
|
|
protected $casts = [
|
|
'orden' => 'integer',
|
|
];
|
|
|
|
protected $appends = ['imagen_url'];
|
|
|
|
public function getImagenUrlAttribute(): ?string
|
|
{
|
|
return $this->imagen_path
|
|
? Storage::disk('public')->url($this->imagen_path)
|
|
: null;
|
|
}
|
|
|
|
public function comunicado(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
{
|
|
return $this->belongsTo(Comunicado::class);
|
|
}
|
|
}
|