|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Adminetic\Website\Http\Livewire\Admin\Payment; |
|
4
|
|
|
|
|
5
|
|
|
use Adminetic\Website\Exports\Payment\DateWisePaymentExport; |
|
|
|
|
|
|
6
|
|
|
use Adminetic\Website\Exports\Payment\PaymentGeneralExport; |
|
|
|
|
|
|
7
|
|
|
use Adminetic\Website\Exports\Payment\TypeWisePaymentExport; |
|
|
|
|
|
|
8
|
|
|
use Adminetic\Website\Models\Admin\Event; |
|
|
|
|
|
|
9
|
|
|
use Adminetic\Website\Models\Admin\Payment; |
|
10
|
|
|
use Carbon\Carbon; |
|
11
|
|
|
use Illuminate\Support\Facades\Cache; |
|
12
|
|
|
use Livewire\Component; |
|
13
|
|
|
use Livewire\WithPagination; |
|
14
|
|
|
use Maatwebsite\Excel\Facades\Excel; |
|
|
|
|
|
|
15
|
|
|
|
|
16
|
|
|
class PaymentMaster extends Component |
|
17
|
|
|
{ |
|
18
|
|
|
use WithPagination; |
|
|
|
|
|
|
19
|
|
|
|
|
20
|
|
|
public $payments; |
|
21
|
|
|
|
|
22
|
|
|
/* |
|
23
|
|
|
|-------------------------------------------------------------------------- |
|
24
|
|
|
| Payment Date Mode |
|
25
|
|
|
|-------------------------------------------------------------------------- |
|
26
|
|
|
| |
|
27
|
|
|
| 1 = Date Mode |
|
28
|
|
|
| 2 = Date Range Mode |
|
29
|
|
|
| |
|
30
|
|
|
*/ |
|
31
|
|
|
public $date_mode = 1; |
|
32
|
|
|
|
|
33
|
|
|
public $date; |
|
34
|
|
|
public $start_date; |
|
35
|
|
|
public $end_date; |
|
36
|
|
|
|
|
37
|
|
|
/* |
|
38
|
|
|
|-------------------------------------------------------------------------- |
|
39
|
|
|
| Payment Type |
|
40
|
|
|
|-------------------------------------------------------------------------- |
|
41
|
|
|
| |
|
42
|
|
|
| 1 => Income |
|
43
|
|
|
| 2 => Expense |
|
44
|
|
|
| |
|
45
|
|
|
*/ |
|
46
|
|
|
public $payment_type; |
|
47
|
|
|
|
|
48
|
|
|
/* |
|
49
|
|
|
|-------------------------------------------------------------------------- |
|
50
|
|
|
| Event ID Filter |
|
51
|
|
|
|-------------------------------------------------------------------------- |
|
52
|
|
|
*/ |
|
53
|
|
|
public $events; |
|
54
|
|
|
public $event_id; |
|
55
|
|
|
|
|
56
|
|
|
/* |
|
57
|
|
|
|-------------------------------------------------------------------------- |
|
58
|
|
|
| Order By |
|
59
|
|
|
|-------------------------------------------------------------------------- |
|
60
|
|
|
| |
|
61
|
|
|
| 1 = Latest |
|
62
|
|
|
| 2 = Oldest |
|
63
|
|
|
| |
|
64
|
|
|
*/ |
|
65
|
|
|
public $order_by; |
|
66
|
|
|
|
|
67
|
|
|
protected $listeners = ['initialize_payment_master' => 'initializePaymentMaster', 'filter_date' => 'filterDate', 'date_range_filter' => 'dateRangeFilter']; |
|
68
|
|
|
|
|
69
|
|
|
public function initializePaymentMaster() |
|
70
|
|
|
{ |
|
71
|
|
|
$this->emit('initializePaymentMaster'); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
public function updatedDateMode() |
|
75
|
|
|
{ |
|
76
|
|
|
$this->emit('initializePaymentMaster'); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
public function dateRangeFilter($start_date, $end_date) |
|
80
|
|
|
{ |
|
81
|
|
|
$this->date_mode = 2; |
|
82
|
|
|
$this->start_date = Carbon::create($start_date); |
|
83
|
|
|
$this->end_date = Carbon::create($end_date); |
|
84
|
|
|
$this->getPayments(); |
|
85
|
|
|
$this->emit('initializePaymentMaster'); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
public function filterDate($date) |
|
89
|
|
|
{ |
|
90
|
|
|
$this->date_mode = 1; |
|
91
|
|
|
$this->date = Carbon::create($date); |
|
92
|
|
|
$this->getPayments(); |
|
93
|
|
|
$this->emit('initializePaymentMaster'); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
public function updatedEventId() |
|
97
|
|
|
{ |
|
98
|
|
|
$this->getPayments(); |
|
99
|
|
|
$this->emit('initializePaymentMaster'); |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
public function mount() |
|
103
|
|
|
{ |
|
104
|
|
|
$this->getPayments(); |
|
105
|
|
|
$this->events = Cache::get('events', Event::orderBy('position')->get()); |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
public function render() |
|
109
|
|
|
{ |
|
110
|
|
|
return view('website::livewire.admin.payment.payment-master'); |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
public function resetFilter() |
|
114
|
|
|
{ |
|
115
|
|
|
$this->order_by = null; |
|
116
|
|
|
$this->payment_type = null; |
|
117
|
|
|
$this->date_mode = null; |
|
118
|
|
|
$this->date = null; |
|
119
|
|
|
$this->start_date = null; |
|
120
|
|
|
$this->end_date = null; |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
public function getPayments() |
|
124
|
|
|
{ |
|
125
|
|
|
$data = Payment::query(); |
|
126
|
|
|
|
|
127
|
|
|
$data = $this->filterByEventId($data); |
|
128
|
|
|
|
|
129
|
|
|
$data = $this->filterByPaymentType($data); |
|
130
|
|
|
|
|
131
|
|
|
$data = $this->filterByDateMode($data); |
|
132
|
|
|
|
|
133
|
|
|
$data = $this->orderPayments($data); |
|
134
|
|
|
|
|
135
|
|
|
$this->payments = $data->get(); |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
private function filterByEventId($data) |
|
139
|
|
|
{ |
|
140
|
|
|
if (! is_null($this->event_id)) { |
|
141
|
|
|
$event = Event::find($this->event_id); |
|
142
|
|
|
|
|
143
|
|
|
return $data->whereIn('id', $event->payments->pluck('id')); |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
return $data; |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
private function filterByPaymentType($data) |
|
150
|
|
|
{ |
|
151
|
|
|
$payment_type = $this->payment_type; |
|
152
|
|
|
if (! is_null($payment_type)) { |
|
153
|
|
|
return $data->where('type', $payment_type); |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
return $data; |
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
|
|
private function filterByDateMode($data) |
|
160
|
|
|
{ |
|
161
|
|
|
$date_mode = $this->date_mode; |
|
162
|
|
|
if (! is_null($date_mode)) { |
|
|
|
|
|
|
163
|
|
|
if ($date_mode == 1) { |
|
164
|
|
|
$date = $this->date ?? Carbon::now(); |
|
165
|
|
|
|
|
166
|
|
|
return $data->whereDate('created_at', $date); |
|
167
|
|
|
} |
|
168
|
|
|
if ($date_mode == 2) { |
|
169
|
|
|
$start_date = $this->start_date; |
|
170
|
|
|
$end_date = $this->end_date; |
|
171
|
|
|
if (! is_null($start_date) && ! is_null($end_date)) { |
|
172
|
|
|
return $data->whereBetween('created_at', [$start_date, $end_date]); |
|
173
|
|
|
} |
|
174
|
|
|
} |
|
175
|
|
|
|
|
176
|
|
|
return $data; |
|
177
|
|
|
} |
|
178
|
|
|
|
|
179
|
|
|
return $data; |
|
180
|
|
|
} |
|
181
|
|
|
|
|
182
|
|
|
private function orderPayments($data) |
|
183
|
|
|
{ |
|
184
|
|
|
$order_by = $this->order_by; |
|
185
|
|
|
|
|
186
|
|
|
if (! is_null($order_by)) { |
|
187
|
|
|
if ($order_by == 1) { |
|
188
|
|
|
return $data->latest(); |
|
189
|
|
|
} elseif ($order_by == 2) { |
|
190
|
|
|
return $data->oldest(); |
|
191
|
|
|
} |
|
192
|
|
|
} |
|
193
|
|
|
|
|
194
|
|
|
return $data; |
|
195
|
|
|
} |
|
196
|
|
|
|
|
197
|
|
|
/* Export */ |
|
198
|
|
|
public function export($type) |
|
199
|
|
|
{ |
|
200
|
|
|
$payments = Payment::get(); |
|
201
|
|
|
// General Export |
|
202
|
|
|
if ($type == 1) { |
|
203
|
|
|
return Excel::download(new PaymentGeneralExport($payments), 'payment_general_export.xlsx'); |
|
204
|
|
|
} |
|
205
|
|
|
// Date Wise Payment Export |
|
206
|
|
|
elseif ($type == 2) { |
|
207
|
|
|
return Excel::download(new DateWisePaymentExport($payments), 'payment_datewise_export.xlsx'); |
|
208
|
|
|
} |
|
209
|
|
|
// Payment Type Export |
|
210
|
|
|
elseif ($type == 3) { |
|
211
|
|
|
return Excel::download(new TypeWisePaymentExport($payments), 'type_wise_payment_export.xlsx'); |
|
212
|
|
|
} |
|
213
|
|
|
} |
|
214
|
|
|
} |
|
215
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths