<?php

namespace Database\Seeders;

use App\Models\Pages;
use Illuminate\Database\Seeder;

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

        $content = [
            'name' => 'Contact Us',
            'slug' => 'contact',
            'banner_image' => 'front/images/mainBanner.webp',
            'content' => json_encode([
                'banner_heading' => 'Contact us',
                'cont_info_heading' => 'Get in touch',
                'con_form_heading' => 'Contact form',
                'con_form_btn' => 'Submit Now',
                'con_map_link' => 'https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d6417238.925823637!2d-106.31656916067374!3d38.246623322600676!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x54eab584e432360b%3A0x1c3bb99243deb742!2sUnited%20States!5e0!3m2!1sen!2s!4v1729302039529!5m2!1sen!2s',
            ])
        ];

        $pageCollection = collect($content);

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

        $contactPage = Pages::create($pageData);
        $contactPage->clearMediaCollection('banner_image');
        $contactPage->addMedia(public_path($content['banner_image']))
            ->preservingOriginal()
            ->toMediaCollection('banner_image');

    }
}
