I have a controller to generate a customized Excel spreadsheet.
But the method is very big (set titles, customize the cells, ...).
And I have to generate in the same sheet three same tables with different datas.
So to use three times the same code, I want to dispatch the code in methods.
I have tried to add other methods in the controller and access to them using $this-> but Laravel generates an error saying that it's not a model context.
I wanted to create a model (not extended from Laravel Model) which extends PHPSpreadSheet class to be able to use the PHPSpreadSheet methods and my methods, I have tried, but Laravel generates an error saying that the spreadsheet methods are undefined.
How is it possible to extend a model from another external model in Laravel to be able to reuse the external model methods ?
In your new model, or service class, have use statements for the models needed. Otherwise the data is going to be unavailable.
I do similar sometimes, have another class to work out a bunch of where clauses, so a method in a model doesn't get overly bloated, and just use a return statement.