<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use App\Models\Pages;
use Illuminate\Support\Facades\Storage;

class HomePageSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        Pages::where('name', 'Home')->delete();
        $content = [
            'name' => 'Home',
            'slug' => 'home',
            'story_image1' => 'front/images/video2.mp4',
            'story_image2' => 'front/images/product10.jpeg',
            'story_image3' => 'front/images/product11.jpeg',
            'story_image4' => 'front/images/product12.jpeg',
            'story_image5' => 'front/images/product13.jpeg',
            'story_image6' => 'front/images/product14.jpeg',
            'story_image7' => 'front/images/product15.jpeg',
            'content' => json_encode([
                'pro_main_heading' => 'Candles which will take away all your worries',

                'home_sto1_desc' => 'Sometimes you just need to light a Luxury Candle take a deep breath inhale peace and
                exhale happiness. This will allow you to relax and recharge',
                'home_sto1_info' => 'Antonio Yarborough • CEO Luxury Candles',
                'home_sto2_heading' => 'Candles to make you save more',
                'home_sto2_desc' => 'Experience the elegance and warmth of luxury candles designed to enhance your space and help you save. Each candle is crafted with care, combining rich scents with eco-friendly materials for a long-lasting burn and a touch of sophistication to elevate any room. Illuminate your home with quality you can feel and scents you’ll love, while making a mindful choice for the environment and your budget.',
                'home_sto2_btn_text' => 'SHOW MORE',
                'home_sto3_heading' => 'We try to make the best Luxury Candles',
                'home_sto3_des1' => '100% Coco Apricot Créme Wax.',
                'home_sto3_des2' => 'Hand Made to order',
                'home_sto3_des3' => 'Made from all-natural waxes and essential oils, ensuring a clean, eco-friendly burn.',
                'home_sto3_des4' => 'Each candle is hand-poured to perfection, reflecting the artistry and dedication of our craft.',
                'home_sto3_des5' => 'Designed to last, providing extended hours of fragrance and warmth.',
                'home_sto3_btn' => 'Learn more about us ',
                'home_sto4_heading' => 'Burn your candle of life',
                'home_sto4_img1_title' => 'Bathroom',
                'home_sto4_img2_title' => 'Living Room',
                'home_gallery_heading' => 'Trend This Yea'

            ])
        ];

        $homeData = collect($content)->except(
            'story_image1',
            'story_image2',
            'story_image3',
            'story_image4',
            'story_image5',
            'story_image6',
            'story_image7',
        )->all();

        $page = Pages::create($homeData);

        $page->clearMediaCollection('story_image1');
        $page->addMedia(public_path($content['story_image1']))
            ->preservingOriginal()
            ->toMediaCollection('story_image1');

        $page->clearMediaCollection('story_image2');
        $page->addMedia(public_path($content['story_image2']))
            ->preservingOriginal()
            ->toMediaCollection('story_image2');

        $page->clearMediaCollection('story_image3');
        $page->addMedia(public_path($content['story_image3']))
            ->preservingOriginal()
            ->toMediaCollection('story_image3');

        $page->clearMediaCollection('story_image4');
        $page->addMedia(public_path($content['story_image4']))
            ->preservingOriginal()
            ->toMediaCollection('story_image4');


        $page->clearMediaCollection('story_image5');
        $page->addMedia(public_path($content['story_image5']))
            ->preservingOriginal()
            ->toMediaCollection('story_image5');

        $page->clearMediaCollection('story_image6');
        $page->addMedia(public_path($content['story_image6']))
            ->preservingOriginal()
            ->toMediaCollection('story_image6');


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