<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use App\Models\Compilation;

class CompilationsTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $compilation1 = Compilation::create([
            'title' => [
                'uz' => 'Eng yaxshi sotuvchi',
                'ru' => 'Лидер продаж'
            ],
            'position' => 2,
            'published' => true,
        ]);

        $compilation2 = Compilation::create([
            'title' => [
                'uz' => 'Ommabop mahsulotlar',
                'ru' => 'Популярные товары'
            ],
            'position' => 1,
            'published' => true,
        ]);

        $compilation3 = Compilation::create([
            'title' => [
                'uz' => 'Yangi mahsulotlar',
                'ru' => 'Новые товары'
            ],
            'position' => 1,
            'published' => true,
        ]);

        if (app()->environment('local')) {
            $compilation1->products()->attach([1, 2]);
            $compilation2->products()->attach([1, 2]);
            $compilation3->products()->attach([1, 2]);
        }
    }
}
