<?php

use App\Page;
use App\PageDescription;
use Illuminate\Database\Seeder;

class PagesDescriptionSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $guidePages = Page::where('type', 1)->cursor();
        $otherPages = Page::where('type', 2)->cursor();

        foreach ($guidePages as $guidePage) {
            foreach (languages() as $language) {
                factory(PageDescription::class)->create([
                    'language_id' => $language->id,
                    'page_id' => $guidePage->id,
                ]);
            }

        }

        foreach ($otherPages as $otherPage) {
            foreach (languages() as $language) {
                factory(PageDescription::class)->create([
                    'language_id' => $language->id,
                    'page_id' => $otherPage->id,
                ]);
            }

        }

    }
}
