1<?php
2
3// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0.
4// See the LICENCE file in the repository root for full licence text.
5
6namespace App\Http\Controllers\Store;
7
8use Auth;
9
10class OrdersController extends Controller
11{
12 protected $layout = 'master';
13
14 public function __construct()
15 {
16 parent::__construct();
17
18 $this->middleware('auth');
19 $this->middleware('verify-user');
20 }
21
22 public function destroy($id)
23 {
24 $order = auth()->user()->orders()->findOrFail($id);
25 $order->cancel(auth()->user());
26
27 return response(null, 204);
28 }
29
30 public function index()
31 {
32 $orders = Auth::user()
33 ->orders()
34 ->orderBy('order_id', 'desc')
35 ->with('items.product');
36
37 if (request('type') === 'processing') {
38 $orders->where('status', 'processing');
39 } else {
40 $orders->where('status', '<>', 'incart');
41 }
42
43 $orders = $orders->paginate();
44
45 return ext_view('store.orders.index', compact('orders'));
46 }
47}