Completed
Push — main ( f800c9...5397e3 )
by Emmanuel
06:12
created

Stats   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 97
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 11
lcom 0
cbo 0
dl 0
loc 97
rs 10
c 0
b 0
f 0

11 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 total_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
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
    public function total_completed_orders()
52
    {
53
        return Order::where('status', 'completed')->count();
54
    }
55
56
    /**
57
     * Gets total count of orders today
58
     */
59
60
    public function total_orders_today()
61
    {
62
        return Order::where('date', date('Y-m-d'))->count();
63
    }
64
65
66
    /**
67
     * Gets total count of orders on a particular day
68
     */
69
    public function total_orders_on_date($date)
70
    {
71
        return Order::where('date', $date)->count();
72
    }
73
74
    /**
75
     * Gets total count of orders on this month
76
     */
77
78
    public function total_orders_this_month()
79
    {
80
        return Order::whereMonth('date', '=', date('m'))->whereYear('date', '=', date('Y'))->count();
81
    }
82
83
84
    /**
85
     * Gets total count of orders on a particular month and year
86
     */
87
    public function total_orders_on_month($month, $year)
88
    {
89
        return Order::whereMonth('date', '=', $month)->whereYear('date', '=', $year)->count();
90
    }
91
92
93
    /**
94
     * Gets total count of orders on given year
95
     */
96
    public function total_orders_on_year($year)
97
    {
98
        return Order::whereYear('date', '=', $year)->count();
99
    }
100
101
102
    /**
103
     * Gets total count of invoices
104
     */
105
    public function total_invoices()
106
    {
107
        return Invoice::count();
108
    }
109
110
111
    /**
112
     * Gets total count of invoices today
113
     */
114
115
    public function total_invoices_today()
116
    {
117
        return Invoice::where('date', date('Y-m-d'))->count();
118
    }
119
}
120