PHP code example of martin6363 / filament-smart-seo

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

    

martin6363 / filament-smart-seo example snippets


use Filament\Panel;
use Martin6363\FilamentSmartSeo\FilamentSmartSeoPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugins([
            FilamentSmartSeoPlugin::make(),
        ]);
}

return [
    'available_locales' => ['en', 'ru'],
    'api_key' => env('GEMINI_API_KEY'),
    'gemini_model' => 'gemini-2.5-flash',
    'ai_autofill_enabled' => true,
    'max_title_length' => 60,
    'max_description_length' => 160,
    'preview_base_url' => env('APP_URL'),
    'preview_fallback_title' => 'Page title',
    'preview_fallback_description' => 'Your meta description will appear here...',
    'og_image_disk' => 'public',
    'og_image_directory' => 'seo/og-images',
    'settings_store' => Martin6363\FilamentSmartSeo\Stores\DatabaseSeoSettingsStore::class,
];

use Illuminate\Database\Eloquent\Model;
use Martin6363\FilamentSmartSeo\Traits\HasSeo;

class Vehicle extends Model
{
    use HasSeo;
}

use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\TextInput;
use Martin6363\FilamentSmartSeo\Forms\Components\SeoSection;

TextInput::make('title')->

'ai_autofill_enabled' => false,

SeoSection::make()
    ->withoutAiAutofill()
    ->localeSuffixed()
    ->locales(['en', 'ru'])
    ->previewUrl(url('/vehicles'));

->locales(['en', 'ru'])

use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Components\Tabs;
use Filament\Schemas\Components\Tabs\Tab;
use Martin6363\FilamentSmartSeo\Forms\Components\SeoSection;

private const LOCALES = ['en', 'ru'];

Tabs::make('Translations')
    ->tabs([
        Tab::make('English')->schema([
            TextInput::make('title_en')->DescriptionField('description')
    ->previewUrl(url('/vehicles'))
    ->withoutImage();

use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\TextInput;
use Martin6363\FilamentSmartSeo\Forms\Components\SeoSection;

TextInput::make('title')->OgPreview();

->withMobileOgPreview()

->withMobileOgPreview(fn (): bool => auth()->user()?->isAdmin())

use Filament\Pages\Page;
use Filament\Schemas\Schema;
use Martin6363\FilamentSmartSeo\Concerns\InteractsWithSeoSettings;
use Martin6363\FilamentSmartSeo\Forms\Components\SeoSection;

class SiteSettings extends Page
{
    use InteractsWithSeoSettings;

    public ?array $data = [];

    public function mount(): void
    {
        $this->form->fill($this->getSeoSettingsFormData());
    }

    public function form(Schema $schema): Schema
    {
        return $schema
            ->statePath('data')
            ->components([
                SeoSection::make()
                    ->settingsKey('site.seo')
                    ->translatable()
                    ->sourceTitleField('site_name')
                    ->sourceDescriptionField('site_tagline'),
            ]);
    }

    public function save(): void
    {
        $this->saveSeoSettingsFromFormData($this->form->getState());
    }
}
bash
php artisan vendor:publish --tag=filament-smart-seo-config
php artisan vendor:publish --tag=filament-smart-seo-migrations
php artisan migrate