If you got as far as reading this reply, thanks for reading :)
I have my classes! Best approach to inputs!
TLDR; I've probably answered my own question, but seek re-assurance on direction, please read :P
So I have set myself a simple task of modelling an event calendar.
- There's one calendar showing one day at a time
- Per date there's a number of 'events' depicting available 'bookings'
So I have my Event, representing start and end times, EventCollection representing a collection of these Events, and a Calendar representing a single collection of events, along with any applicable calendar related information.
The calendar, regardless of input will build up a collection of events marked as available, then, depending on if the current date is today, then it'll mark a number of these available blocks as unavailable since I want to build in lead time for preparation for these events to occur.
Once I have selected a number of dates from the UI representing the calendar, I'm storing these to a session for processing after the next UI, which will confirm the selected events.
These are passed using the key of an input, for example 1030_1130, 1200_1300.
So far, all of the above is completely fine, I've got this working with some test data, but now comes the inclusion of persistence and inputs.
Given that the form handler will return an array of times for the events 'selected', what is the best strategy of putting these inputs back into my event collection (not the calendar this time since we'll be using a booking class), taking into account that the reverse of this operation, retrieving from the database for editing, will present the data in a different way.
I've toyed around with populateFromDb, populateFromInput, but I feel the need to gouge my eyes out since I know there's something missing!
Eloquent converts all dates to Carbon, so I feel I need to present the data to the class using a common interface, so all I'd need to do is convert my form inputs into carbons and pass them using the applicable 'addEvent' and Bob's your Grannies Uncle!
Would this be a scenario for building an interface, and if I want to pass form inputs, that I'd just reference the interface and use whichever type the source data came from?
Would this be in say, the form of 'formEventRepository'? What's the best strategy to name this?
I'm all too hung up on the strategy of all of this, but I'm trying to build common classes, and handle it in such a way I can throw data at it in many forms, and have the big old classes doing the leg work for me!
Advice is more than welcome!
Please or to participate in this conversation.