Files
Kol-Manager/app/Models/RateCardProfile.php

53 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class RateCardProfile extends Model
{
protected $fillable = [
'owner_name', 'tagline', 'whatsapp',
'ig_handle', 'tiktok_handle', 'youtube_handle', 'email',
'logo_path', 'bg_color', 'accent_color', 'text_color',
'custom_footer', 'show_prices', 'access_token',
'terms_and_conditions',
'past_brands',
'brand_logo_size',
'contact_person_html',
];
protected $casts = [
'show_prices' => 'boolean',
'past_brands' => 'array',
];
/** Get the singleton profile, creating defaults if needed */
public static function getSingleton(): self
{
return static::firstOrCreate([], [
'owner_name' => config('app.name', 'Cathy Page'),
'bg_color' => '#FFF8F0',
'accent_color' => '#FFB7C5',
'text_color' => '#374151',
'show_prices' => true,
]);
}
public function getWhatsappUrlAttribute(): ?string
{
if (! $this->whatsapp) return null;
$number = preg_replace('/[^0-9]/', '', $this->whatsapp);
return "https://wa.me/{$number}";
}
public function getLogoUrlAttribute(): ?string
{
return $this->logo_path
? route('files.serve-profile-logo')
: null;
}
}