I'm developing a site in which there is a reward chart table type thing (if you've never seen one, it's just a checklist for certain activities each day of the week to ensure your kids are doing their tasks, you can search one up for better visual).
I'm developing using Laravel 11 and MYSQL, and to store the table I was planning on using one of two methods, either storing it in a string like this:
'tasks' => 'Brush Teeth, Make bed, Wash, Make table',
'task_states_all' => 'Basketball,Flower_Blue,False,Plane,False,Plane,False;False,Flower_Pink,Mushroom,False,Basketball,Plane,Mushroom;Flower_Blue,False,False,Flower_Pink,False,Unicorn,False;False,Unicorn,Plane,False,Flower_Pink,Flower_Blue,Basketball',
and then using Laravel's blade PHP tools, seperate the task_states_all by semicolons, and then commas to get the specfic value for each cell, (Basketball, Flower_Blue, Plane etc are just name of the stickers which will appear in its place). Another option was using json like this:
{
"tasks": [
{
"name": "Task 1",
"schedule": {
"Monday": true,
"Tuesday": false,
"Wednesday": true,
"Thursday": false,
"Friday": true,
"Saturday": false,
"Sunday": true
}
},
{
"name": "Task 2",
"schedule": {
"Monday": false,
"Tuesday": true,
"Wednesday": false,
"Thursday": true,
"Friday": false,
"Saturday": true,
"Sunday": false
}
},
{
"name": "Task 3",
"schedule": {
"Monday": true,
"Tuesday": true,
"Wednesday": true,
"Thursday": true,
"Friday": true,
"Saturday": true,
"Sunday": true
}
}
]
}
My issue comes in editing the string/json. Obviously, the table is editable by the user. When they choose a different sticker, or a different task name, it needs to be reflected in the string or json, but as they are stored in one string, I'm not sure on how to change the string in such a way that one word is altered whilst the rest remain the same, and so that the altered word is the correct one, so another sticker isnt change etc.
I could have made like 70 columns in my table, each with a name and state for that specific task and day of the week, but i felt that wouldnt be efficient. Anyone have any ideas? If you need any other code snippets, please let me know.