hide(), Text::make(__('ID'), 'unique_id')->sortable(), Select::make(__('Ýüztutmanyň görnüşi'), 'type') ->fullWidth() ->searchable() ->rules('required') ->displayUsingLabels() ->options(VisaMasterPaymentOrder::applicationTypes()), DateTime::make(__('Created at'), 'created_at') ->turkmenDateTime(), Select::make(__('Region'), 'region') ->displayUsingLabels() ->options(RegionRepo::values()) ->canSeeWhen('isAdmin', $resource) ->sortable(), BelongsTo::make(__('Branch'), 'branch', Branch::class) ->canSeeWhen('isAdmin', $resource) ->filterable() ->sortable(), Text::make(__('Name'), 'passport_name'), Text::make(__('Surname'), 'passport_surname'), Text::make(__('Phone'), 'phone'), Badge::make(__('Status'), 'status') ->map(OrderRepo::statusClasses()) ->addTypes([ 'primary' => 'dark:bg-gray-900 bg-gray-600 text-white', ]) ->labels(OrderRepo::statusValues()) ->withIcons() ->icons(OrderRepo::statusIcons()) ->sortable(), Text::make(sprintf('%s (%s)', __('Paid'), __('This month')), function () use ($resource, $date) { return static::paidField($resource, $resource->filter_month); }), ]; } /** * 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'; } }