Skip to content

Commit e717c61

Browse files
Merge pull request #6 from ssntpl/feature/link_from_parent_data
Revert "link child to parent data"
2 parents 75eb583 + 87a0bfe commit e717c61

4 files changed

Lines changed: 0 additions & 45 deletions

File tree

database/migrations/create_data_fields_table.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ public function up()
1919
$table->string('owner_type');
2020
$table->index(['owner_id', 'owner_type'], 'data_fields_owner_id_owner_type_index');
2121

22-
$table->unsignedBigInteger('parent_id')->nullable();
2322
$table->text('description')->nullable();
2423
$table->string('key')->nullable();
2524
$table->text('value')->nullable();

database/migrations/create_data_sets_table.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ public function up()
1919
$table->string('owner_type');
2020
$table->index(['owner_id', 'owner_type'], 'data_sets_owner_id_owner_type_index');
2121

22-
$table->unsignedBigInteger('parent_id')->nullable();
2322
$table->string('name')->nullable();
2423
$table->string('type');
2524
$table->integer('sort_order')->nullable();

src/Models/DataField.php

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ class DataField extends Model
3535
protected $fillable = [
3636
'owner_id',
3737
'owner_type',
38-
'parent_id',
3938
'description',
4039
'key',
4140
'value',
@@ -69,11 +68,6 @@ public static function getAllTypes()
6968
];
7069
}
7170

72-
protected function getClass()
73-
{
74-
return config('data-fields.data_field_model', DataField::class);
75-
}
76-
7771
public function owner()
7872
{
7973
return $this->morphTo();
@@ -90,11 +84,6 @@ public function delete()
9084
{
9185
$dataField->delete();
9286
}
93-
if ($this->children()->get()) {
94-
foreach ($this->children()->get() as $child) {
95-
$child->delete();
96-
}
97-
}
9887
return parent::delete();
9988
}
10089

@@ -111,15 +100,4 @@ public function duplicate()
111100

112101
return $newDataSet;
113102
}
114-
115-
public function parent()
116-
{
117-
return $this->belongsTo($this->getClass(), 'parent_id');
118-
}
119-
120-
public function children()
121-
{
122-
return $this->hasMany($this->getClass(), 'parent_id');
123-
}
124-
125103
}

src/Models/DataSet.php

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ class DataSet extends Model
2020
'id',
2121
'owner_id',
2222
'owner_type',
23-
'parent_id',
2423
'name',
2524
'type',
2625
'sort_order',
@@ -30,11 +29,6 @@ class DataSet extends Model
3029
protected $casts = [
3130
'meta_data' => 'array',
3231
];
33-
34-
protected function getClass()
35-
{
36-
return config('data-fields.data_set_model', DataSet::class);
37-
}
3832

3933
public function owner()
4034
{
@@ -49,11 +43,6 @@ public function delete()
4943
$dataField->delete();
5044
// DataField::destroy($dataField->id);
5145
}
52-
if ($this->children()->get()) {
53-
foreach ($this->children()->get() as $child) {
54-
$child->delete();
55-
}
56-
}
5746
return parent::delete();
5847
}
5948

@@ -71,14 +60,4 @@ public function duplicate()
7160

7261
return $newDataSet;
7362
}
74-
75-
public function parent()
76-
{
77-
return $this->belongsTo($this->getClass(), 'parent_id');
78-
}
79-
80-
public function children()
81-
{
82-
return $this->hasMany($this->getClass(), 'parent_id');
83-
}
8463
}

0 commit comments

Comments
 (0)