From e19c37c1f89c6adeee8b20e24e4525293859b4f3 Mon Sep 17 00:00:00 2001 From: A1Gard Date: Sat, 10 Aug 2024 07:52:42 +0330 Subject: [PATCH] added Open Graph Tags to models updated markup --- app/Models/Clip.php | 37 +++++++++++++++++++ app/Models/Post.php | 5 +++ app/Models/Product.php | 21 +++++++++++ database/seeders/SettingSeeder.php | 5 +++ .../views/website/inc/website-head.blade.php | 34 +++++++++++++++++ 5 files changed, 102 insertions(+) diff --git a/app/Models/Clip.php b/app/Models/Clip.php index ff8d8e5..39d3dca 100644 --- a/app/Models/Clip.php +++ b/app/Models/Clip.php @@ -69,4 +69,41 @@ class Clip extends Model return $this->morphMany(Comment::class, 'commentable')->where('status', 1); } + public function markup(){ + + $app = config('app.name'); + $logo = asset('upload/images/logo.png'); + $desc = str_replace('"','',strip_tags($this->body)); + $count = $this->comments()->count() ; + return << +{ + "@context": "https://schema.org", + "@type": "VideoObject", + "name": "{$this->title}", + "description": "{$desc}", + "thumbnailUrl": "{$this->imgUrl()}", + "uploadDate": "{$this->updated_at}", + "contentUrl": "{$this->fileUrl()}", + "embedUrl": "{$this->webUrl()}", + "interactionStatistic": { + "@type": "InteractionCounter", + "interactionType": "http://schema.org/PlayAction", + "userInteractionCount": {$count} + }, + "publisher": { + "@type": "Organization", + "name": "$app", + "logo": { + "@type": "ImageObject", + "url": "$logo" + } + } +} + +RESULT; + + } + } diff --git a/app/Models/Post.php b/app/Models/Post.php index aa26a78..e2b1a3a 100644 --- a/app/Models/Post.php +++ b/app/Models/Post.php @@ -170,6 +170,11 @@ class Post extends Model implements HasMedia "@type": "ImageObject", "url": "$logo" } + }, + "interactionStatistic": { + "@type": "InteractionCounter", + "interactionType": "http://schema.org/PlayAction", + "userInteractionCount": {$this->view} }, "datePublished": "{$this->created_at}", "dateModified": "{$this->updated_at}" diff --git a/app/Models/Product.php b/app/Models/Product.php index 7669302..670aa6a 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -376,6 +376,11 @@ class Product extends Model implements HasMedia "url": "{$this->webUrl()}", "priceCurrency": "$currency", "price": "{{$this->price}}" + }, + "interactionStatistic": { + "@type": "InteractionCounter", + "interactionType": "http://schema.org/PlayAction", + "userInteractionCount": {$this->view} }, "aggregateRating": { "@type": "AggregateRating", @@ -389,4 +394,20 @@ class Product extends Model implements HasMedia RESULT; } + + public function seoDesc() + { + $template = getSetting('product_description'); + if ($template == null || $template == ''){ + $template = __('%name% sale in our shop by %price% %category.name%'); + } + $template = str_replace('%name%', $this->name,$template); + $template = str_replace('%price%', $this->getPrice() ,$template); + $template = str_replace('%excerpt%', $this->excerpt,$template); + $template = str_replace('%stock_quantity%', $this->stock_quantity,$template); + $template = str_replace('%category.name%', $this->category->name,$template); + + return $template; + + } } diff --git a/database/seeders/SettingSeeder.php b/database/seeders/SettingSeeder.php index 6ec29fc..72ee536 100644 --- a/database/seeders/SettingSeeder.php +++ b/database/seeders/SettingSeeder.php @@ -118,6 +118,11 @@ class SettingSeeder extends Seeder 'key' => 'site_image', 'type' => 'FILE', ], + [ + 'title' => __("%name% sale in our shop by %price% %category.name%"), + 'key' => 'product_description', + 'type' => 'text', + ], ], 'Media' => [ [ diff --git a/resources/views/website/inc/website-head.blade.php b/resources/views/website/inc/website-head.blade.php index fd3ace9..935dbdc 100644 --- a/resources/views/website/inc/website-head.blade.php +++ b/resources/views/website/inc/website-head.blade.php @@ -17,14 +17,48 @@ @yield('custom-head') {{-- WIP rtl or ltr--}} + +{{-- seo --}} + + @if(isset($breadcrumb)) {!! markUpBreadcrumbList($breadcrumb) !!} @endif @if(isset($post)) {!! $post->markup() !!} + + + + + @endif @if(isset($product)) {!! $product->markup() !!} + + + + + @endif + @if(isset($clip)) +{!! $clip->markup() !!} + + + + + + + +{{-- --}} +{{-- --}} + + @endif + @if(isset($gallery)) + + + + + + @endif