定制 fomvasss/laravel-seo 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

fomvasss/laravel-seo

最新稳定版本:1.10.0

Composer 安装命令:

composer require fomvasss/laravel-seo

包简介

Laravel SEO package

README 文档

README

License Build Status Latest Stable Version Total Downloads Quality Score

With this package you can manage meta-tags and SEO-fields from Laravel app.

Installation

You can install the package via composer:

composer require fomvasss/laravel-seo

You can publish and run the migrations with:

php artisan vendor:publish --provider="Fomvasss\Seo\SeoServiceProvider"
php artisan migrate

Usage

The Eloquent model must has the Trait HasSeo:

namespace App\Models;

use Fomvasss\Seo\Models\HasSeo;

class PostModel extends Model {
	use HasSeo;
	//...

    public function registerSeoDefaultTags(): array
    {
        return [
            'title' => $this->name,
            'description' => $this->description,
            'og_image' => $this->getFirstMediaUrl('images', 'thumb'),
        ];
    }
}

Also in model you can define default tags in method registerSeoDefaultTags

Allowed next methods (By increasing priority):

Seo::setDefault(['title' => 'Blog']);
Seo::setModel($post);
Seo::setPath('page/faq');
Seo::setTags(['keywords' => 'Laravel, SEO, tags']);

Rendering tags in Blade (in HTML head):

{!!
\Seo::setGroup(app()->getLocale())
    ->setDefault([
        'og_site_name' => config('app.name'),
        'og_url' => URL::full(),
        'og_locale' => app()->getLocale(),
    ])->renderHtml()
!!}

Get array tags (for API resource, etc.):

\Seo::setGroup(app()->getLocale())
    ->setDefault([
        'og_site_name' => config('app.name'),
        'og_locale' => app()->getLocale(),
    ])->getTags();

You can save tags for model in DB:

$post->seo('uk')->updateOrCreate([], ['tags' => ['title' => 'Hello Page', 'description' => 'Lorem Ipsum'], 'group' => 'uk']);

And get tags (for edit) for dashboard:

$tags = $post->getRawSeoTags('uk');

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 1.7k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-09-27