PHP code example of galtsevt / laravel-seo

1. Go to this page and download the library: Download galtsevt/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/ */

    

galtsevt / laravel-seo example snippets




namespace Kontur\News\App\Models;


use Galtsevt\LaravelSeo\App\Interfaces\SitemapContract; // [tl! add]
use Galtsevt\LaravelSeo\App\Traits\HasSeo; // [tl! add]

class News extends Model implements SitemapContract
{
    use HasFactory, HasSeo;
}

$schedule->call(function () {  
    $sitemapGenerator = new SiteMapGenerator();  
    $sitemapGenerator->saveToFile();  
})->dailyAt('1:00');

Seo::breadcrumbs()->add('Name', 'Url'); // Один элемент

Seo::breadcrumbs()->addList([
  'url' => 'name',
  'url1' => 'name1',
]);  // несколько элементов

Seo::breadcrumbs()->getAll();

Seo::metaData();

Seo::metaData()->prepare($news)

Seo::metaData()->prepare($news)->withTemplate();

Seo::template()->add(
    new TemplateSeo(
        name: 'Новости',
        model: News::class,
    )
);