<?php

namespace Database\Seeders;

use App\Models\Pages;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;

class DeliveryPageSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        Pages::where('name', 'Delivery')->delete();

        $content = [
            'name' => 'Delivery',
            'slug' => 'delivery',
            'banner_image' => 'front/images/mainBanner.webp',
            'content' => json_encode([
                'banner_heading' => 'Delivery',
                'story_heading' => 'Delivery Information',
                'story_des' => ' <p>
            At Luxury Candles, we prioritize a seamless delivery experience to ensure that your handcrafted candles
            arrive safely and promptly. Once your order is placed, we carefully prepare your candles made from 100%
            Coco Apricot Créme Wax, ensuring that each item is fresh and ready for enjoyment.
        </p>
        <p>
            <strong>Shipping Options:</strong> We offer a variety of shipping methods to accommodate your needs.
            Once your order is
            shipped, you will receive a tracking number, allowing you to monitor its journey.
        </p>
        <p>
            <strong>Delivery Times:</strong> Standard delivery typically takes 5-7 business days, depending on your
            location. For any
            specific delivery inquiries or to discuss expedited options, please reach out to our customer service
            team.
        </p>
        <p>
            For questions regarding your order, feel free to contact us at
            <a href="mailto:info@luxury-candles.net">info@luxury-candles.net</a>
            or call us at
            <a href="tel:(240) 358 3046">(240) 358 3046</a>
            . Our dedicated team is here to assist you!
        </p> ',
            ])
        ];

        $pageCollection = collect($content);

        $pageData = $pageCollection->except([
            'banner_image',
        ])->toArray();

        $service = Pages::create($pageData);

        $service->clearMediaCollection('banner_image');
        $service->addMedia(public_path($content['banner_image']))
            ->preservingOriginal()
            ->toMediaCollection('banner_image');
    }
}
