add seo
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Models\Botanic\Specie;
|
||||
use App\Models\Botanic\Variety;
|
||||
use App\Traits\Model\HasComments;
|
||||
use App\Traits\Model\Imageable;
|
||||
use Cviebrock\EloquentSluggable\Sluggable;
|
||||
use Fico7489\Laravel\EloquentJoin\Traits\EloquentJoin;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
@@ -16,6 +17,8 @@ use Illuminate\Database\Eloquent\Relations\MorphToMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Kirschbaum\PowerJoins\PowerJoins;
|
||||
use Laravel\Scout\Searchable;
|
||||
use RalphJSmit\Laravel\SEO\Support\HasSEO;
|
||||
use RalphJSmit\Laravel\SEO\Support\SEOData;
|
||||
use Rinvex\Categories\Traits\Categorizable;
|
||||
use Rinvex\Tags\Traits\Taggable;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
@@ -29,10 +32,12 @@ class Article extends Model implements HasMedia
|
||||
use EloquentJoin;
|
||||
use HasComments;
|
||||
use HasRelationships;
|
||||
use HasSEO;
|
||||
use Imageable;
|
||||
use Powerjoins;
|
||||
use RevisionableTrait;
|
||||
use Searchable;
|
||||
use Sluggable;
|
||||
use SoftDeletes;
|
||||
use Taggable;
|
||||
use UserStamps;
|
||||
@@ -177,6 +182,11 @@ class Article extends Model implements HasMedia
|
||||
return $productId ? $query->where($this->table.'.product_id', $productId) : $query;
|
||||
}
|
||||
|
||||
public function scopeBySlug($query, $slug)
|
||||
{
|
||||
return $slug ? $query->where($this->table.'.slug', $slug) : $query;
|
||||
}
|
||||
|
||||
public function scopeByTag($query, $tagId)
|
||||
{
|
||||
return $tagId ? $query->whereHas('tags', function ($query) use ($tagId) {
|
||||
@@ -227,4 +237,25 @@ class Article extends Model implements HasMedia
|
||||
'description' => html_entity_decode(strip_tags($description)),
|
||||
];
|
||||
}
|
||||
|
||||
public function getDynamicSEOData(): SEOData
|
||||
{
|
||||
// $pathToFeaturedImageRelativeToPublicPath = // ..;
|
||||
|
||||
// Override only the properties you want:
|
||||
return new SEOData(
|
||||
title: $this->name,
|
||||
description: $this->description,
|
||||
// image: $pathToFeaturedImageRelativeToPublicPath,
|
||||
);
|
||||
}
|
||||
|
||||
public function sluggable(): array
|
||||
{
|
||||
return [
|
||||
'slug' => [
|
||||
'source' => 'name'
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user