whitecube / nova-page

Static pages content management for Laravel Nova
https://whitecube.github.io/nova-page
MIT License
239 stars 40 forks source link

We should prefix the default page fields #8

Closed voidgraphics closed 5 years ago

voidgraphics commented 5 years ago

The title, created_at and updated_at fields that automatically come with every template should be prefixed (for example __title), so that it does not conflict or restrict the fields users can define.

toonvandenbos commented 5 years ago

Those fields are already prefixed.

The updated_at field is automatically maintained by the Filesystem Source and is therefore not displayed on the Nova edit page, meaning it cannot cause conflicts with the user's fields.

The two other fields, created_at and title are automatically prefixed with nova_page_. Take a look at Pages\Resource:

    /**
     * Get the base common attributes
     *
     * @return array
     */
    protected function getBaseAttributeFields()
    {
        return [
            Text::make('Page title', 'nova_page_title')
                ->rules(['required', 'string', 'max:255']),

            DateTime::make('Page creation date', 'nova_page_created_at')
                ->format('DD-MM-YYYY HH:mm:ss')
                ->rules(['required', 'string', 'max:255']),
        ];
    }

In the Template class (and in the JSON files also), these values are never filled in the attributes array, meaning they're never mixed with the user's values.

In my opinion this issue can be closed, unless you have a specific problematic case in mind?

toonvandenbos commented 5 years ago

After some more testing, I'm closing this issue. Feel free to open it again if needed.