### Install Laravel Filament SEO package Source: https://github.com/ralphjsmit/laravel-filament-seo/blob/main/README.md Use Composer to install the package, which automatically includes the required laravel-seo dependency. ```shell composer require ralphjsmit/laravel-filament-seo ``` -------------------------------- ### Create and Edit SEO-enabled Filament Forms Source: https://github.com/ralphjsmit/laravel-filament-seo/blob/main/README.md Examples of implementing Filament Forms in Livewire components for creating and editing Eloquent models with integrated SEO fields. These snippets demonstrate the required form schema, model binding, and state management. ```php namespace App\Http\Livewire; use App\Models\Post; use Filament\Forms\Components\Card; use Filament\Forms\Components\TextInput; use Filament\Forms\Concerns\InteractsWithForms; use Filament\Forms\Contracts\HasForms; use Illuminate\Contracts\View\View; use Illuminate\Database\Eloquent\Model; use Livewire\Component; use RalphJSmit\Filament\SEO\SEO; class CreatePost extends Component implements HasForms { use InteractsWithForms; public array $data = []; public function mount(): void { $this->form->fill(); } public function render(): View { return view('livewire.create-post'); } protected function getFormSchema(): array { return [ TextInput::make('title'), Card::make([ SEO::make() ]), ]; } protected function getFormStatePath(): ?string { return 'data'; } protected function getFormModel(): Model|string|null { return Post::class; } public function submitForm() { $post = Post::create($this->form->getState()); /** Do not forget this step. */ $this->form->model($post)->saveRelationships(); } } ``` ```php namespace App\Http\Livewire; use App\Models\Post; use Filament\Forms\Components\TextInput; use Filament\Forms\Concerns\InteractsWithForms; use Filament\Forms\Contracts\HasForms; use Illuminate\Contracts\View\View; use Illuminate\Database\Eloquent\Model; use Livewire\Component; use RalphJSmit\Filament\SEO\SEO; class EditPost extends Component implements HasForms { use InteractsWithForms; public Post $post; public function mount(): void { $this->form->fill([ 'title' => $this->post->title, ]); } public function render(): View { return view('livewire.edit-post'); } protected function getFormSchema(): array { return [ TextInput::make('title'), SEO::make(), ]; } protected function getFormModel(): Model|string|null { return $this->post; } public function submitForm() { $this->post->update( $this->form->getState(), ); } } ``` -------------------------------- ### Configure Robots Meta Tag Options Source: https://context7.com/ralphjsmit/laravel-filament-seo/llms.txt Explains how to include the robots field in SEO forms and provides examples for updating robots directives programmatically on a model. ```php use RalphJSmit\Filament\SEO\SEO; // Include robots in your SEO form SEO::make(['title', 'description', 'robots']); // Example: Setting robots programmatically on the model $post = Post::find(1); $post->seo->update([ 'title' => 'My SEO Title', 'description' => 'Meta description for search results', 'robots' => 'noindex, nofollow', ]); ``` -------------------------------- ### Basic SEO::make() Usage in Filament Resource Source: https://context7.com/ralphjsmit/laravel-filament-seo/llms.txt Demonstrates the basic usage of the `SEO::make()` component within a Filament resource's form schema. This component automatically includes fields for title, author, description, and robots, with data binding to the model's SEO relationship. ```php schema([ TextInput::make('title') ->required() ->maxLength(255), Textarea::make('content') ->required() ->rows(10), // SEO component automatically handles all SEO fields SEO::make(), ]); } } ``` -------------------------------- ### Implement Livewire Component for SEO Editing Source: https://context7.com/ralphjsmit/laravel-filament-seo/llms.txt Demonstrates how to create a Livewire component that integrates Filament forms with SEO fields. It handles model hydration and automatic relationship saving for SEO data. ```php namespace App\Http\Livewire; use App\Models\Post; use Filament\Forms\Components\Card; use Filament\Forms\Components\TextInput; use Filament\Forms\Components\Textarea; use Filament\Forms\Concerns\InteractsWithForms; use Filament\Forms\Contracts\HasForms; use Illuminate\Contracts\View\View; use Illuminate\Database\Eloquent\Model; use Livewire\Component; use RalphJSmit\Filament\SEO\SEO; class EditPost extends Component implements HasForms { use InteractsWithForms; public Post $post; public array $data = []; public function mount(): void { $this->form->fill([ 'title' => $this->post->title, 'slug' => $this->post->slug, 'content' => $this->post->content, ]); } protected function getFormSchema(): array { return [ Card::make([ TextInput::make('title')->required()->maxLength(255), TextInput::make('slug')->required(), Textarea::make('content')->required(), ]), Card::make([ SEO::make(), ])->heading('SEO Settings'), ]; } public function submitForm(): void { $formData = $this->form->getState(); $this->post->update([ 'title' => $formData['title'], 'slug' => $formData['slug'], 'content' => $formData['content'], ]); } } ``` -------------------------------- ### Create Blade View for SEO Forms Source: https://context7.com/ralphjsmit/laravel-filament-seo/llms.txt Provides a sample Blade template structure for rendering Filament forms within Livewire components for creating or editing records. ```blade