Skip to content

Commit

Permalink
add Yaml and add custom column type
Browse files Browse the repository at this point in the history
  • Loading branch information
railken committed Apr 6, 2024
1 parent 8f3807c commit d5829a1
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions config/amethyst.attribute-schema.resolvers.php
Expand Up @@ -12,4 +12,5 @@
'DateTime' => Amethyst\AttributeSchemaResolvers\DateTimeResolver::class,
'DataName' => Amethyst\AttributeSchemaResolvers\DataNameResolver::class,
'MorphTo' => Amethyst\AttributeSchemaResolvers\MorphToResolver::class,
'Yaml' => Amethyst\AttributeSchemaResolvers\YamlResolver::class,
];
20 changes: 20 additions & 0 deletions src/AttributeSchemaResolvers/YamlResolver.php
@@ -0,0 +1,20 @@
<?php

namespace Amethyst\AttributeSchemaResolvers;

class YamlResolver extends Resolver
{
/**
* Return \Railken\Lem\Attributes\BaseAttribute class.
*
* @return string
*/
public function getSchemaClass(): string
{
return \Railken\Lem\Attributes\YamlAttribute::class;
}

public function validate()
{
}
}
3 changes: 2 additions & 1 deletion src/Observers/AttributeSchemaObserver.php
Expand Up @@ -75,7 +75,8 @@ public function updating(AttributeSchema $attributeSchema, bool $onChange = true
});

Schema::table($data->newEntity()->getTable(), function (Blueprint $table) use ($attributeSchema, $onChange, $options) {
$method = $this->getMethod($attributeSchema);

$method = !empty($options->column) ? $options->column : $this->getMethod($attributeSchema);

$arguments = $attributeSchema->getResolver()->getDatabaseArguments();

Expand Down
15 changes: 15 additions & 0 deletions tests/Managers/AttributeSchemaYamlTest.php
@@ -0,0 +1,15 @@
<?php

namespace Amethyst\Tests\Managers;

class AttributeSchemaYamlTest extends AttributeSchemaCommonTestCase
{
public function testBasicYaml()
{
$this->resetFields();

$this->commonField('yaml', 'Yaml', ["valid:yaml"]);

$this->resetFields();
}
}

0 comments on commit d5829a1

Please sign in to comment.