@faezx3 I would tend to create a categories table and just store a look up I'd for the category. Then you could just get the categories and loop those to obtain each count. There is probably a way to do what you want in eloquent, but that is the way I would structure this.
Group the category and get count from period date
Hello, and happy new years.
| ID | category | status | created_at | updated_at | |----|-------------|-------------|---------------------|---------------------| | 1 | Server | Complete | 2019-12-23 13:15:12 | 2019-12-23 13:12:57 | | 2 | Laptop | In Progress | 2019-12-23 13:15:12 | 2019-12-23 13:12:57 | | 3 | Desktop | Complete | 2019-12-23 13:15:12 | 2019-12-23 18:11:29 | | 4 | Desktop | In Progress | 2019-12-23 13:15:12 | 2019-12-23 18:11:29 | | 5 | Maintenance | In Progress | 2019-12-23 13:15:12 | 2019-12-23 18:11:29 | | 6 | Server | Complete | 2019-12-23 13:15:12 | 2019-12-23 18:11:29 | | 7 | Laptop | Complete | 2019-12-23 13:15:12 | 2019-12-23 18:11:29 |
Any idea how to group the category where its status are complete and count the between created_at and updated_at if its below 2 day and more than 2 days.
the result suppose be right here
| Category | Less than 2 days | More than 2 days | Average Time | |----------|:----------------:|-----------------:|---------------------| | Server | 2 | 6 | 6 Hours 10 Minute | | Laptop | 1 | 4 | 12 Hours 3 Minutes | | Desktop | 4 | 10 | 4 Hours 32 Minutes | | TOTAL | 7 | 20 | 22 Hours 45 Minutes |
Please or to participate in this conversation.