<?php

use Illuminate\Database\Seeder;
use App\Models\PetPopularity as PetPopularityModel;

class PetPopularitySeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
    	PetPopularityModel::truncate();
    	$pets = [
    		'Dogs',
    		'Cats',
    	];

        $start_date = '2019-01-01';
        $end_date = date('Y-m-d');

        while (strtotime($start_date) <= strtotime($end_date)) {
            echo "$start_date\n";
            foreach (range(0,5) as $value) {
                foreach ($pets as $pet) {
                    $new_data = new PetPopularityModel;
                    $new_data->pet_name = $pet;
                    $new_data->popularity = rand($value,50);
                    $new_data->created_at = $start_date;
                    $new_data->updated_at = $start_date;
                    $new_data->save();
                }
            }
            $start_date = date ("Y-m-d", strtotime("+1 month", strtotime($start_date)));
        }
    }
}
