-
Notifications
You must be signed in to change notification settings - Fork 9
/
create_grid.php
76 lines (68 loc) · 2.04 KB
/
create_grid.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
use Anomaly\Streams\Platform\Database\Migration\Migration;
class CreateGrid extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
/*
|--------------------------------------------------------------------------
| Create Grid
|--------------------------------------------------------------------------
|
*/
$stream = $this->streams()->create([
"namespace" => "grid",
"name" => "Grid",
"slug" => "grid",
]);
/*
|--------------------------------------------------------------------------
| Create field
|--------------------------------------------------------------------------
|
|
*/
$field = $this->fields()->create([
"namespace" => "grid",
"type" => "anomaly.field_type.image",
"slug" => "image_3_2",
"name" => "Image Ratio 3:2",
"locked" => false,
]);
/*
|--------------------------------------------------------------------------
| Assign the field to the stream
|--------------------------------------------------------------------------
|
|
*/
$this->assignments()->create(
[
'stream' => $stream,
'field' => $field,
'unique' => false,
'required' => false,
'translatable' => false,
]
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
$stream = $this->streams()->findBySlugAndNamespace('grid', 'grid');
$field = $this->fields()->findBySlugAndNamespace('image_3_2', 'grid');
$assignment = $this->assignments()->findByStreamAndField($stream, $field);
$field->delete();
$stream->delete();
$assignment->delete();
}
}