Might also be worth noting that I use the calculations MANY controllers, since there are a lot of related functions to classes/events: ticket sales/returns/admin-management/etc., attendee management, and more. So this will be used through a huge chunk of the website.
Model manipulation before every call
Hello! I am hoping for advice on how to best approach my problem. Strategies or tips.
I have a website with repeating events & classes. They all repeat using iCal standard, and I decided to calculate each event, rather than store each instance independently in the database. So everytime I get an event, I have to run functions (that I currently have swept under the rug in a Trait) that calculate the instance of the event with a given date in the route uri.
So my question, is whether it's possible to run these calculations BEFORE the model hits the controller. Unfortunately these calculations need a composer package to run... In case that's important.
My urls related to events all look like:
Route::get('/{eventsOrClasses}/{event}-{slug}/{date}', EventController@show);
(fyi: since events and classes run exactly the same, I use the eventsOrClasses variable to switch from an Event model to a Class model which both extend the same base class. I do this switch with route model binding checks)
I appreciate any insight you can give me!
Can't it all be in a service provider (or repository class), and then inject that into your controller instead of the model?
Please or to participate in this conversation.