<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Facades\Storage;

class ProcesoAdmisionDetalle extends Model
{
    protected $table = 'proceso_admision_detalles';

    protected $fillable = [
        'proceso_admision_id',
        'tipo',
        'titulo_detalle',
        'descripcion',
        'listas',
        'meta',
        'url',
        'imagen_path',
        'imagen_path_2',
    ];

    protected $casts = [
        'listas' => 'array',
        'meta' => 'array',
    ];

    protected $appends = ['imagen_url','imagen_url_2'];

    public function proceso(): BelongsTo
    {
        return $this->belongsTo(ProcesoAdmision::class, 'proceso_admision_id');
    }

    public function getImagenUrlAttribute(): ?string
    {
        return $this->imagen_path ? Storage::disk('public')->url($this->imagen_path) : null;
    }

    public function getImagenUrl2Attribute(): ?string
    {
        return $this->imagen_path_2 ? Storage::disk('public')->url($this->imagen_path_2) : null;
    }
}
