wip
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Modules\VisaMasterPaymentOrder\Nova\Resources\Concerns;
|
||||
use App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrder;
|
||||
use App\Modules\VisaMasterPaymentOrder\Nova\Resources\NovaVisaMasterPaymentOrderItem;
|
||||
use App\Nova\Resources\Branch\Branch;
|
||||
use App\Nova\User;
|
||||
use App\Repos\Order\OrderRepo;
|
||||
use App\Repos\System\Settings\Legal\PassportRepo;
|
||||
use App\Repos\System\Settings\Location\RegionRepo;
|
||||
@@ -34,9 +35,7 @@ class VisaMasterPaymentOrderFieldsForDetail
|
||||
ID::make()
|
||||
->hideFromDetail(),
|
||||
|
||||
Hidden::make('user_id')
|
||||
->default(auth()->id())
|
||||
->hideWhenUpdating(),
|
||||
BelongsTo::make(__('User'), 'user', User::class),
|
||||
|
||||
Text::make(__('ID'), 'unique_id')
|
||||
->exceptOnForms(),
|
||||
@@ -60,12 +59,13 @@ class VisaMasterPaymentOrderFieldsForDetail
|
||||
->withIcons()
|
||||
->icons(OrderRepo::statusIcons()),
|
||||
|
||||
Text::make(sprintf('%s (%s)', __('Paid'), __('This month')), function () use ($resource) {
|
||||
return static::paidField($resource, $resource->filter_month);
|
||||
}),
|
||||
|
||||
Text::make(__('Note'), 'notes')
|
||||
->fullWidth()
|
||||
->canSeeWhen('systemUser', $resource),
|
||||
]),
|
||||
new Panel(__('Payment'), [
|
||||
|
||||
]),
|
||||
new Panel(__('Application type'), [
|
||||
Select::make(__('Application type'), 'type')
|
||||
@@ -195,4 +195,25 @@ class VisaMasterPaymentOrderFieldsForDetail
|
||||
HasMany::make(__('Payment items'), 'paymentItems', NovaVisaMasterPaymentOrderItem::class),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Paid field
|
||||
*/
|
||||
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') == $month) {
|
||||
$paid = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $paid ? 'Tölenen' : 'Tölenmedik';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user