<?php

namespace Database\Seeders;

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

class OpenPositionDetailsTableSeeder extends Seeder
{
    private $table = 'open_position_details';
    private $langTable = 'open_position_detail_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,
                    'created_at'        => $now
                ],
                [
                    'id'                => 2,
                    'backend_user_id'   => 1,
                    'created_at'        => $now
                ],
                [
                    'id'                => 3,
                    'backend_user_id'   => 1,
                    'created_at'        => $now
                ],
                [
                    'id'                => 4,
                    'backend_user_id'   => 1,
                    'created_at'        => $now
                ],
                [
                    'id'                => 5,
                    'backend_user_id'   => 1,
                    'created_at'        => $now
                ]
            ]
        );

        DB::table($this->langTable)->insert(
            [
                [
                    'translation_id'            => 1,
                    'open_position_detail_id'   => 1,
                    'language_id'               => 'en',
                    'title'                     => 'Language - EN & PT',
                    'detail_title'              => 'Language',
                    'text'                      => 'English or Portuguese',
                    'created_at'                => $now
                ],
                [
                    'translation_id'            => 2,
                    'open_position_detail_id'   => 2,
                    'language_id'               => 'en',
                    'title'                     => 'Language - EN',
                    'detail_title'              => 'Language',
                    'text'                      => 'English',
                    'created_at'                => $now
                ],
                [
                    'translation_id'            => 3,
                    'open_position_detail_id'   => 3,
                    'language_id'               => 'en',
                    'title'                     => 'Experience - Junior',
                    'detail_title'              => 'Experience',
                    'text'                      => 'Entry level',
                    'created_at'                => $now
                ],
                [
                    'translation_id'            => 4,
                    'open_position_detail_id'   => 4,
                    'language_id'               => 'en',
                    'title'                     => 'Experience - Intermediate',
                    'detail_title'              => 'Experience',
                    'text'                      => 'Intermediate',
                    'created_at'                => $now
                ],
                [
                    'translation_id'            => 5,
                    'open_position_detail_id'   => 5,
                    'language_id'               => 'en',
                    'title'                     => 'Location - PT',
                    'detail_title'              => 'Location',
                    'text'                      => 'Lisbon, Portugal',
                    'created_at'                => $now
                ],
            ]
        );

        DB::table($this->websiteTable)->insert(
            [
                [
                    'website_object_id' => 701,
                    'parent_id'         => null,
                    'object_id'         => 1,
                    'object_type'       => OpenPositionDetail::class,
                    'content_type'      => 'openPositionDetail',
                    'slug'              => 'language-en-pt',
                    'uri'               => null,
                    'template'          => null,
                    'status'            => 'published',
                    'position'          => 1,
                    'created_at'        => $now
                ],
                [
                    'website_object_id' => 702,
                    'parent_id'         => null,
                    'object_id'         => 2,
                    'object_type'       => OpenPositionDetail::class,
                    'content_type'      => 'openPositionDetail',
                    'slug'              => 'language-en',
                    'uri'               => null,
                    'template'          => null,
                    'status'            => 'published',
                    'position'          => 2,
                    'created_at'        => $now
                ],
                [
                    'website_object_id' => 703,
                    'parent_id'         => null,
                    'object_id'         => 3,
                    'object_type'       => OpenPositionDetail::class,
                    'content_type'      => 'openPositionDetail',
                    'slug'              => 'experience-junior',
                    'uri'               => null,
                    'template'          => null,
                    'status'            => 'published',
                    'position'          => 3,
                    'created_at'        => $now
                ],
                [
                    'website_object_id' => 704,
                    'parent_id'         => null,
                    'object_id'         => 4,
                    'object_type'       => OpenPositionDetail::class,
                    'content_type'      => 'openPositionDetail',
                    'slug'              => 'experience-intermediate',
                    'uri'               => null,
                    'template'          => null,
                    'status'            => 'published',
                    'position'          => 4,
                    'created_at'        => $now
                ],
                [
                    'website_object_id' => 705,
                    'parent_id'         => null,
                    'object_id'         => 5,
                    'object_type'       => OpenPositionDetail::class,
                    'content_type'      => 'openPositionDetail',
                    'slug'              => 'location-pt',
                    'uri'               => null,
                    'template'          => null,
                    'status'            => 'published',
                    'position'          => 5,
                    'created_at'        => $now
                ]
            ]
        );

        DB::table($this->websiteLangTable)->insert(
            [
                [
                    'wo_translation_id' => 701,
                    'website_object_id' => 701,
                    'wo_language_id'    => 'en',
                    'lang_slug'         => 'language-en-pt',
                    'lang_uri'          => null,
                ],
                [
                    'wo_translation_id' => 702,
                    'website_object_id' => 702,
                    'wo_language_id'    => 'en',
                    'lang_slug'         => 'language-en',
                    'lang_uri'          => null,
                ],
                [
                    'wo_translation_id' => 703,
                    'website_object_id' => 703,
                    'wo_language_id'    => 'en',
                    'lang_slug'         => 'experience-junior',
                    'lang_uri'          => null,
                ],
                [
                    'wo_translation_id' => 704,
                    'website_object_id' => 704,
                    'wo_language_id'    => 'en',
                    'lang_slug'         => 'experience-intermediate',
                    'lang_uri'          => null,
                ],
                [
                    'wo_translation_id' => 705,
                    'website_object_id' => 705,
                    'wo_language_id'    => 'en',
                    'lang_slug'         => 'location-pt',
                    'lang_uri'          => null,
                ]
            ]
        );
    }
}
