<?php

namespace Database\Seeders;

use App\Models\GenericBackoffice\BlogArticle;
use App\Models\GenericBackoffice\OpenPosition;
use App\Models\GenericBackoffice\Project;
use Illuminate\Database\Seeder;
use Carbon\Carbon;
use Illuminate\Support\Facades\DB;

class BlogArticlesTableSeeder extends Seeder
{
    private $table = 'blog_articles';
    private $langTable = 'blog_article_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,
                    'main_image_id'     => 1,
                    'backend_user_id'   => 1,
                    'meta_image_id'     => 1,
                    'created_at'        => $now
                ]
            ]
        );

        DB::table($this->langTable)->insert(
            [
                [
                    'translation_id'    => 1,
                    'blog_article_id'   => 1,
                    'language_id'       => 'en',
                    'article_title'     => 'Meet our Magento Lead',
                    'title'             => 'Blog: Magento Lead',
                    'meta_title'        => 'Meet our Magento Lead',
                    'meta_description'  => 'Meet our Magento Lead',
                    'created_at'        => $now
                ]
            ]
        );

        DB::table($this->websiteTable)->insert(
            [
                [
                    'website_object_id' => 1601,
                    'parent_id'         => null,
                    'object_id'         => 1,
                    'object_type'       => BlogArticle::class,
                    'content_type'      => 'blogArticle',
                    'slug'              => 'blog-magento-lead',
                    'uri'               => '/blog/blog-magento-lead',
                    'template'          => null,
                    'status'            => 'published',
                    'position'          => 1,
                    'created_at'        => $now
                ]
            ]
        );

        DB::table($this->websiteLangTable)->insert(
            [
                [
                    'wo_translation_id' => 1601,
                    'website_object_id' => 1601,
                    'wo_language_id'    => 'en',
                    'lang_slug'         => 'blog-magento-lead',
                    'lang_uri'          => '/blog/blog-magento-lead',
                ]
            ]
        );
    }
}
