<?php

use Illuminate\Database\Seeder;
use Illuminate\Support\Carbon;

class HotelDescriptionSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {

//        foreach (\App\User::where('role', 'provider')->cursor() as $user) {
            $hotels = factory(\App\Hotel::class, 10)->create();
//        }

        foreach ($hotels as $hotel) {
            foreach (languages() as $language) {
                factory(\App\HotelDescription::class)->create(
                    [
                        'hotel_id' => $hotel->id,
                        'language_id' => $language->id,
                    ]
                );
            }

//            $allDates = [];
//            foreach (json_decode($hotel->available_dates, true) as $key => $available_date) {
//                $from = Carbon::make($available_date['from'])->addDays(-1);
//                $to = Carbon::make($available_date['to']);
//                while($to->diff($from)->days){
//                    $from = $from->addDay();
//                    $allDates[] = $from->format('Y-m-d');
//
//                }
//            }
//
//            $hotel->update(['all_dates' => $allDates]);
        }
    }
}
