DeleteColumn::handle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
3
namespace Hechoenlaravel\JarvisFoundation\FieldGenerator\Listeners;
4
5
use Hechoenlaravel\JarvisFoundation\EntityGenerator\EntityModel;
6
use Hechoenlaravel\JarvisFoundation\FieldGenerator\Events\FieldWasDeleted;
7
use Illuminate\Support\Facades\Schema;
8
9
class DeleteColumn
10
{
11
    public function handle(FieldWasDeleted $event)
12
    {
13
        $field = $event->field;
14
        $entity = EntityModel::find($field['entity_id']);
15
        Schema::table($entity->getTableName(), function ($table) use ($field) {
16
            $table->dropColumn($field['slug']);
17
        });
18
    }
19
}
20