<?php

namespace Database\Seeders;

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

class ProjectDetailsTableSeeder extends Seeder
{
    private $table = 'project_details';
    private $langTable = 'project_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
                ]
            ]
        );

        DB::table($this->langTable)->insert(
            [
                [
                    'translation_id'    => 1,
                    'project_detail_id' => 1,
                    'language_id'       => 'en',
                    'title'             => 'Project Detail : Client Grass4You',
                    'label'             => 'Client',
                    'info'              => 'Grass4You',
                    'created_at'        => $now
                ],
                [
                    'translation_id'    => 2,
                    'project_detail_id' => 2,
                    'language_id'       => 'en',
                    'title'             => 'Project Detail : Country Portugal',
                    'label'             => 'Country',
                    'info'              => 'Portugal',
                    'created_at'        => $now
                ]
            ]
        );

        DB::table($this->websiteTable)->insert(
            [
                [
                    'website_object_id' => 1401,
                    'parent_id'         => null,
                    'object_id'         => 1,
                    'object_type'       => ProjectDetail::class,
                    'content_type'      => 'projectDetail',
                    'slug'              => 'project-detail-client-grass4you',
                    'uri'               => null,
                    'template'          => null,
                    'status'            => 'published',
                    'position'          => 1,
                    'created_at'        => $now
                ],
                [
                    'website_object_id' => 1402,
                    'parent_id'         => null,
                    'object_id'         => 2,
                    'object_type'       => ProjectDetail::class,
                    'content_type'      => 'projectDetail',
                    'slug'              => 'project-detail-country-portugal',
                    'uri'               => null,
                    'template'          => null,
                    'status'            => 'published',
                    'position'          => 2,
                    'created_at'        => $now
                ]
            ]
        );

        DB::table($this->websiteLangTable)->insert(
            [
                [
                    'wo_translation_id' => 1401,
                    'website_object_id' => 1401,
                    'wo_language_id'    => 'en',
                    'lang_slug'         => 'project-detail-client-grass4you',
                    'lang_uri'          => null,
                ],
                [
                    'wo_translation_id' => 1402,
                    'website_object_id' => 1402,
                    'wo_language_id'    => 'en',
                    'lang_slug'         => 'project-detail-country-portugal',
                    'lang_uri'          => null,
                ]
            ]
        );
    }
}
