<?php

namespace Database\Seeders;

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

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

        $content = [
            'name' => 'Luxury Candles',
            'slug' => 'luxury-candles',
            'banner_image' => 'front/images/mainBanner.webp',
            'content' => json_encode([
                'banner_heading' => 'Luxury Candles',
                'main_heading' => 'Candles which will take away all your worries',
            ])

        ];

        $pageCollection = collect($content);

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

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

    }
}
