Skip to content

Commit

Permalink
Merge pull request #5 from cwsdigital/fix/issue-#1
Browse files Browse the repository at this point in the history
update readme to indicate requires HasMedias Trait
  • Loading branch information
chrispymm authored Sep 20, 2021
2 parents 68c1449 + e288719 commit 55a343d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
tags
.php_cs.cache
.idea
6 changes: 4 additions & 2 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
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 55a343d

Please sign in to comment.