I'm writing my first Laravel package, and I need to add some lines of code (like routes to web.php, or add a function to a controller) on an event triggered by the user. How can I open the file and add some code to it?
(I know that the package's routes, views... should be published through Service Provider, but I Don't Think It'll work in this case, Because I want to Generate / Write to a file based on the user's action on view, for example, if the user wants to generate crud for a table I have to add a route to web.php of the project dynamically, and not to the one in Service provider