> ## Documentation Index
> Fetch the complete documentation index at: https://docs.filarank.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Usage

> Prepare your model, add the SEO form section, show the score column, and render tags on your frontend

<Steps>
  <Step title="Prepare your model">
    ```php theme={null}
    use Usamamuneerchaudhary\FilaRank\Concerns\HasSeo;

    class Post extends Model
    {
        use HasSeo;
    }
    ```

    By default the analyzer reads the model's `content` and `slug` attributes and falls back to `title` for the page title. Override if your columns differ:

    ```php theme={null}
    public function getSeoContent(): ?string
    {
        return $this->body;
    }

    public function getSeoSlug(): ?string
    {
        return $this->permalink;
    }
    ```
  </Step>

  <Step title="Add the SEO section to your Filament form">
    ```php theme={null}
    use Usamamuneerchaudhary\FilaRank\Forms\SeoFields;

    public static function form(Schema $schema): Schema
    {
        return $schema->components([
            TextInput::make('title'),
            TextInput::make('slug'),
            RichEditor::make('content'),

            SeoFields::make(), // assumes `content` + `slug` fields on this form
        ]);
    }
    ```

    If your body field has a different name, or lives somewhere unusual in the schema tree:

    ```php theme={null}
    SeoFields::make(contentField: 'body', slugField: 'permalink');

    // or take full control of where the values come from:
    SeoFields::make(
        getContentUsing: fn (Get $get) => $get('../body'),
        getSlugUsing: fn (Get $get) => $get('../permalink'),
    );
    ```

    <Note>
      `SeoFields::make()` binds to the `seo` relationship, so it must be used on a form with a record model that uses `HasSeo`.
    </Note>
  </Step>

  <Step title="Show the score in your table">
    ```php theme={null}
    use Usamamuneerchaudhary\FilaRank\Tables\SeoScoreColumn;

    public static function table(Table $table): Table
    {
        return $table->columns([
            TextColumn::make('title'),
            SeoScoreColumn::make(),
        ]);
    }
    ```

    Scores are recalculated and stored whenever the model is saved (disable with `'persist_score' => false`).
  </Step>

  <Step title="Render the tags on your frontend">
    In your layout's `<head>`:

    ```blade theme={null}
    <x-filarank::tags :model="$post" />
    ```

    Or for static pages without a model:

    ```blade theme={null}
    <x-filarank::tags title="Contact us" description="Get in touch with our team." />
    ```
  </Step>

  <Step title="Analyze anything programmatically">
    ```php theme={null}
    use Usamamuneerchaudhary\FilaRank\SeoAnalyzer;

    $report = SeoAnalyzer::analyze([
        'title' => 'Coffee Beans Guide',
        'description' => '…',
        'focus_keyword' => 'coffee beans',
        'slug' => 'coffee-beans',
        'content' => $html,
    ]);

    $report->score();            // 0–100 or null
    $report->seoScore();
    $report->readabilityScore();
    $report->rating();           // Status::Good | Ok | Bad
    $report->results;            // list of CheckResult
    ```

    Or against a model directly: `SeoAnalyzer::analyzeModel($post)`.
  </Step>
</Steps>
