> For the complete documentation index, see [llms.txt](https://docs.astrotomic.info/stancy/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.astrotomic.info/stancy/basics/pagedata.md).

# PageData

Stancy uses [spatie/data-transfer-object](https://github.com/spatie/data-transfer-object) to validate the passed in data and allow static analysis.

## Properties

Your page data class should extend `\Astrotomic\Stancy\Models\PageData` and define all possible attributes via public properties including a doc-tag with all possible types (FQCN for objects).

{% code title="app/Pages/Blog.php" %}

```php
<?php

namespace App\Pages;

class Blog extends PageData
{
    /** @var string */
    public $title;
    
    /** @var \Carbon\Carbon */
    public $date;

    /** @var \App\Pages\Post[] */
    public $posts;
}
```

{% endcode %}

## Traits

The package comes with some ready to use traits with the most common attributes.

* `\Astrotomic\Stancy\Traits\PageHasContent` adds the `contents` attribute (used by  markdown content parsers)
* `\Astrotomic\Stancy\Traits\PageHasDate` adds the `date` attribute (used by `\Spatie\Sheets\PathParsers\SlugWithDateParser`)
* `\Astrotomic\Stancy\Traits\PageHasOrder` adds the `order` attribute (used by `\Spatie\Sheets\PathParsers\SlugWithOrderParser`)
* `\Astrotomic\Stancy\Traits\PageHasSlug` adds the `slug` attribute (used by path parsers)

{% code title="app/Pages/Blog.php" %}

```php
<?php

namespace App\Pages;

use Astrotomic\Stancy\Models\PageData;
use Astrotomic\Stancy\Traits\PageHasContent;
use Astrotomic\Stancy\Traits\PageHasSlug;

class Blog extends PageData
{
    use PageHasSlug, PageHasContent;
}
```

{% endcode %}

## Routable & PageHasUrl

The package comes with a `\Astrotomic\Stancy\Contracts\Routable` interface which defines a `getUrl()` method. You can combine it with the `\Astrotomic\Stancy\Traits\PageHasUrl` trait which defines the `toSitemapItem()` method by using the `getUrl()` return value. It's also great to get the page url in a view or for the feed item transformation.

{% code title="app/Pages/Blog.php" %}

```php
<?php

namespace App\Pages;

use Astrotomic\Stancy\Contracts\Routable;
use Astrotomic\Stancy\Models\PageData;
use Astrotomic\Stancy\Traits\PageHasUrl;

class Blog extends PageData implements Routable
{
    use PageHasUrl;

    public function getUrl(): string
    {
        return url('/blog');
    }
}
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.astrotomic.info/stancy/basics/pagedata.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
