I have the following table and and the following code to retrieve a store orders;
My intention was to fetch orders and order them according to the created at and also order the delivery_from time field in an ascending order while pertaining the created_at orderby.
An example a valid query would fetch the following;
delivery_from: 10:00, created_at: 10/10/2018
delivery_from: 12:00, created_at: 10/10/2018
delivery_from: 09:00, created_at: 15/10/2018
delivery_from: 15:00, created_at: 15/10/2018
My current code below fetches it like so;
delivery_from: 09:00, created_at: 15/10/2018
delivery_from: 10:00, created_at: 10/10/2018
delivery_from: 12:00, created_at: 10/10/2018
delivery_from: 15:00, created_at: 15/10/2018
$store = auth('manager')->user->store;
$orders = $store->orders()->orderBy('created_at', 'desc')->orderBy('delivery_from', 'asc')->get();
Schema::create('orders', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('user_id');
$table->unsignedInteger('store_id');
$table->unsignedInteger('delivery_method');
$table->float('final_price', 8, 2);
$table->float('delivery_price', 8, 2);
$table->unsignedInteger('payment_type');
$table->unsignedInteger('status');
$table->boolean('paid')->default(false);
$table->time('delivery_from');
$table->time('delivery_to');
$table->timestamps();
});