Skip to content

Commit

Permalink
Merge branch 'master' into fix/issue-#2
Browse files Browse the repository at this point in the history
  • Loading branch information
chrispymm authored Sep 20, 2021
2 parents 667d64b + 55a343d commit 69c4147
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 18 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
tags
.php_cs.cache
.idea
.idea

8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ $ artisan migrate

### In your model

Set your model to use the `HasMetadata` trait, and add the public property `$metadataFallbacks`.
Set your model to use the `HasMetadata` trait, and add the public property `$metadataFallbacks`.
Your model also need to use the HasMedias trait in order to allow for OpenGraph images.
```php
class Page extends Model {

use HasMetadata;
use HasMetadata,
HasMedias;

public $metadataFallbacks = [];
...
Expand Down Expand Up @@ -55,7 +57,7 @@ In the admin 'form.blade.php' view add the metadata fieldset to the additional f
@stop
@section('fieldsets')
@metadata-fields
@metadataFields
@stop
```

Expand Down
6 changes: 5 additions & 1 deletion src/Models/Behaviours/HasMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ protected function initializeHasMetadata()

// Add the default metadata from config into the $mediasParams array
// by default adds in an 'og_image' role with a 'default' crop
$this->mediasParams = array_merge($this->mediasParams, config('metadata.mediasParams') );
if( isset($this->mediasParams) && is_Array($this->mediasParams)) {
$this->mediasParams = array_merge($this->mediasParams, config('metadata.mediasParams'));
} else {
$this->mediasParams = config('metadata.mediasParams');
}
}

public function usesTrait($trait) {
Expand Down
13 changes: 0 additions & 13 deletions src/Models/Metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,6 @@ public function meta_describable() {
return $this->morphTo();
}

// //TODO - naming of this method?
// public function full() {
// $metadata = [];
// $exclude = ['id', 'created_at', 'updated_at', 'meta_describable_id', 'meta_describable_type', 'og_image'];
// $columns = array_diff($this->getTableColumns(), $exclude);
// foreach($columns as $column){
// $metadata[$column] = $this->field($column);
// }
//
// $metadata['image'] = $this->meta_describable->getSocialImageAttribute();
//
// return $metadata;
// }

public function field($column)
{
Expand Down

0 comments on commit 69c4147

Please sign in to comment.