*/ public static $model = Payout::class; /** * The single value that should be used to represent the resource when being displayed. * * @var string */ public static $title = 'id'; /** * The columns that should be searched. * * @var array */ public static $search = [ 'id', ]; /** * The relationships that should be eager loaded on index queries. * * @var array */ public static $with = ['channel']; /** * Get the displayable label of the resource. */ public static function label(): string { return __('Payout'); } /** * Get the displayable singular label of the resource. */ public static function singularLabel(): string { return __('Payouts'); } /** * After resource has been created */ public static function afterCreate(NovaRequest $request, Model $model): void { PayoutsRepo::orderItemIdsFill($request, $model); } /** * Get the fields displayed by the resource. */ public function fields(NovaRequest $request): array { return [ ID::make()->sortable(), Select::make(__('Channel'), 'channel_id') ->fullWidth() ->displayUsingLabels() ->searchable() ->options(ChannelRepository::values()) ->rules('required') ->canSeeWhen('isAdmin', $this), Date::make(__('Start date'), 'start_date') ->rules('required') ->fullWidth() ->displayUsing(fn ($value) => $value->format('d.m.Y')) ->readonly(fn ($request) => $request->isUpdateOrUpdateAttachedRequest()) ->sortable(), Date::make(__('End date'), 'end_date') ->rules('required') ->fullWidth() ->displayUsing(fn ($value) => $value->format('d.m.Y')) ->readonly(fn ($request) => $request->isUpdateOrUpdateAttachedRequest()) ->sortable(), PayoutProducts::make(__('Products'), 'order_items_ids') ->dependsOn(['channel_id', 'start_date', 'end_date'], PayoutsRepo::orderItemIdsDependsOn()) ->fillUsing(function ($request, $model, $attribute, $requestAttribute) { $model->total_sum = $request->total_sum; $model->entrepreneur_total = $request->entrepreneur_total; $model->postshop_total = $request->postshop_total; }) ->products(PayoutsRepo::resolveOrderItems($request, $this)) ->fullWidth() ->hideFromIndex(), Text::make(__('Hasap'), 'total_sum') ->fullWidth() ->exceptOnForms() ->sortable(), Text::make(__('Entrepreneur Total'), 'entrepreneur_total') ->fullWidth() ->exceptOnForms() ->sortable(), Text::make(__('POSTSHOP Total'), 'postshop_total') ->fullWidth() ->exceptOnForms() ->sortable(), Textarea::make(__('Notes'), 'notes')->fullWidth(), ]; } /** * Get the cards available for the request. */ public function cards(NovaRequest $request): array { return []; } /** * Get the filters available for the resource. */ public function filters(NovaRequest $request): array { return []; } /** * Get the lenses available for the resource. */ public function lenses(NovaRequest $request): array { return []; } /** * Get the actions available for the resource. */ public function actions(NovaRequest $request): array { return [ ExportEvidenceForProducts::make() ->confirmText('Delilnama çykarmak isleýarmisiňiz?') ->confirmButtonText('Hawa') ->cancelButtonText('Ýok') ->icon(IconRepository::make()->documentDownload()), ]; } }