diff --git a/app/Modules/VisaMasterPaymentOrder/Nova/Resources/Concerns/VisaMasterPaymentOrderFieldsForIndex.php b/app/Modules/VisaMasterPaymentOrder/Nova/Resources/Concerns/VisaMasterPaymentOrderFieldsForIndex.php index 5424c47..a322cea 100644 --- a/app/Modules/VisaMasterPaymentOrder/Nova/Resources/Concerns/VisaMasterPaymentOrderFieldsForIndex.php +++ b/app/Modules/VisaMasterPaymentOrder/Nova/Resources/Concerns/VisaMasterPaymentOrderFieldsForIndex.php @@ -3,10 +3,12 @@ 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; @@ -63,17 +65,28 @@ class VisaMasterPaymentOrderFieldsForIndex ->icons(OrderRepo::statusIcons()) ->sortable(), - Text::make(__('Paid'), static::paidField()), + Text::make(sprintf('%s (%s)', __('Paid'), __('This month')), function () use ($resource) { + return static::paidField($resource); + }), ]; } /** * Paid field */ - public static function paidField(): Closure + public static function paidField($resource) { - return function () { - return 'OK'; - }; + $paid = false; + $items = $resource->paymentItems; + + foreach ($items as $item) { + if (boolval($item->paid)) { + if ($item->created_at->format('m') == date('m')) { + $paid = true; + } + } + } + + return $paid ? 'Tölenen' : 'Tölenmedik'; } } diff --git a/app/Modules/VisaMasterPaymentOrder/Nova/Resources/NovaVisaMasterPaymentOrder.php b/app/Modules/VisaMasterPaymentOrder/Nova/Resources/NovaVisaMasterPaymentOrder.php index 1d4b5f1..ade706b 100644 --- a/app/Modules/VisaMasterPaymentOrder/Nova/Resources/NovaVisaMasterPaymentOrder.php +++ b/app/Modules/VisaMasterPaymentOrder/Nova/Resources/NovaVisaMasterPaymentOrder.php @@ -3,8 +3,8 @@ namespace App\Modules\VisaMasterPaymentOrder\Nova\Resources; use App\Models\Branch\Branch; -use App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrder; use App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrder as VisaMasterPaymentOrderModel; +use App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrder; use App\Modules\VisaMasterPaymentOrder\Nova\Resources\Concerns\VisaMasterAuth; use App\Modules\VisaMasterPaymentOrder\Nova\Resources\Concerns\VisaMasterPaymentOrderFieldsForDetail; use App\Modules\VisaMasterPaymentOrder\Nova\Resources\Concerns\VisaMasterPaymentOrderFieldsForIndex; @@ -18,6 +18,7 @@ use App\Repos\System\Settings\Location\RegionRepo; use Ebess\AdvancedNovaMediaLibrary\Fields\Files; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; +use Illuminate\Support\Facades\DB; use Illuminate\Support\Str; use Laravel\Nova\Fields\Badge; use Laravel\Nova\Fields\HasMany; @@ -63,9 +64,9 @@ class NovaVisaMasterPaymentOrder extends Resource /** * The relationships that should be eager loaded on index queries. * - * @var array + * @var array */ - public static $with = ['branch']; + public static $with = ['branch', 'paymentItems']; /** * Indicates whether the resource should automatically poll for new resources. diff --git a/lang/tk.json b/lang/tk.json index 5ca1ea5..9ba033d 100644 --- a/lang/tk.json +++ b/lang/tk.json @@ -331,5 +331,7 @@ "Make payment": "Töleg", "Visa/Master, Sber Settings": "Visa/Master, Sber sazlamalar", "Loan order required docs": "Karz gerekli resminamalary", - "Required docs": "Gerekli resminamalar" + "Required docs": "Gerekli resminamalar", + "Payment items": "Тöleg taryhy", + "This month": "Şul aý" }