Skip to content

Commit

Permalink
Merge pull request #8 from cwsdigital/v1.1.x
Browse files Browse the repository at this point in the history
Fix creation of new models
  • Loading branch information
chrispymm authored Sep 22, 2021
2 parents ab57e8c + 13b1e9b commit dfd7e8b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/Repositories/Behaviours/HandleMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ public function afterSaveHandleMetadata(Model $object, array $fields)

$repository = App::make('CwsDigital\TwillMetadata\Repositories\MetadataRepository');

$repository->update($object->id, $fields);
$metadata = $object->metadata ?? $object->metadata()->create();

$repository->update($metadata->id, $fields);

//$object->metadata()->update($fields);
}

/**
Expand All @@ -43,8 +44,6 @@ public function afterSaveHandleMetadata(Model $object, array $fields)
* @return array
*/
public function getFormFieldsHandleMetadata(Model $object, array $fields){
$repository = App::make('CwsDigital\TwillMetadata\Repositories\MetadataRepository');

//If the metadata object doesn't exist create it. Every 'meta_describable' will need one entry.
$metadata = $object->metadata ?? $object->metadata()->create();

Expand Down

0 comments on commit dfd7e8b

Please sign in to comment.