Skip to content

Commit 2a230c5

Browse files
committed
Add IpAddressFactory class
1 parent 0beea53 commit 2a230c5

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

src/IpAddress.php

+9
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Illuminate\Support\Facades\Http;
88
use Illuminate\Contracts\Support\Arrayable;
99
use Illuminate\Database\Eloquent\Factories\HasFactory;
10+
use Illuminate\Database\Eloquent\Factories\Factory;
1011

1112
use Illuminate\Database\Eloquent\Model;
1213

@@ -65,6 +66,14 @@ class IpAddress extends Model
6566
'proxy' => 'boolean',
6667
];
6768

69+
/**
70+
* Create a new factory instance for the model.
71+
*/
72+
protected static function newFactory(): Factory
73+
{
74+
return IpAddressFactory::new();
75+
}
76+
6877
/**
6978
* Create a new element.
7079
*

src/IpAddressFactory.php

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace CryptoUnifier\Helpers;
4+
5+
use Illuminate\Database\Eloquent\Factories\Factory;
6+
7+
class IpAddressFactory extends Factory
8+
{
9+
/**
10+
* Define the model's default state.
11+
*
12+
* @return array<string, mixed>
13+
*/
14+
public function definition(): array
15+
{
16+
return [
17+
'ip_address' => $this->faker->ipv4(),
18+
'asn' => $this->faker->randomNumber(4, true),
19+
'continent' => 'world',
20+
'country' => $this->faker->country(),
21+
'country_code' => $this->faker->countryCode(),
22+
'region' => $this->faker->state(),
23+
'region_code' => $this->faker->stateAbbr(),
24+
'city' => $this->faker->city(),
25+
'latitude' => $this->faker->latitude(),
26+
'longitude' => $this->faker->longitude(),
27+
'risk' => $this->faker->randomNumber(2),
28+
'proxy' => $this->faker->boolean(),
29+
'driver' => 'factory',
30+
];
31+
}
32+
}

0 commit comments

Comments
 (0)