<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class ServicePageContent extends Model
{
    protected $fillable = ['content'];

    protected function casts(): array
    {
        return [
            'content' => 'array',
        ];
    }

    public static function defaults(): array
    {
        return [
            'seo' => [
                'title' => 'Services - ' . config('app.name'),
                'description' => 'Explore our complete study abroad services from admission strategy to post-admission support.',
            ],
            'hero' => [
                'title' => 'Find out what we do, how we do and how it benefits you',
                'highlight' => 'what we do',
                'text' => 'We provide comprehensive study abroad services to help you achieve your international education goals.',
                'button' => 'Book A Free Consultation',
                'image' => 'https://images.unsplash.com/photo-1573496773905-f5b17e717f05?auto=format&fit=crop&w=1200&q=80',
            ],
            'offer' => [
                'title' => 'What we Offer',
                'highlight' => 'Offer',
                'text' => 'We provide comprehensive services designed around your study-abroad journey.',
            ],
            'services' => [
                [
                    'title' => 'Expert Guidance',
                    'text' => 'From country and university selection to application planning, our counselors help you choose the right path.',
                    'image' => 'https://images.unsplash.com/photo-1552664730-d307ca884978?auto=format&fit=crop&w=1200&q=80',
                ],
                [
                    'title' => 'Test Prep Support',
                    'text' => 'We guide you with IELTS and English preparation strategy to improve your admission readiness.',
                    'image' => 'https://images.unsplash.com/photo-1456513080510-7bf3a84b82f8?auto=format&fit=crop&w=1200&q=80',
                ],
                [
                    'title' => 'Scholarship Support',
                    'text' => 'Our experts help identify scholarship options aligned to your profile and destination.',
                    'image' => 'https://images.unsplash.com/photo-1434030216411-0b793f4b4173?auto=format&fit=crop&w=1200&q=80',
                ],
                [
                    'title' => 'Visa Support',
                    'text' => 'We provide end-to-end visa documentation and interview preparation support.',
                    'image' => 'https://images.unsplash.com/photo-1488646953014-85cb44e25828?auto=format&fit=crop&w=1200&q=80',
                ],
                [
                    'title' => 'Flight and Accommodation Support',
                    'text' => 'We assist with travel planning and accommodation guidance before departure.',
                    'image' => 'https://images.unsplash.com/photo-1521295121783-8a321d551ad2?auto=format&fit=crop&w=1200&q=80',
                ],
                [
                    'title' => 'Post-Admission Support',
                    'text' => 'After admission, we stay connected to help with onboarding and transition support.',
                    'image' => 'https://images.unsplash.com/photo-1520607162513-77705c0f0d4a?auto=format&fit=crop&w=1200&q=80',
                ],
            ],
            'final_cta' => [
                'title' => 'Still wondering what to do?',
                'text' => 'Send us a message and our expert counselors will help you.',
                'button' => 'Book A Free Consultation',
                'image' => 'https://images.unsplash.com/photo-1573496359142-b8d87734a5a2?auto=format&fit=crop&w=900&q=80',
            ],
        ];
    }

    public static function getContent(): array
    {
        $row = static::query()->first();
        $stored = $row?->content ?? [];

        return array_replace_recursive(static::defaults(), $stored);
    }

    public static function saveContent(array $content): void
    {
        static::query()->updateOrCreate(
            ['id' => 1],
            ['content' => $content]
        );
    }
}