<?php

namespace Database\Seeders;

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

class SocialMediasTableSeeder extends Seeder
{
    private $table = 'social_medias';
    private $langTable = 'social_media_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,
                    'type'              => 'linkedin',
                    'link_info'         => '{"url":"https://pt.linkedin.com/company/east-atlantic-engineering-lda","label":"LinkedIn","objectId":"","isExternal":true}',
                    'created_at'        => $now
                ],
                [
                    'id'                => 2,
                    'backend_user_id'   => 1,
                    'type'              => 'facebook',
                    'link_info'         => '{"url":"https://pt-pt.facebook.com/EastAtlanticEngineering/","label":"Facebook","objectId":"","isExternal":true}',
                    'created_at'        => $now
                ],
            ]
        );

        DB::table($this->langTable)->insert(
            [
                [
                    'translation_id'    => 1,
                    'social_media_id'   => 1,
                    'language_id'       => 'en',
                    'title'             => 'Social: LinkedIn',
                    'created_at'        => $now
                ],
                [
                    'translation_id'    => 2,
                    'social_media_id'   => 2,
                    'language_id'       => 'en',
                    'title'             => 'Social: Facebook',
                    'created_at'        => $now
                ]
            ]
        );

        DB::table($this->websiteTable)->insert(
            [
                [
                    'website_object_id' => 1201,
                    'parent_id'         => null,
                    'object_id'         => 1,
                    'object_type'       => SocialMedia::class,
                    'content_type'      => 'socialMedia',
                    'slug'              => 'media-linkedin',
                    'uri'               => null,
                    'template'          => null,
                    'status'            => 'published',
                    'position'          => 1,
                    'created_at'        => $now
                ],
                [
                    'website_object_id' => 1202,
                    'parent_id'         => null,
                    'object_id'         => 2,
                    'object_type'       => SocialMedia::class,
                    'content_type'      => 'socialMedia',
                    'slug'              => 'social-facebook',
                    'uri'               => null,
                    'template'          => null,
                    'status'            => 'published',
                    'position'          => 2,
                    'created_at'        => $now
                ]
            ]
        );

        DB::table($this->websiteLangTable)->insert(
            [
                [
                    'wo_translation_id' => 1201,
                    'website_object_id' => 1201,
                    'wo_language_id'    => 'en',
                    'lang_slug'         => 'social-linkedin',
                    'lang_uri'          => null,
                ],
                [
                    'wo_translation_id' => 1202,
                    'website_object_id' => 1202,
                    'wo_language_id'    => 'en',
                    'lang_slug'         => 'social-facebook',
                    'lang_uri'          => null,
                ],
            ]
        );
    }
}
