Skip to content

yarmat/laravel-seo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel-seo

Package for using seo fields (Title, Description, Keywords) in your Eloquent Model.

Installing

composer require yarmat/laravel-seo

You must publish the migration with:

php artisan vendor:publish --provider="Yarmat\Seo\SeoServiceProvider" --tag="migrations"

After the migration has been published you can create seos-tables by running the migrations:

php artisan migrate

Usage

First, add the Yarmat\Seo\Traits\HasSeoTrait trait to your model(s):

use Illuminate\Database\Eloquent\Model;
use Yarmat\Seo\Traits\HasSeoTrait;

class Blog extends Model 
{
    use HasSeoTrait;
}

A Seo fields can be added to your model:

$blog->saveSeo([
    'title'       => 'Title',
    'description' => 'Description',
    'keywords'    => 'Keywords'
]);

A Seo fields can be deleted from your model:

$blog->deleteSeo();

Get the Seo fields

$blog->seo->title; // if seo.title not added to this model returned null
$blog->seo->description; // if seo.description not added to this model returned null
$blog->seo->keywords; // if seo.keywords not added to this model returned null

If you wont to use your own Model

You must publish the config with:

php artisan vendor:publish --provider="Yarmat\Seo\SeoServiceProvider" --tag="config"

After publishing edit config file seo.php

return [
    'model' => App\Seo.php // f.e.
];

Extend your model

use Yarmat\Seo\Models\Seo as Model;

class Seo extends Model
{
}

License

The Laravel-seo is open-sourced software licensed under the MIT license.

About

Package for adding seo filelds to your model

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages