Eloquent & form model for business hours

Posted 3 years ago by Red scorpion

Hi,

i'm trying to implement business hours for my users. So i have basic users table and user_business_hours table, which looks like this:

| id | user_id | weekDay | start_time | end_time | is_break | created_at | updated_at |
|---:|---------|--------:|------------|----------|----------|------------|------------|
| 1  | 10      | 1       | 10:00:00   | 16:00:00 | 0        | ...        | ...        |
| 2  | 10      | 1       | 12:00:00   | 12:30:00 | 1        | ...        | ...        |

When is_break parameter id 1 the times represents working break (eg. lunch)

Now the problem: How to query this model and setup form model / inputs, that laravel will automatically fill nescessary inputs with provided values whlie updating bussiness hours for particular user?

I was thinking about this input organisation:

| ...     | Work From | Work From | Break From | Break To |
|---------|-----------|-----------|------------|----------|
| Monday  | 10:00:00  | 18:00:00  | 12:00:00   | 13:00:00 |
| Tuesday | <input>   | <input>   | <input>    | <input>  |

Thanks for your ideas

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