From ce2102c0e3162e76a9b69b699fe92929d0027fde Mon Sep 17 00:00:00 2001 From: HolgerHatGarKeineNode Date: Thu, 16 Mar 2023 19:18:07 +0100 Subject: [PATCH] seo image added --- .../Livewire/BookCase/CommentBookCase.php | 26 +++++++++---------- app/Models/BookCase.php | 16 +++++++----- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/app/Http/Livewire/BookCase/CommentBookCase.php b/app/Http/Livewire/BookCase/CommentBookCase.php index 677f1c3c..3f9a0328 100644 --- a/app/Http/Livewire/BookCase/CommentBookCase.php +++ b/app/Http/Livewire/BookCase/CommentBookCase.php @@ -21,18 +21,6 @@ class CommentBookCase extends Component public BookCase $bookCase; - public function render() - { - return view('livewire.book-case.comment-book-case') - ->layout('layouts.app', [ - 'SEOData' => new SEOData( - title: $this->bookCase->title, - description: $this->bookCase->address, - image: $this->bookCase->getFirstMediaUrl('images') ?? asset('img/bookcase.jpg'), - ), - ]); - } - public function save() { $this->validate([ @@ -55,12 +43,24 @@ class CommentBookCase extends Component return to_route('bookCases.comment.bookcase', ['country' => $this->country, 'bookCase' => $this->bookCase->id]); } + public function render() + { + return view('livewire.book-case.comment-book-case') + ->layout('layouts.app', [ + 'SEOData' => new SEOData( + title: $this->bookCase->title, + description: $this->bookCase->address, + image: $this->bookCase->getFirstMediaUrl('images', 'seo') ?? asset('img/bookcase.jpg'), + ), + ]); + } + protected function url_to_absolute($url) { if (str($url)->contains('http')) { return $url; } - if (! str($url)->contains('http')) { + if (!str($url)->contains('http')) { return str($url)->prepend('https://'); } } diff --git a/app/Models/BookCase.php b/app/Models/BookCase.php index 953a6a7d..45ecfa0a 100644 --- a/app/Models/BookCase.php +++ b/app/Models/BookCase.php @@ -22,28 +22,26 @@ class BookCase extends Model implements HasMedia /** * The attributes that aren't mass assignable. - * * @var array */ protected $guarded = []; /** * The attributes that should be cast to native types. - * * @var array */ protected $casts = [ - 'id' => 'integer', - 'lat' => 'double', - 'lon' => 'array', - 'digital' => 'boolean', + 'id' => 'integer', + 'lat' => 'double', + 'lon' => 'array', + 'digital' => 'boolean', 'deactivated' => 'boolean', ]; protected static function booted() { static::creating(function ($model) { - if (! $model->created_by) { + if (!$model->created_by) { $model->created_by = auth()->id(); } }); @@ -60,6 +58,10 @@ class BookCase extends Model implements HasMedia ->addMediaConversion('preview') ->fit(Manipulations::FIT_CROP, 300, 300) ->nonQueued(); + $this->addMediaConversion('seo') + ->fit(Manipulations::FIT_CROP, 1200, 630) + ->width(1200) + ->height(630); $this->addMediaConversion('thumb') ->fit(Manipulations::FIT_CROP, 130, 130) ->width(130)