yarmat/laravel-seo

This package is abandoned and no longer maintained. The author suggests using the yarmat/laravel-seo package instead.

Package for using seo fields. (Laravel, Eloquent)

dev-master 2019-01-20 06:10 UTC

This package is auto-updated.

Last update: 2023-11-16 16:53:14 UTC


README

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.