-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathConnectModuleSeeder.php
More file actions
54 lines (45 loc) · 1.7 KB
/
ConnectModuleSeeder.php
File metadata and controls
54 lines (45 loc) · 1.7 KB
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
<?php namespace Visiosoft\ConnectModule;
use Anomaly\Streams\Platform\Assignment\Contract\AssignmentRepositoryInterface;
use Anomaly\Streams\Platform\Database\Seeder\Seeder;
use Anomaly\Streams\Platform\Field\Contract\FieldRepositoryInterface;
use Anomaly\Streams\Platform\Stream\Contract\StreamRepositoryInterface;
class ConnectModuleSeeder extends Seeder
{
public function run(
FieldRepositoryInterface $fieldRepository,
AssignmentRepositoryInterface $assignmentRepository,
StreamRepositoryInterface $streamRepository
)
{
$namespace = 'users';
$locked = 0;
$stream = $streamRepository->findBySlugAndNamespace('users', 'users');
$customFields = [
[
'name' => 'referrer',
'slug' => 'referrer',
'type' => 'anomaly.field_type.text',
]
];
foreach ($customFields as $customField) {
$field = $fieldRepository->findBySlugAndNamespace($customField['slug'], $namespace);
if (!$field) {
$data = [
'name' => $customField['name'],
'namespace' => $namespace,
'slug' => $customField['slug'],
'type' => $customField['type'],
'locked' => $locked
];
if (isset($customField['config'])) {
$data['config'] = $customField['config'];
}
$field = $fieldRepository->create($data);
$assignmentRepository->create([
'stream_id' => $stream->id,
'field_id' => $field->id
]);
}
}
}
}