|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Database\Factories; |
|
4
|
|
|
|
|
5
|
|
|
use App\Enum\DenominationType; |
|
6
|
|
|
use App\Models\Denomination; |
|
7
|
|
|
use Illuminate\Database\Eloquent\Factories\Factory; |
|
8
|
|
|
use Illuminate\Http\UploadedFile; |
|
9
|
|
|
|
|
10
|
|
|
class DenominationFactory extends Factory |
|
11
|
|
|
{ |
|
12
|
|
|
/** |
|
13
|
|
|
* The name of the factory's corresponding model. |
|
14
|
|
|
* |
|
15
|
|
|
* @var string |
|
16
|
|
|
*/ |
|
17
|
|
|
protected $model = Denomination::class; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Define the model's default state. |
|
21
|
|
|
* |
|
22
|
|
|
* @return array |
|
23
|
|
|
*/ |
|
24
|
|
|
public function definition() |
|
25
|
|
|
{ |
|
26
|
|
|
$isCoin = $this->faker->boolean; |
|
27
|
|
|
|
|
28
|
|
|
$denomination = $isCoin |
|
29
|
|
|
? $this->faker->randomElement([100, 200, 500, 1000]) |
|
30
|
|
|
: $this->faker->randomElement([1000, 2000, 5000, 10000, 20000, 50000, 75000, 100000]); |
|
31
|
|
|
|
|
32
|
|
|
return [ |
|
33
|
|
|
'name' => terbilang($denomination), |
|
34
|
|
|
'value' => $denomination, |
|
35
|
|
|
'type' => $isCoin ? DenominationType::coin() : DenominationType::banknote(), |
|
36
|
|
|
'quantity_per_bundle' => $this->faker->randomElement([50, 100, 200]), |
|
37
|
|
|
'minimum_order_bundle' => $minimum = $this->faker->numberBetween(1, 10), |
|
38
|
|
|
'maximum_order_bundle' => $this->faker->numberBetween($minimum, 10), |
|
39
|
|
|
'image' => UploadedFile::fake()->image($denomination . '.jpg'), |
|
40
|
|
|
]; |
|
41
|
|
|
} |
|
42
|
|
|
} |
|
43
|
|
|
|