<?php

/** @var \Illuminate\Database\Eloquent\Factory $factory */

use App\User;
use App\UserSubscription;
use Carbon\Carbon;
use Faker\Generator as Faker;

$factory->define(UserSubscription::class, function (Faker $faker) {
    $date = $faker->dateTimeBetween('-30 days','+15 days');
    return [
        "user_id" => User::all()->random()->id,
        "role_id" => null,
        "start_date" => Carbon::createFromFormat('Y-m-d',$date->format('Y-m-d'))->addDays(rand(-15,5)),
        "end_date" => Carbon::createFromFormat('Y-m-d',$date->format('Y-m-d'))->addDays(rand(6,20)),
        "price" => $faker->randomFloat($nbMaxDecimals = NULL, $min = 0, $max = 150),
        "renew" => $faker->boolean,
        "created_at" => $faker->dateTimeBetween('-30 days','+15 days')
    ];
});
