ekmungai/eloquent-ifrs

View on GitHub
database/factories/AccountFactory.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

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

use IFRS\Models\Account;
use Faker\Generator as Faker;

$factory->define(
    Account::class,
    function (Faker $faker) {
        $types = array_keys(config('ifrs')['accounts']);
        unset($types[3]);

        $type = $this->faker->randomElement($types);
        return [
            'name' => $faker->name,
            'account_type' => $type,
            'category_id' => factory('IFRS\Models\Category')->create([
                'category_type' => $type,
            ])->id,
            'code' => $faker->randomDigit,
        ];
    }
);