I want to sort a table entries. Here is the Eloquent Model.
namespace App;
use Illuminate\Database\Eloquent\Model;
/**
* App\Story
...
* @property string $due_date
* @property string $status late|scheduled|completed
...
*/
class Story extends Model {
...
}
The order in which i want to return the Stories are:
- "late" is ASC (Older first)
- "scheduled" in DSC ( New first)
- "completed" in DSC ( New first)
So Let's assume there are 15 entries in db for each status type of story. and the Pagination limit is set to be 20.
so here is the response of each page
- First Page: 15 Late Stories in ASC order + first 5 Scheduled Stories in DSC order
- Second Page: Remaining 10 Scheduled Stories + first 10 Completed Stories in DSC order
- Third Page: remaining 5 Completed Stories
Please do let me know if the information provided above is not sufficient. Thanks!