Closed Mina-R-Meshriky closed 3 years ago
@Mina-R-Meshriky you can use laravel model events : https://laravel.com/docs/5.8/eloquent#events
you can define this events into your specific model's into boot()
method
e.g.
model::creating(..
before model generation
model::created(..
after model generation
Sorry, poor words choice I guess, What I mean is before the (api, web) scaffolding and after that.
I see on the generate method's last line return Response::json("Files created successfully");
but isn't there any custom event triggered so I can hook some more actions after the scaffolding is done ?
@Mina-R-Meshriky The question looks little bit confusing to me. Are you looking for events at model level or at the generator level?
so what I mean to Model level is, something like when model is created in the database. And Generator level is when Generator command is generating files.
Clarify this and then maybe we can help.
sorry for any inconvenience. Actually I mean an event on the Generator Level, when generating files. What I need is to add the name of the generated model to my database and if I rolled the model back (deleting the files) I want to delete it from my database in both cases I also will perform a git commit committing the files that has just been added or deleted. of course this can be done easily If I am using only the Artisan Commands. but what about the GUI generator, when a model is being generated, I have no control on doing anything before or after the generation of files
@Mina-R-Meshriky it's not available at this point in time, but I can add it to the future scope.
Here is the documentation for this: https://infyom.com/open-source/laravelgenerator/docs/8.0/generator-options#file-creation--deletion-events
Dears, great job on that package. I wonder if there is any event listeners for before model generation, after model generation, before update, and after update.? as I want to make some checks before actually generating a model and some database insertions and a git commit after creating it.