<?php

namespace Database\Seeders;

use App\Models\GenericBackoffice\Footer;
use Illuminate\Database\Seeder;
use Carbon\Carbon;
use Illuminate\Support\Facades\DB;

class FooterTableSeeder extends Seeder
{
    private $table = 'footer';
    private $langTable = 'footer_languages';

    private $websiteTable = 'website_objects';
    private $websiteLangTable = 'website_objects_lang';

    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        // Table already deleted in DatabaseSeeder

        $now = Carbon::now();

        DB::table($this->table)->insert(
            [
                [
                    'id'                => 1,
                    'backend_user_id'   => 1,
                    'legal_link_info'   => '{"url":null,"label":"Legal policies","objectId":"107","isExternal":false}',
                    'email_contact'     => '{"url":"mailto://contact@eae.pt","label":"m. contact@eae.pt","objectId":"","isExternal":true}',
                    'phone_contact'     => '{"url":"tel://00351210532067","label":"p. 00351 210 532 067","objectId":"","isExternal":true}',
                    'created_at'        => $now
                ]
            ]
        );

        DB::table($this->langTable)->insert(
            [
                [
                    'translation_id'    => 1,
                    'footer_id'         => 1,
                    'language_id'       => 'en',
                    'title'             => 'Footer',
                    'address'           => "Rua Garrett 74, 3º dto,\r\n1200-204 Lisboa,\r\nPortugal",
                    'copyright_text'    => "©{year} All Rights reserved",
                    'funny_phrase'      => 'Play it again Sam',
                    'created_at'        => $now
                ]
            ]
        );

        DB::table($this->websiteTable)->insert(
            [
                [
                    'website_object_id' => 1301,
                    'parent_id'         => null,
                    'object_id'         => 1,
                    'object_type'       => Footer::class,
                    'content_type'      => 'footer',
                    'slug'              => 'footer',
                    'uri'               => null,
                    'template'          => null,
                    'status'            => 'published',
                    'position'          => 1,
                    'created_at'        => $now
                ]
            ]
        );

        DB::table($this->websiteLangTable)->insert(
            [
                [
                    'wo_translation_id' => 1301,
                    'website_object_id' => 1301,
                    'wo_language_id'    => 'en',
                    'lang_slug'         => 'footer',
                    'lang_uri'          => null,
                ],
            ]
        );
    }
}
