Creating an Attribute
Attributes are pretty self-explanatory. They are the data that modules use to do their work. They can be anything from a simple string to a complex object.
Making Your Attribute Known
Just like modules, attributes are added with a standard extender. Attributes are scoped by module type.
use OrdinaryJellyfish\Sentra\Extend\Attributes;
return [ (new Attributes('post-analysis')) ->add(MyAttribute::class),];
Writing Your Attribute
Attributes are simpler than modules. You only need to implement one method: handle
.
class MyAttribute{ public function handle(Post $post, User $user): array { return [ 'key' => 'value', ] }}