Completed
Push — main ( cb99e0...e0ab63 )
by Emmanuel
01:10
created

Stats   A

Complexity

Total Complexity 19

Size/Duplication

Total Lines 171
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 19
lcom 0
cbo 0
dl 0
loc 171
rs 10
c 0
b 0
f 0

19 Methods

Rating   Name   Duplication   Size   Complexity  
A total_orders() 0 5 1
A total_cancelled_orders() 0 4 1
A total_pending_orders() 0 4 1
A sum_of_pending_amount() 0 5 1
A total_completed_orders() 0 4 1
A completed_orders() 0 4 1
A total_orders_today() 0 4 1
A total_orders_on_date() 0 4 1
A total_orders_this_month() 0 4 1
A total_orders_on_month() 0 4 1
A total_orders_on_year() 0 4 1
A total_invoices() 0 4 1
A total_invoices_today() 0 4 1
A total_pending_invoices() 0 4 1
A sum_of_pending_invoice_amount() 0 5 1
A total_invoice_count_by_status() 0 4 1
A sum_of_given_invoice_status_amount() 0 5 1
A total_completed_invoices() 0 4 1
A sum_of_completed_invoice_amount() 0 5 1
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
use Epmnzava\BillMe\Models\Order;
14
use Epmnzava\BillMe\Models\Invoice;
15
use Epmnzava\BillMe\Models\OrderItem;
16
use Epmnzava\BillMe\Mail\Client\Invoices\InvoiceCreated;
17
use Epmnzava\BillMe\Mail\Client\OrderReceived;
18
use Epmnzava\BillMe\Mail\Merchant\NewOrder;
19
use Carbon\Carbon;
20
21
use Mail;
22
23
class Stats
24
{
25
26
    /**
27
     * Gets total count of orders 
28
     */
29
    public function total_orders()
30
    {
31
32
        return Order::count();
33
    }
34
35
    /**
36
     * Gets total count of cancelled orders 
37
     */
38
    public function total_cancelled_orders()
39
    {
40
        return Order::where('status', 'cancelled')->count();
41
    }
42
43
    /**
44
     * Gets total count of pending orders 
45
     */
46
    public function total_pending_orders()
47
    {
48
        return Order::where('status', 'pending')->count();
49
    }
50
51
    /**
52
     * Gets total sum of pending orders 
53
     */
54
    public function sum_of_pending_amount()
55
    {
56
57
        return Invoice::where('status', 'pending')->sum('amount');
58
    }
59
60
    public function total_completed_orders()
61
    {
62
        return Order::where('status', 'completed')->count();
63
    }
64
65
  public function completed_orders()
66
    {
67
        return Order::where('status', 'completed')->get();
68
    }
69
70
    /**
71
     * Gets total count of orders today
72
     */
73
74
    public function total_orders_today()
75
    {
76
        return Order::where('date', date('Y-m-d'))->count();
77
    }
78
79
80
    /**
81
     * Gets total count of orders on a particular day
82
     */
83
    public function total_orders_on_date($date)
84
    {
85
        return Order::where('date', $date)->count();
86
    }
87
88
    /**
89
     * Gets total count of orders on this month
90
     */
91
92
    public function total_orders_this_month()
93
    {
94
        return Order::whereMonth('date', '=', date('m'))->whereYear('date', '=', date('Y'))->count();
95
    }
96
97
98
    /**
99
     * Gets total count of orders on a particular month and year
100
     */
101
    public function total_orders_on_month($month, $year)
102
    {
103
        return Order::whereMonth('date', '=', $month)->whereYear('date', '=', $year)->count();
104
    }
105
106
107
    /**
108
     * Gets total count of orders on given year
109
     */
110
    public function total_orders_on_year($year)
111
    {
112
        return Order::whereYear('date', '=', $year)->count();
113
    }
114
115
116
    /**
117
     * Gets total count of invoices
118
     */
119
    public function total_invoices()
120
    {
121
        return Invoice::count();
122
    }
123
124
125
    /**
126
     * Gets total count of invoices today
127
     */
128
129
    public function total_invoices_today()
130
    {
131
        return Invoice::where('date', date('Y-m-d'))->count();
132
    }
133
134
135
    /**
136
     * Gets total count of pending orders 
137
     */
138
    public function total_pending_invoices()
139
    {
140
        return Invoice::where('status', 'pending')->count();
141
    }
142
143
    /**
144
     * Gets total sum of pending orders 
145
     */
146
    public function sum_of_pending_invoice_amount()
147
    {
148
149
        return Invoice::where('status', 'pending')->sum('amount');
150
    }
151
152
153
154
155
    /**
156
     * Gets total count of pending invoices by status 
157
     */
158
    public function total_invoice_count_by_status($status)
159
    {
160
        return Invoice::where('status', $status)->count();
161
    }
162
163
164
165
166
    /**
167
     * Gets total sum of pending invoices by status 
168
     */
169
    public function sum_of_given_invoice_status_amount($status)
170
    {
171
172
        return Invoice::where('status', $status)->sum('amount');
173
    }
174
175
176
177
    /**
178
     * Gets total count of completed invoices 
179
     */
180
    public function total_completed_invoices()
181
    {
182
        return Invoice::where('status', 'paid')->count();
183
    }
184
185
    /**
186
     * Gets total sum of completed invoices 
187
     */
188
    public function sum_of_completed_invoice_amount()
189
    {
190
191
        return Invoice::where('status', 'paid')->sum('amount');
192
    }
193
}
194