<?php

namespace Database\Seeders;

use App\Models\BannerSetting;
use Illuminate\Database\Seeder;
use Dipokhalder\Settings\Facades\Settings;
use Dipokhalder\EnvEditor\EnvEditor;

class BannerTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $envService = new EnvEditor();
        Settings::group('banner')->set([
            'banner_title'       => $envService->getValue('DEMO') ? 'Exceptional Catering for Everyday - Fresh, Flavorful, & Memorable!' : "",
            'banner_description' => $envService->getValue('DEMO') ? 'Say goodbye to meal planning and cooking—our daily catering service ensures you enjoy fresh, delicious meals without the hassle.' : "",
            'banner_image'       => ""
        ]);

        if ($envService->getValue('DEMO') && file_exists(public_path('images/seeder/banner/banner.png'))) {
            $setting = BannerSetting::where('key', 'banner_image')->first();
            $setting->addMedia(public_path('images/seeder/banner/banner.png'))->preservingOriginal()->toMediaCollection('banner');
        }
    }
}