Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/database/Factories/AllocationFactory.php
7458 views
1
<?php
2
3
namespace Database\Factories;
4
5
use Pterodactyl\Models\Server;
6
use Pterodactyl\Models\Allocation;
7
use Illuminate\Database\Eloquent\Factories\Factory;
8
9
class AllocationFactory extends Factory
10
{
11
/**
12
* The name of the factory's corresponding model.
13
*
14
* @var string
15
*/
16
protected $model = Allocation::class;
17
18
/**
19
* Define the model's default state.
20
*/
21
public function definition(): array
22
{
23
return [
24
'ip' => $this->faker->unique()->ipv4,
25
'port' => $this->faker->unique()->numberBetween(1024, 65535),
26
];
27
}
28
29
/**
30
* Attaches the allocation to a specific server model.
31
*/
32
public function forServer(Server $server): self
33
{
34
return $this->for($server)->for($server->node);
35
}
36
}
37
38