Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using allFields() method breaks export of relationship and computed fields #98

Merged
merged 1 commit into from
Oct 8, 2020

Conversation

ahmedabdel3al
Copy link

@ahmedabdel3al ahmedabdel3al commented Sep 4, 2020

[#48 ]
this PR merge non index fields with index fields when using allFields method

I have case that i want to export all index fields with non index fields. so i found allFields method but this method breaks export of relationship and computed fields .
so i found getOnly method in Only Trait which set only in case of index Fields and count of only equal zero
but also needed to merge non index fields with index fields in case of using allFields method

@patrickbrouwers
Copy link
Member

Can you give a couple of examples I can test this against?

@ahmedabdel3al
Copy link
Author

ahmedabdel3al commented Sep 11, 2020

@patrickbrouwers
#49
this PR fix this issue

 /**
     * Get the fields displayed by the resource.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function fields(Request $request)
    {

        return [
            ID::make()->sortable(),

            Text::make('Downpayment', 'booking_price')->sortable(),

            BelongsTo::make('Show Room', 'showRoom')->sortable(),

            BelongsTo::make('Vehicle Model', 'vehicleModel')->sortable(),

            BelongsTo::make('Vehicle Category', 'vehicleCategory')->sortable(),

            BelongsTo::make('Vehicle Color', 'vehicleColor')->sortable(),

        ];
    }


 /**
     * Get the actions available for the resource.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function actions(Request $request)
    {
        return [
            (new DownloadExcel)->withHeadings()->allFields()->except([
                'payment_date',
                'toyota_id',
                'status',
                'payment_method',
                'personal_id_type',
                'show_room_id',
                'vehicle_model_id',
                'vehicle_category_id',
                'vehicle_color_id',

            ]),
        ];
    }

before
the result set not included nova resources attributes

after
the result set will include nova resources attributes with model attributes

@patrickbrouwers patrickbrouwers merged commit cc91b4b into SpartnerNL:1.2 Oct 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants