/
Factory.tpl.php
43 lines (38 loc) · 1.48 KB
/
Factory.tpl.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?= "<?php\n" ?>
namespace <?= $namespace; ?>;
use <?= $entity->getName() ?>;
<?php if ($repository): ?>use <?= $repository->getName() ?>;
use Zenstruck\Foundry\RepositoryProxy;
<?php endif ?>
use Zenstruck\Foundry\ModelFactory;
use Zenstruck\Foundry\Proxy;
/**
* @method static <?= $entity->getShortName() ?>|Proxy findOrCreate(array $attributes)
* @method static <?= $entity->getShortName() ?>|Proxy random()
* @method static <?= $entity->getShortName() ?>[]|Proxy[] randomSet(int $number)
* @method static <?= $entity->getShortName() ?>[]|Proxy[] randomRange(int $min, int $max)
<?php if ($repository): ?> * @method static <?= $repository->getShortName() ?>|RepositoryProxy repository()
<?php endif ?>
* @method <?= $entity->getShortName() ?>|Proxy create($attributes = [])
* @method <?= $entity->getShortName() ?>[]|Proxy[] createMany(int $number, $attributes = [])
*/
final class <?= $class_name ?> extends ModelFactory
{
protected function getDefaults(): array
{
return [
// TODO add your default values here (https://github.com/zenstruck/foundry#model-factories)
];
}
protected function initialize(): self
{
// see https://github.com/zenstruck/foundry#initialization
return $this
// ->beforeInstantiate(function(<?= $entity->getShortName() ?> $<?= \lcfirst($entity->getShortName()) ?>) {})
;
}
protected static function getClass(): string
{
return <?= $entity->getShortName() ?>::class;
}
}