-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathModelFactory.php
More file actions
55 lines (47 loc) · 926 Bytes
/
ModelFactory.php
File metadata and controls
55 lines (47 loc) · 926 Bytes
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
44
45
46
47
48
49
50
51
52
53
54
55
<?php
namespace Codecasts\Support\Domain;
use Faker\Generator;
use Faker\Generator as Faker;
use Illuminate\Database\Eloquent\Factory;
use Illuminate\Database\Eloquent\Model;
/**
* Class ModelFactory.
*
* Base Factory for usage inside domains.
*/
abstract class ModelFactory
{
/**
* @var Factory
*/
protected $factory;
/**
* @var Model
*/
protected $model;
/**
* @var Faker
*/
protected $faker;
/**
* BaseFactory constructor.
*/
public function __construct()
{
$this->factory = app()->make(Factory::class);
$this->faker = app()->make(Generator::class);
}
/**
* @return mixed
*/
public function define()
{
$this->factory->define($this->model, function () {
return $this->fields();
});
}
/**
* @return mixed
*/
abstract public function fields();
}