akaunting/database/factories/Account.php

77 lines
1.8 KiB
PHP
Raw Normal View History

2020-01-06 13:37:32 +00:00
<?php
2020-10-14 14:07:59 +00:00
namespace Database\Factories;
2020-01-06 13:37:32 +00:00
2020-10-14 14:07:59 +00:00
use App\Abstracts\Factory;
use App\Models\Banking\Account as Model;
2020-01-06 13:37:32 +00:00
2020-10-14 14:07:59 +00:00
class Account extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Model::class;
2020-01-06 13:37:32 +00:00
2020-10-14 14:07:59 +00:00
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
2022-06-01 07:15:55 +00:00
$types = ['bank', 'credit_card'];
2020-10-14 14:07:59 +00:00
return [
'company_id' => $this->company->id,
2022-06-01 07:15:55 +00:00
'type' => $this->faker->randomElement($types),
2020-10-14 14:07:59 +00:00
'name' => $this->faker->text(15),
'number' => (string) $this->faker->iban(),
'currency_code' => $this->company->currencies()->enabled()->get()->random(1)->pluck('code')->first(),
'opening_balance' => '0',
'bank_name' => $this->faker->text(15),
'bank_phone' => $this->faker->phoneNumber,
'bank_address' => $this->faker->address,
'enabled' => $this->faker->boolean ? 1 : 0,
2021-09-09 21:31:39 +00:00
'created_from' => 'core::factory',
2020-10-14 14:07:59 +00:00
];
}
2020-01-06 22:28:05 +00:00
2020-10-14 14:07:59 +00:00
/**
* Indicate that the model is enabled.
*
* @return \Illuminate\Database\Eloquent\Factories\Factory
*/
public function enabled()
{
2020-10-14 21:08:41 +00:00
return $this->state([
'enabled' => 1,
]);
2020-10-14 14:07:59 +00:00
}
2020-01-06 22:28:05 +00:00
2020-10-14 14:07:59 +00:00
/**
* Indicate that the model is disabled.
*
* @return \Illuminate\Database\Eloquent\Factories\Factory
*/
public function disabled()
{
2020-10-14 21:08:41 +00:00
return $this->state([
'enabled' => 0,
]);
2020-10-14 14:07:59 +00:00
}
2020-01-07 06:29:45 +00:00
2020-10-14 14:07:59 +00:00
/**
* Indicate that the default currency is used.
*
* @return \Illuminate\Database\Eloquent\Factories\Factory
*/
public function default_currency()
{
2020-10-14 21:08:41 +00:00
return $this->state([
'currency_code' => setting('default.currency'),
]);
2020-10-14 14:07:59 +00:00
}
}