<?php

namespace Database\Seeders;

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

class AboutUsTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $envService = new EnvEditor();
        Settings::group('about_us')->set([
            'about_us_details_page_id' => $envService->getValue('DEMO') ? 1 : null,
            'about_us_title'           => $envService->getValue('DEMO') ? 'Passionately Catering, Perfecting Every Bite' : "",
            'about_us_description'     => $envService->getValue('DEMO') ? 'At TiffinKing, we bring people together with exceptional food and service. Using fresh ingredients and expert craftsmanship, we create memorable dining experiences for any occasion. Whether it’s daily corporate meals or grand celebrations, we cater with passion and precision.' : "",
            'about_us_image'           => ""
        ]);

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