<?php

namespace Database\Seeders;

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

class HomePageSliderSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        //
        $services = [
            [
                'title' => 'Bring the natural aroma',
                'decuraton_text' => '100% Coco Apricot Créme Wax',
                'description' => 'The product is made from',
                'btn_text' => 'Shop More',
                'slider_video' => 'front/images/video1.mp4',
            ],
            [
                'title' => 'Bring the natural aroma',
                'decuraton_text' => '100% Coco Apricot Créme Wax',

                'description' => 'The product is made from',
                'slider_video' => 'front/images/video1.mp4',
                'btn_text' => 'Shop More',
            ],

        ];

        foreach ($services as $serviceData) {
            $ourService = HomePageSlider::create([
                'title' => $serviceData['title'],
                'description' => $serviceData['description'],
                'decuraton_text' => $serviceData['decuraton_text'],
                'btn_text' => $serviceData['btn_text'],
            ]);


            $fullPath = public_path($serviceData['slider_video']);
            if (file_exists($fullPath)) {
                if (!$ourService->getMedia('slider_video')->where('file_name', basename($fullPath))->first()) {
                    $ourService->addMedia($fullPath)
                        ->preservingOriginal()
                        ->toMediaCollection('slider_video');
                }
            }
        }
    }
}
