Closed newtongamajr closed 4 years ago
Hi! I added migration(s) publishing in version 1.3.0. I also now allow the user to configure the table name.
Can you tell me what do you mean by model publishing? Do you really need to overwrite the model and the resource classes?
Hi @Tarpsvo ! Yes, I need to modify Note model in order to add a Trait that indicates that this model uses a connection with another schema. What I think, that's the best way, is to create a new class inherited from Note, or transform the Note model content on a Trait, so we can use this trait on a brand new Note class, or even you can combine both. Since you use this model to access and maintain data, there's no need to publish Resource Class. Just add the $model = {model informed on config file or Note model by default}
Hey! Sorry for the delay.
I added an option to the config which allows you to provide your own Notes model.
Just create a new class that extends the class \OptimistDigital\NovaNotesField\Models\Note
, add your own traits to it and then place it in the config as App\Models\CustomNote::class
and it should work.
Good luck!
Hi @Tarpsvo! Just to say thank's for your attention to solve my problem. Now everything is working really fine. An observation about your config option 'get_avatar_url' that became unnecessary now because extending the Note model, allowed me to overload the getCreatedByAvatarAttribute like this: public function getCreatedByAvatarUrlAttribute() { $createdBy = $this->createdBy; if (empty($createdBy)) return null; return $createdBy->url_avatar; }
And another thing about Note Model: $fillable is referencing 'model_id' and 'model_type' instead of 'notable_id' and 'notable_type'. As I'm extending this class, I could overload this too, but if someone is not doing that, will receive errors during record CRUD operations.
I use several packages including multi-tenant. In the case of a multi-tenant its necessary to inform that the migrations will occur on the tenant-side or on the system-side. For models, I have to tell my model that the connection will occur to the tenant database or system database. If migrations and models are publishable, I can manage this problem and use your package, that's great! Also suggest, a config file to point for an alias for id columns, table names. model names and so on.
Thanks for your good job and I hope that my suggestions to be implemented for this package improvement!