This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

leocavalcante
leocavalcante

How have you guys been using October?

  1. As a framework and not editing modules/ directory. What you do when you need to extend some feature not supported yet?

  2. Or more like a boilerplate/skeleton then assuming modules/ as part of your own code, not as 3th-party, then editing it. Then how to apply updates?

Cheers.

philipptempel
philipptempel

If you find a bug or any missing feature that is not an application-specific feature, you can file an issue over on GitHub or - even better - create a PR with your data. In any other case, if you want to extend core models to have more functionality or relations, just use October's built-in Model Extending Feature that allows not only to define relationships on the go, but also to add methods or whatever you need. If this does not suffice, then create your own component and extends the core classes.

But to give you an exact answer to your question: number one with what I said above about extending models.

leocavalcante
leocavalcante

Sure I did that: https://github.com/octobercms/october/pull/1853 But while it isn't merged or if it never will?

Model Extending Feature does't not allow you to add or override $fillable and/or $jsonable properties, for example, as long as I know. Don't know if I'm overusing October, but I always need something that does not dispatch some extensibility event or isn't available thought a public API yet like WidgetBase session handling, you aren't able to know in your lists if the column is being sorted by asc or desc orders.

Renatio
Renatio

Take a look into: vendor/october/rain/src/Database/Model.php class.

There are methods like addFillable, jsonable, getJsonable.

As for your PR, you can try to use model accessors or hook into fetch records event.

leocavalcante
leocavalcante

Renatio said:

Take a look into: vendor/october/rain/src/Database/Model.php class.

There are methods like addFillable, jsonable, getJsonable.

As for your PR, you can try to use model accessors or hook into fetch records event.

Awesome. I should take a closer look at Rain library. Thanks. Any links about "model accessors or hook into fetch records event" feature?

jakobf
jakobf

Hi there.

Can someone please point out the right way to add a method? I think the ExtendableTrait which is attached to the \October\Rain\Database\Model allows for additional Methods, but still I could not figure out the correct way to add an Accessor (get[...]Attribute). Do I need to create a \System\Classes\ModelBehavior and add it to the $implement property of the model to extend? Help is appreciated. Regards Jakob

alxy
alxy

To add methods, there is addDynamicMethod. As for an example, you can have a look on this plugin source: https://github.com/scottbedard/blogtags/blob/master/Plugin.php#L107-L115

jakobf
jakobf

Yes, finally found it. For someone who's interested, check out the library readme:

october/rain/src/Extension/README.md

The explanation is pretty simple.

Thanks alxy!

Last updated

1-8 of 8

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.