PHP code example of mad-web / laravel-seoable

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

    

mad-web / laravel-seoable example snippets


'providers' => [
    // ...
    MadWeb\Seoable\SeoableServiceProvider::class,
];

return [
    /*
    |--------------------------------------------------------------------------
    | Seo Data Table
    |--------------------------------------------------------------------------
    |
    | You can customize seo data storing table for your models
    */
    'seo_data_table' => 'seo_data',

    /*
    |--------------------------------------------------------------------------
    | Seo Data Templates Path
    |--------------------------------------------------------------------------
    |
    | Path to lang file where you can set property template
    |
    | Supported properties: "title", "description"
    */
    'templates_path' => 'seoable::seo',

    /*
    |--------------------------------------------------------------------------
    | Seo Data Model
    |--------------------------------------------------------------------------
    |
    | Model name for seo data table
    */
    'model' => \MadWeb\Seoable\Models\SeoData::class
];

/*
|--------------------------------------------------------------------------
| Seo Data Templates Path
|--------------------------------------------------------------------------
|
| Path to lang file where you can set property template
|
| Supported properties: "title", "description"
*/
'templates_path' => 'seoable::seo',

class User implements Seoable
{
    use SeoableTrait;
    ...
    
    public function seoable()
    {
    }
}

public function seoable()
{
    $this->seo()
        ->setTitle('full_name')
        ->setDescription('full_name');
}

return [
    \App\User::class => [
        'title' => 'This is page title for user profile :full_name',
        'description' => 'This is page description for user profile :full_name',
        'twitter_card' => [
            'title' => 'Page title for twitter card :full_name',
            'description' => 'Page description for twitter card :full_name'
        ],
        'open_graph' => [
            'title' => 'Page title for open graph :full_name',
            'description' => 'Page description for open graph :full_name'
        ]
    ]
];

public function seoable()
{
    $this->seo()
        ->setTitleRaw('Some awesome title')
        ->setDescriptionRaw('Some awesome description');
}

public function seoable()
{
    $this->seo()
        ->setTitle(['name' => 'full_name', 'address' => 'email'])
        ->setDescription('full_name');
}

$user = User::find(1)
$user->seoData->update(['meta' => ['title' => 'some title']]);

public function show($post)
{
    $post->seoable()
    ...
}

public function show($post)
{
    $post->seoable()->meta()
    ->setTitleRaw('Some Post Title');
    ...
}

public function show($post)
{
    $post->seoable()->meta()->ignoreStored()
    ->setTitleRaw('Some Post Title');
    ...
}

'aliases' => [
    // other Facades ommited
    'SEO' => Artesaos\SEOTools\Facades\SEOTools::class,
]

php artisan vendor:publish --provider="Artesaos\SEOTools\Providers\SEOToolsServiceProvider"

public function seoable()
{
    return $this->seo()
        ->setTitle(['name', 'email'])
        ->setDescription('name')
        ->setCanonical('url')
        ->setPrev('link')
        ->setNext('link')
        ->setKeywords('keywords')
        ->setLanguages([
            [
                'lang' => 'ru',
                'url' => 'lang_url' // Resolving by model attribute
            ]
        ])
        ->addLanguage('en', 'lang_url')
        ->addMeta('foo', 'bar')
        ->setMeta([
            [
                'meta' => 'some',
                'value' => 'name'
            ],
            [
                'meta' => 'another',
                'value' => 'tag'
            ]
        ])
        ->twitter()
            ->setTitle('name')
            ->setDescription('name')
            ->setUrl('url')
            ->setSite('site_name')
            ->setType('type')
            ->setImages(['avatar', 'image'])
            ->addValue('foo', ['name', 'name'])
            ->setValues([
                [
                    'key' => 'foo',
                    'value' => 'attribute'
                ],
                [
                    'key' => 'another',
                    'value' => 'another_attribute'
                ]
            ])
        ->opengraph()
            ->setTitle('name')
            ->setDescription(['name', 'email'])
            ->setUrl('url')
            ->setSiteName('site_name')
            ->setImages(['avatar', 'image'])
            ->setProperties([
                [
                    'key' => 'foo',
                    'value' => 'attribute'
                ],
                [
                    'key' => 'another',
                    'value' => 'another_attribute'
                ]
            ])
            ->addProperty('foo', ['name', 'email']);
}
app.php