Completed
Push — main ( c8b5aa...da21bc )
by Emmanuel
01:04
created

Queries::getUserInvoiceByStatus()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
/**
4
 * Author: Emmanuel Paul Mnzava
5
 * Twitter: @epmnzava
6
 * Github: https://github.com/dbrax/bill-me
7
 * Email: [email protected]
8
 * 
9
 */
10
11
namespace Epmnzava\BillMe;
12
13
14
use Epmnzava\BillMe\Models\BillingPayment;
15
use Epmnzava\BillMe\Models\Order;
16
use Epmnzava\BillMe\Models\Invoice;
17
use Epmnzava\BillMe\Models\OrderItem;
18
use Epmnzava\BillMe\Mail\Client\Invoices\InvoiceCreated;
19
use Epmnzava\BillMe\Mail\Client\OrderReceived;
20
use Epmnzava\BillMe\Mail\Merchant\NewOrder;
21
22
use Mail;
23
24
class Queries extends Stats
25
{
26
27
    public function orders()
28
    {
29
30
        return Order::all();
31
    }
32
33
34
    public function orders_orderby($orderby)
0 ignored issues
show
Unused Code introduced by
The parameter $orderby is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
35
    {
36
    }
37
38
39
40
    public function orders_today()
41
    {
42
        return Order::where('date', date('Y-m-d'))->get();
43
    }
44
45
    public function pending_orders()
46
    {
47
        return Order::where('status', "pending")->get();
48
    }
49
50
    public function cancelled_orders()
51
    {
52
        return Order::where('status', "cancelled")->get();
53
    }
54
55
    public function completed_orders()
56
    {
57
        return Order::where('status', "complete")->get();
58
    }
59
60
    public function getOrderById($orderid)
61
    {
62
        return Order::find($orderid);
63
    }
64
65
    public function getOrdersOnDate($date)
66
    {
67
        return Order::where('date', $date)->get();
68
    }
69
70
71
    public function getOrdersOnDateRange($startdate, $enddate)
0 ignored issues
show
Unused Code introduced by
The parameter $startdate is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $enddate is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
72
    {
73
    }
74
75
76
    /** Function to get an invoice */
77
    public function getInvoiceById($invoiceid)
78
    {
79
        return Invoice::find($invoiceid);
80
    }
81
82
83
    /**
84
     * 
85
     * User Queries
86
     */
87
88
89
    /** Function to get given user orders */
90
    public function getUserOrders($userid)
91
    {
92
        return Order::where('userid', $userid)->get();
93
    }
94
95
96
    /** Function to get given user orders by status */
97
    public function getUserOrdersByStatus($userid, $status)
98
    {
99
        return Order::where('userid', $userid)->where('status', $status)->get();
100
    }
101
102
103
    /** Function to get given user invoices */
104
    public function getUserInvoices($userid)
105
    {
106
        return Invoice::where('userid', $userid)->get();
107
    }
108
109
110
111
    /** Function to get given user invoices by status */
112
    public function getUserInvoiceByStatus($userid, $status)
113
    {
114
        return Invoice::where('userid', $userid)->where('status', $status)->get();
115
    }
116
117
118
119
120
121
    public function getAllBillingHistory()
122
    {
123
124
        return BillingPayment::all();
125
    }
126
127
128
    public function getUserBillingHistory($userid)
129
    {
130
131
        return BillingPayment::where('userid', $userid)->get();
132
    }
133
134
135
136
    public function getUserBillingHistoryByStatus($userid, $status)
137
    {
138
139
        return BillingPayment::where('userid', $userid)->where('status', $status)->get();
140
    }
141
}
142