This commit is contained in:
2025-02-20 15:03:24 +05:00
parent 2910f7f314
commit 1c9889e0b4
9 changed files with 957 additions and 669 deletions

View File

@@ -3,12 +3,9 @@
namespace App\Modules\VisaMasterPaymentOrder\Nova\Resources\Concerns;
use App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrder;
use App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrderItem;
use App\Nova\Resources\Branch\Branch;
use App\Repos\Order\OrderRepo;
use App\Repos\System\Settings\Location\RegionRepo;
use Closure;
use Laravel\Nova\Fields\Boolean;
use Laravel\Nova\Fields\Badge;
use Laravel\Nova\Fields\BelongsTo;
use Laravel\Nova\Fields\DateTime;
@@ -21,7 +18,7 @@ class VisaMasterPaymentOrderFieldsForIndex
/**
* Loan Order fields for "create"
*/
public static function make($resource): array
public static function make($resource, $date = null): array
{
return [
ID::make()->hide(),
@@ -65,8 +62,8 @@ class VisaMasterPaymentOrderFieldsForIndex
->icons(OrderRepo::statusIcons())
->sortable(),
Text::make(sprintf('%s (%s)', __('Paid'), __('This month')), function () use ($resource) {
return static::paidField($resource);
Text::make(sprintf('%s (%s)', __('Paid'), __('This month')), function () use ($resource, $date) {
return static::paidField($resource, $resource->filter_month);
}),
];
}
@@ -74,14 +71,16 @@ class VisaMasterPaymentOrderFieldsForIndex
/**
* Paid field
*/
public static function paidField($resource)
public static function paidField($resource, $date = null)
{
$paid = false;
$items = $resource->paymentItems;
$month = $date ?: date('m');
foreach ($items as $item) {
if (boolval($item->paid)) {
if ($item->created_at->format('m') == date('m')) {
if ($item->created_at->format('m') == $month) {
$paid = true;
}
}