Completed
Push — main ( a8a380...c25e3c )
by Emmanuel
01:31
created

Stats::total_pending_orders()   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 0
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
     return Invoice::where('status', 'pending')->sum('amount');   
57
    }
58
59
    public function total_completed_orders()
60
    {
61
        return Order::where('status', 'completed')->count();
62
    }
63
64
    /**
65
     * Gets total count of orders today
66
     */
67
68
    public function total_orders_today()
69
    {
70
        return Order::where('date', date('Y-m-d'))->count();
71
    }
72
73
74
    /**
75
     * Gets total count of orders on a particular day
76
     */
77
    public function total_orders_on_date($date)
78
    {
79
        return Order::where('date', $date)->count();
80
    }
81
82
    /**
83
     * Gets total count of orders on this month
84
     */
85
86
    public function total_orders_this_month()
87
    {
88
        return Order::whereMonth('date', '=', date('m'))->whereYear('date', '=', date('Y'))->count();
89
    }
90
91
92
    /**
93
     * Gets total count of orders on a particular month and year
94
     */
95
    public function total_orders_on_month($month, $year)
96
    {
97
        return Order::whereMonth('date', '=', $month)->whereYear('date', '=', $year)->count();
98
    }
99
100
101
    /**
102
     * Gets total count of orders on given year
103
     */
104
    public function total_orders_on_year($year)
105
    {
106
        return Order::whereYear('date', '=', $year)->count();
107
    }
108
109
110
    /**
111
     * Gets total count of invoices
112
     */
113
    public function total_invoices()
114
    {
115
        return Invoice::count();
116
    }
117
118
119
    /**
120
     * Gets total count of invoices today
121
     */
122
123
    public function total_invoices_today()
124
    {
125
        return Invoice::where('date', date('Y-m-d'))->count();
126
    }
127
128
129
      /**
130
     * Gets total count of pending orders 
131
     */
132
    public function total_pending_invoices()
133
    {
134
        return Invoice::where('status', 'pending')->count();
135
    }
136
137
/**
138
     * Gets total sum of pending orders 
139
     */
140
    public function sum_of_pending_invoice_amount(){
141
142
     return Invoice::where('status', 'pending')->sum('amount');   
143
    }
144
145
146
}
147