From af84a040e6a6bd965dd7a4a8dda38e47864e9342 Mon Sep 17 00:00:00 2001 From: Patrick Boivin Date: Fri, 17 Sep 2021 07:58:03 -0400 Subject: [PATCH 1/2] fix: Blade directive in form.blade.php example --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 988ec09..616ec67 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ In the admin 'form.blade.php' view add the metadata fieldset to the additional f @stop @section('fieldsets') - @metadata-fields + @metadataFields @stop ``` From e2887199b483da559bd50dca2f4514c06d992e56 Mon Sep 17 00:00:00 2001 From: Chris Pymm Date: Fri, 17 Sep 2021 14:33:23 +0100 Subject: [PATCH 2/2] update readme to indicate requires HasMedias Trait --- .gitignore | 1 + README.md | 6 ++++-- src/Models/Behaviours/HasMetadata.php | 6 +++++- src/Models/Metadata.php | 13 ------------- 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index a2d70b7..d5ec451 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ tags .php_cs.cache +.idea diff --git a/README.md b/README.md index 988ec09..4d8c28a 100644 --- a/README.md +++ b/README.md @@ -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 = []; ... diff --git a/src/Models/Behaviours/HasMetadata.php b/src/Models/Behaviours/HasMetadata.php index 91d7adf..58a8d72 100644 --- a/src/Models/Behaviours/HasMetadata.php +++ b/src/Models/Behaviours/HasMetadata.php @@ -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) { diff --git a/src/Models/Metadata.php b/src/Models/Metadata.php index 0e16b87..c5653cd 100644 --- a/src/Models/Metadata.php +++ b/src/Models/Metadata.php @@ -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) {