PHP code example of gabrieliuga / laravel-seo-meta-box

1. Go to this page and download the library: Download gabrieliuga/laravel-seo-meta-box 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/ */

    

gabrieliuga / laravel-seo-meta-box example snippets


/**
* Manual entry
*/
Seo::create([
    'slug' => '/', //this is the page route 
    'title' => 'Super special application',
    'description' => 'My super special application that does x',
    'type' => 'page'
]);

/**
* Model based generator
*/

use Giuga\LaravelSeoMetaBox\Traits\HasSeo;
use Giuga\LaravelSeoMetaBox\Traits\SeoOptions;
use Illuminate\Database\Eloquent\Model;

class Page extends Model
{
    use HasSeo;

    public function getSeoOptions(): SeoOptions
    {
        return SeoOptions::create()
            ->setSlugField('slug') // optional
            ->setRoutePrefix('/page/') // optional
            ->setTitleField('name') // optional
            ->setDescriptionField('short_description') // optional
            ->setOverwriteOnUpdate(); // optional
    }
}