You're probably better storing them as datetime's or just integers - then the algorithm is easier? Depends exactly how you're planning to check the availability I guess though - if it's really 'any monday, 9-5' then you'd maybe do it differently :-)
Feb 29, 2016
15
Level 10
Whats the best practice to save these data
I've a form where I take availability of a user in a week. Lets say he can be available on Monday and Tuesday from 9:30 to 12:00, and Monday to Friday 5:00 to 7:00. I want to save these details in database and later I want to check if someone is available during the specified time.
array:1 [▼
0 => {#175 ▼
+"days": array:2 [▼
0 => "Monday"
1 => "Thursday"
]
+"from": "9"
+"to": "12"
}
]
The above $request object shows an example of my form submission. Should I save each day in separate row with from and to time repeated as many times? Or is there any better way I can save this data and retrieve data?
My table looks like below:
id user_id day from to
Your advice would be greatly appreciated. Thanks in advance.
Please or to participate in this conversation.