<?php

namespace App\Models;

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

class ConfiguracionNegocio extends Model
{
    protected $table = 'configuracion_negocio';

    protected $fillable = ['nombre', 'nif', 'direccion', 'telefono', 'email', 'logo_path', 'fondo_login_path'];

    public static function actual(): self
    {
        return static::first() ?? static::create(['nombre' => 'Mi Negocio']);
    }

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

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