You don't store the day. Just use a datetime type, use the dates array in your model and use Carbon to format the date,
Jul 27, 2018
3
Level 1
Storing (Days) in database
I'm working on listing schedule, I want to store all of these values in a table called listing_working_hours I want to store all of the following data
(day, from_time, to_time, listing_id)
This will shows that listing (x) is open on (Friday from 8:00 AM to 4:pm) and on (Saturday from 6:00 am to 6:00 pm) ..etc.
what is the best practice to store day (integer value, enum, relation to another table ..etc.)?
Level 122
If by 'Friday' you mean any friday then store an integer for the day of the week, ie 5
You could perhaps lean on Carbon constants but probably not necessary
1 like
Please or to participate in this conversation.