Mity Docs Mity Docs for Mity Digital
Feedamic Documentation

Feedamic Author

The new FeedamicAuthor model is far more intelligent and powerful than in earlier versions, and will automatically be created based on your Feed configuration.

Feedamic ships with its own MityDigital\Feedamic\Models\FeedamicAuthor model that is all ready to go.

All of the intelligence of this class is in an Abstract class - MityDigital\Feedamic\Abstracts\AbstractFeedamicAuthor. You are free to create your own Feedamic Author model, however you must extend this class.

Create

Creating a new Model requires a resource (either a Statamic\Entries\Entry or Statamic\Auth\User), and a FeedamicConfig object. This will allow all of the intelligence inside to know what Feed it belongs to, as well as have access to the original resource - an Entry or a User.

Your own Feedamic Author must use this same signature.

The Resource

The Resource of the FeedamicAuthor can be either an Entry (Statamic\Entries\Entry) or a User (Statamic\Auth\User).

This Resource, plus the FeedamicConfig, is all that is needed to do the heavy lifting for you.

When your Feed is configured to link to an Entry or User for the Author, the FeedamicAuthor model will know what fields and methods to use to get you your Name and Email address (if enabled).

When your Feed is configured to use fields in your Entry itself, the FeedamicAuthor model will know how to access these fields.

For token-based values, the FeedamicAuthor model will correctly tokenise the templates and populate new values.

Public methods

These fields do the heavy lifting for you including determining the name based on field or field token templates.

If you extend the FeedamicAuthor class, feel free to do whatever you need to do: but there are smarts here to help you out.

email

Returns the email address for the author.

May be null.

name

Returns the name for the author.

May be null.

resource

Returns the resource, either an Entry (Statamic\Entries\Entry) or a User (Statamic\Auth\User).

Accessing the Resource

Calls to the underlying Author's resource are forwarded - for both method calls and properties.

For example, accessing the Resource (i.e. a User) email method is as simple as:

1$feedamicAuthor->email();

If the property you're trying to access is actually part of the Feedamic Author too, you might need to access the resource first:

1$feedamicAuthor->name(); // the FeedamicAuthor name()
2 
3$feedamicAuthor->resource()->name(); // the Statamic User name()