<?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.
|
*/

$factory->define(App\Models\User::class, function (Faker\Generator $faker) {
    return [
        'first_name' => $faker->firstName,
        'last_name' => $faker->lastName,
        'username' => $faker->userName,
        'email' => $faker->email,
        'password' => bcrypt('password'),
        'remember_token' => str_random(10),
        'active' => 1,
    ];
});

$factory->define(App\Modules\Stock\Stock::class, function (Faker\Generator $faker) {
    return [
		'name'                => $faker->sentence,
		'type'                => $faker->randomElement(['stock', 'non_stock']),
		'retail'              => $faker->randomFloat($decimals = 2, $max = 150),
		'quantity'            => $faker->ean13,
		'price_excluding_vat' => $faker->randomFloat($decimals = 2, $max = 150),
    ];
});

$factory->define(App\Modules\Invoices\Invoice::class, function (Faker\Generator $faker) {
    return [
		'client_id'      => $faker->randomNumber($digits = 4),
		'client_type'    => 'customer',
		'type'           => 'sale',
		'invoice_number' => $faker->randomNumber($digits = 4),
		'invoiced_at'    => $faker->dateTime,
		'vat'            => 20,
		'invoice_date'   => $faker->date,
    ];
});

$factory->define(App\Modules\Invoices\InvoiceItem::class, function (Faker\Generator $faker) {
    return [
		'invoice_id'     => factory(App\Modules\Invoices\Invoice::class),
		'name'           => $faker->sentence,
		'quantity'       => $faker->randomDigit,
		'price_sold_exc' => $faker->randomFloat($decimals = 2),
    ];
});
