<?php

use Illuminate\Database\Seeder;
use App\Pagename;
use App\PagenameLocale;
use App\Meta;
use Faker\Factory;

class PageTableSeeder extends Seeder
{
    protected $faker;

    public function __construct()
    {
      // $this->faker = [
      //   'id' => Factory::create('id'),
      //   'en' => Factory::create('en'),
      //   'fr' => Factory::create('fr'),
      // ];
    }


    public function generateMetaTags()
    {
      // $locales = [];
      //
      // foreach (['en', 'id', 'fr'] as $lang) {
      //   array_push([
      //     'title' => $this->faker[$lang]->sentence,
      //     'description' => $this->faker[$lang]->paragraphs(3, true),
      //     'keywords' => implode(',', $this->faker[$lang]->words(rand(4, 6)))
      //   ]);
      // }
      // return $locales;
    }

    public function run()
    {
        $pages = [
          [
            'slug' => 'home',
            'key' => 'home',
            'locales' => [
              'en' => 'Home',
              'id' => 'Beranda',
              'fr' => 'Home [FR]'
            ],
            'generals' => [
              'general_title' => 'sentence',
              'general_content' => 'paragraph',
              'general_url',
              'general_section',
              'general_desc',
              'general_page',
              'temp_id' => null
            ]
          ],
          [
            'slug' => 'toko',
            'key' => 'product',
            'locales' => [
              'en' => 'Store',
              'id' => 'Toko',
              'fr' => 'Store [FR]'
            ]
          ],
          [
            'slug' => 'halaman-a',
            'key' => 'section1',
            'locales' => [
              'en' => 'Section A',
              'id' => 'Halaman A',
              'fr' => 'Section A [FR]'
            ]
          ],
          [
            'slug' => 'halaman-b',
            'key' => 'section2',
            'locales' => [
              'en' => 'Section B',
              'id' => 'Halaman B',
              'fr' => 'Section B [FR]'
            ]
          ],
          [
            'slug' => 'tentang-kami',
            'key' => 'about',
            'locales' => [
              'en' => 'About us',
              'id' => 'Tentang kami',
              'fr' => 'About us [FR]'
            ]
          ],
          [
            'slug' => 'kontak',
            'key' => 'contact',
            'locales' => [
              'en' => 'Contact',
              'id' => 'Kontak',
              'fr' => 'Contact [FR]'
            ]
          ],
          [
            'slug' => 'artikel',
            'key' => 'article',
            'locales' => [
              'en' => 'Article',
              'id' => 'Artikel',
              'fr' => 'Article [FR]'
            ]
          ],
          [
            'slug' => 'badan-hukum',
            'key' => 'mentionslegales',
            'locales' => [
              'en' => 'Mention Legales',
              'id' => 'Badan Hukum',
              'fr' => 'Mention Legales [FR]'
            ]
          ]
      	];

      	foreach ($pages as $page) {
	        $pagename = Pagename::create([
	        	'slug' => $page['slug'],
	        	'key' => $page['key']
	        ]);

          foreach ($page['locales'] as $key => $value) {
            $pagename->locales()->create(['locale' => $key, 'page_name' => $value]);
          }
      	}



    }
}
