pratiksh404 /
adminetic-website
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace Adminetic\Website\Services; |
||||
| 4 | |||||
| 5 | use Adminetic\Website\Models\Admin\Pass; |
||||
|
0 ignored issues
–
show
|
|||||
| 6 | use Adminetic\Website\Models\Admin\Payment; |
||||
| 7 | use Carbon\Carbon; |
||||
| 8 | use Carbon\CarbonPeriod; |
||||
| 9 | |||||
| 10 | class Statistic |
||||
| 11 | { |
||||
| 12 | /* |
||||
| 13 | |-------------------------------------------------------------------------- |
||||
| 14 | | Reports |
||||
| 15 | |-------------------------------------------------------------------------- |
||||
| 16 | */ |
||||
| 17 | public function dayBook(Carbon $start_date, Carbon $end_date, $event = null) |
||||
| 18 | { |
||||
| 19 | $data = null; |
||||
| 20 | $period = CarbonPeriod::create($start_date, $end_date); |
||||
| 21 | foreach ($period as $date) { |
||||
| 22 | if (! is_null($event)) { |
||||
| 23 | $payments = $event->payments->filter(function ($payment) use ($date) { |
||||
| 24 | return $payment->created_at->format('Y-m-d') == $date->format('Y-m-d'); |
||||
|
0 ignored issues
–
show
The method
format() does not exist on null.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||||
| 25 | }); |
||||
| 26 | $passes = $event->passes->filter(function ($pass) use ($date) { |
||||
| 27 | return $pass->created_at->format('Y-m-d') == $date->format('Y-m-d'); |
||||
| 28 | }); |
||||
| 29 | } else { |
||||
| 30 | $payments = Payment::whereDate('created_at', $date)->get(); |
||||
| 31 | $passes = Pass::whereDate('created_at', $date); |
||||
| 32 | } |
||||
| 33 | $data[modeDate($date)] = [ |
||||
|
0 ignored issues
–
show
It seems like
$date can also be of type null; however, parameter $date of modeDate() does only seem to accept Carbon\Carbon, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 34 | 'total_payment' => $payments->sum('payment'), |
||||
| 35 | 'total_pass' => $passes->count(), |
||||
| 36 | 'total_transaction' => $payments->count(), |
||||
| 37 | ]; |
||||
| 38 | } |
||||
| 39 | |||||
| 40 | return ! is_null($data) ? array_reverse($data) : null; |
||||
|
0 ignored issues
–
show
|
|||||
| 41 | } |
||||
| 42 | |||||
| 43 | /* |
||||
| 44 | |-------------------------------------------------------------------------- |
||||
| 45 | | Pass Statistics |
||||
| 46 | |-------------------------------------------------------------------------- |
||||
| 47 | */ |
||||
| 48 | public function passRegisterPerDay($given_data = null, $limit = 30) |
||||
| 49 | { |
||||
| 50 | $data = $given_data ?? Pass::orderBy('position')->get(); |
||||
| 51 | if ($data->count() > 0) { |
||||
| 52 | $data = $data->sortByDesc('created_at'); |
||||
| 53 | $end_date = $data->first()->created_at; |
||||
| 54 | $start_date = $end_date->copy()->subDays($limit); |
||||
| 55 | $period = CarbonPeriod::create($start_date, $end_date); |
||||
| 56 | $total = []; |
||||
| 57 | foreach ($period as $date) { |
||||
| 58 | $total[modeDate($date)] = $data->filter(function ($p) use ($date) { |
||||
|
0 ignored issues
–
show
It seems like
$date can also be of type null; however, parameter $date of modeDate() does only seem to accept Carbon\Carbon, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 59 | return $p->created_at->format('Y-m-d') == $date->format('Y-m-d'); |
||||
| 60 | })->count(); |
||||
| 61 | } |
||||
| 62 | |||||
| 63 | return $total; |
||||
| 64 | } |
||||
| 65 | |||||
| 66 | return null; |
||||
| 67 | } |
||||
| 68 | |||||
| 69 | /* |
||||
| 70 | |-------------------------------------------------------------------------- |
||||
| 71 | | Payment Statistics |
||||
| 72 | |-------------------------------------------------------------------------- |
||||
| 73 | */ |
||||
| 74 | public function perDayPaymentTotal($given_data = null, $limit = 30) |
||||
| 75 | { |
||||
| 76 | $data = $given_data ?? Payment::orderBy('position')->get(); |
||||
| 77 | if ($data->count() > 0) { |
||||
| 78 | $data = $data->sortByDesc('created_at'); |
||||
| 79 | $end_date = $data->first()->created_at; |
||||
| 80 | $start_date = $end_date->copy()->subDays($limit); |
||||
| 81 | $period = CarbonPeriod::create($start_date, $end_date); |
||||
| 82 | $total = []; |
||||
| 83 | foreach ($period as $date) { |
||||
| 84 | $total[modeDate($date)] = $data->filter(function ($p) use ($date) { |
||||
|
0 ignored issues
–
show
It seems like
$date can also be of type null; however, parameter $date of modeDate() does only seem to accept Carbon\Carbon, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 85 | return $p->created_at->format('Y-m-d') == $date->format('Y-m-d'); |
||||
| 86 | })->sum('payment'); |
||||
| 87 | } |
||||
| 88 | |||||
| 89 | return $total; |
||||
| 90 | } |
||||
| 91 | |||||
| 92 | return null; |
||||
| 93 | } |
||||
| 94 | } |
||||
| 95 |
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