/** * Handle the creation of the Field in the Database * @param $command * @return static */ public function handle($command) { $command->namespace = EntityModel::find($command->entity_id)->namespace; $field = FieldModel::create((array) $command); event(new FieldWasCreated($field)); return $field; }
public function handle(FieldWasDeleted $event) { $field = $event->field; $entity = EntityModel::find($field['entity_id']); Schema::table($entity->getTableName(), function ($table) use($field) { $table->dropColumn($field['slug']); }); }