Correlating db entries directly to a PHP Class

Posted 2 months ago by mynameiscody07

I'm not sure how to do this or if what the title says is even the best way to handle my situation but I need some advice. I'll give a quick run down on what I'm trying to do below.

If anyone here is in a bowling league you know that their are all sorts of side games that people play with everyone else in the league including things like, high game, high series, brackets and many more. I'm working on building a system that allows to run all these side games, the current software for these things is ancient looking and not modern at all.

The idea is that users create leagues, they then can add bowlers to the league, each week they can add a new event and inside that event they can add what ever side games they will be running. When someone signs up they can attach the bowler to the games they want to participate in. With this the user can simply then add the bowlers scores in one place and every game they are in will know what to do with it.

Now with all that it brings me to my question. All of these game types have very different rules of how they work so they all need to be their own PHP class or classes to work correctly. How do I correlate entries in say a game_types table to their perspective PHP classes, or how can I correlate the GameType Eloquent Model to the different PHP classes based on a field in the database? There may be a better way to do this but I think by having the all the games in a table I can then use an event_game pivot table to save which games each event is running.

With all that being said in the future as more games are added I would also like some way to do it without necessarily running a new seed to add the new game type to the database, the system should just know. I'm guessing some sort of Service Provider is the answer, I'm just not sure how.

Hope this makes sense and it not just me rambling.

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.