<?php

/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
|
*/

/** @var \Illuminate\Database\Eloquent\Factory $factory */
$factory->define(App\User::class, function (Faker\Generator $faker) {
    static $password;

    return [
        'name' => $faker->name,
        'email' => $faker->unique()->safeEmail,
        'password' => $password ?: $password = bcrypt('secret'),
        'remember_token' => str_random(10),
    ];
});

// Bidders
$factory->define(App\Models\Bidders::class, function (Faker\Generator $faker) {
    return [
        'bidder_fname' => $faker->firstName,
        'bidder_lname' => $faker->lastName,
        'bidder_addr' => $faker->streetAddress,
        'bidder_city' => $faker->city,
        'bidder_state' => $faker->stateAbbr,
        'bidder_zip' => $faker->postcode,
        'bidder_phone' => $faker->phoneNumber,
        'bidder_email' => $faker->unique()->safeEmail,
        'bidder_assigned_number' => $faker->unique()->numberBetween(1, 1000),
    ];
});

// Items
$factory->define(App\Models\Items::class, function (Faker\Generator $faker) {
    return [
        'item_desc' => $faker->sentence(3),
        'item_min_bid' => $faker->numberBetween(10, 100),
        'item_est_value' => $faker->numberBetween(50, 500),
        'item_assigned_num' => $faker->unique()->numberBetween(1, 500),
    ];
});

// CarShowCategory
$factory->define(App\Models\CarShowCategory::class, function (Faker\Generator $faker) {
    return [
        'category_name' => $faker->words(2, true),
        'vehicle_type' => $faker->boolean,
    ];
});

// Vehicles
$factory->define(App\Models\Vehicles::class, function (Faker\Generator $faker) {
    return [
        'year' => $faker->year,
        'make' => $faker->company,
        'model' => $faker->word,
        'type' => function () {
            return factory(App\Models\CarShowCategory::class)->create()->id;
        },
        'doNotJudge' => $faker->boolean,
        'owner' => function () {
            return factory(App\Models\Bidders::class)->create()->bidder_assigned_number;
        },
    ];
});

// PaymentMethods
$factory->define(App\Models\PaymentMethods::class, function (Faker\Generator $faker) {
    return [
        'pm_name' => $faker->randomElement(['Cash', 'Check', 'Credit Card']),
    ];
});

// Judges
$factory->define(App\Models\Judges::class, function (Faker\Generator $faker) {
    return [
        'judge_number' => $faker->unique()->numberBetween(1, 50),
    ];
});

// VehicleScores
$factory->define(App\Models\VehicleScores::class, function (Faker\Generator $faker) {
    return [
        'judge' => function () {
            return factory(App\Models\Judges::class)->create()->id;
        },
        'overall_score' => $faker->numberBetween(1, 100),
        'vehicle' => function () {
            return factory(App\Models\Vehicles::class)->create()->id;
        },
    ];
});

// PeoplesChoice
$factory->define(App\Models\PeoplesChoice::class, function (Faker\Generator $faker) {
    return [
        'vehicle' => function () {
            return factory(App\Models\Vehicles::class)->create()->id;
        },
        'pc_count' => $faker->numberBetween(0, 50),
    ];
});

// WinningBids
$factory->define(App\Models\WinningBids::class, function (Faker\Generator $faker) {
    return [
        'winning_bidder_num' => function () {
            return factory(App\Models\Bidders::class)->create()->idbidders;
        },
        'winning_cost' => $faker->numberBetween(10, 1000),
        'winning_item_num' => function () {
            return factory(App\Models\Items::class)->create()->iditems;
        },
    ];
});

// Checkout
$factory->define(App\Models\Checkout::class, function (Faker\Generator $faker) {
    return [
        'bidder_num' => function () {
            return factory(App\Models\Bidders::class)->create()->idbidders;
        },
        'winnertotal' => $faker->numberBetween(10, 2000),
        'payment_method' => function () {
            return factory(App\Models\PaymentMethods::class)->create()->pm_id;
        },
        'check_number' => $faker->optional()->numberBetween(100, 999),
        'cc_transaction' => $faker->optional()->uuid,
        'cc_amount' => $faker->optional()->numberBetween(10, 2000),
    ];
});

// CarShowWinner
$factory->define(App\Models\CarShowWinner::class, function (Faker\Generator $faker) {
    return [
        'vehicle' => function () {
            return factory(App\Models\Vehicles::class)->create()->id;
        },
        'category' => function () {
            return factory(App\Models\CarShowCategory::class)->create()->id;
        },
        'place' => $faker->numberBetween(1, 3),
        'total_score' => $faker->numberBetween(50, 300),
    ];
});