PHP code example of fomvasss / laravel-seo

1. Go to this page and download the library: Download fomvasss/laravel-seo library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

fomvasss / laravel-seo example snippets


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'),
        ];
    }
}

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

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

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

$tags = $post->getRawSeoTags('uk');
bash
php artisan vendor:publish --provider="Fomvasss\Seo\SeoServiceProvider"
php artisan migrate