kirschbaum-development / nova-inline-relationship

A package to present relationships as inline properties in Nova.
MIT License
196 stars 84 forks source link

inline with support for visible fields on detail only #19

Closed chorton closed 4 years ago

chorton commented 4 years ago

Hello,

I have a resource with some fields that I have a chained exceptOnForms method. When I reference that resource from another resource using, for example, HasMany....->inline(), those fields I've set to show exceptOnForms never appear on the detail page for the resource that references the inline resource.

Is there a different way to get those fields to show up? I just don't want those fields to appear on forms.

brandonferens commented 4 years ago

@chorton If I am understanding you correctly, you have for example, three field: name, age, and email. You don't want age to show up on any form, but when displaying the form via inline(), the visibility for age is not respected?

brandonferens commented 4 years ago

@chorton We have fixed this issue in PR #28 and will release as a new tagged version soon.

Muetze42 commented 3 years ago

The default functions like ->exceptOnForms() missing in this package. Check in fields the request and you can make custom Fields with ->canSee() and the request

Request Check:

public function fields(Request $request)
    {
        Log::debug(print_r($request->all(), true));

Example: Hide on forms:

            HasMany::make(__('Raffles'), 'raffle', Raffle::class)->inline()
                ->canSee(function () use ($request) {
                    return !$request->get('editing');
                }),

Example only for forms should be:

            HasMany::make(__('Raffles'), 'raffle', Raffle::class)->inline()
                ->canSee(function () use ($request) {
                    return $request->get('editing');
                }),

The You can make Custom Nova Resource with own relatableQuery, fields etc, like:

            HasMany::make(__('Raffles'), 'raffle', RaffleCustom::class)->inline()
                ->canSee(function () use ($request) {
                    return !$request->get('editing');
                }),