php - Sorting on multiple values MYSQL Laravel -
I am currently working on a project where I need to sort a collection using MySQL, but I Actually can not find it working. I have a table with ingredients component related to a training. Therefore there may be several components in one training.
I created an HTML table with the results along with the following columns:
- Date
- Time
- Component
- Component
What sort of components do I need to sort: Sort the dates, all the dates ASC - time, the component must be the first time at that time Must have - components, based on time, the ingredients must be grouped by the same training.
For example, a list with these components:
Date: 4-11-2014
Time: 11:00
Training_ID: 1
Components : First Component
Date: 4-11-2014
Time: 11:30
Training_ID: 2
Component: First component of Training_ID2
Date: 4-11-2014
Time: 12:00
Training_ID: 1 Component: Second Component:
In order to be kept: first component, second component, training First component of 2 This is because the first component based on time is 'first element'. The next step is that all components of this training will be resolved under 'first component' (and also at the time). After that comes the next training.
Does anyone have a clue, I really can not understand this one ..
This is in the order of the works done by me:
$ Result = Component :: ofType ('Training') - & gt; Select ('component. *') -> Join ('training', 'trainings.id', '=', 'Components.parent_id') - & gt; GroupB ('components.id') - & gt; Orderbuy ('component_start_date') - & gt; Orderbuy ('parent_id') - & gt; Orderbike ('to') - & gt; ;
This can work for you by $ data-> order ("date "," Esque ") -> orderbird (" time "," esk ")
Comments
Post a Comment