drewroberts / blog

📝 Laravel package for my opinionated style of adding blog posts to Laravel projects
MIT License
2 stars 4 forks source link

Nova Layout Relationship #85

Open drewroberts opened 3 years ago

drewroberts commented 3 years ago

Could we limit the Nova Resource relationship to Layout (#60) to just show select options for those Layouts that have the same type as the current Nova Resource? For example, the Page (#15) resource should just show select options for Layouts that have the enum of Page:

Screen Shot 2021-04-16 at 11 42 42 AM
pdbreen commented 3 years ago

Looks like its possible by creating defining a relatableLayouts(...) method in those Nova resources. Reference - https://nova.laravel.com/docs/3.0/resources/authorization.html#dynamic-relatable-methods

I'll do a quick test.

pdbreen commented 3 years ago

@drewroberts Adding the following to src/Nova/Page.php filtered the options.

    public static function relatableLayouts(NovaRequest $request, $query)
    {
        return $query->where('layout_type', LayoutType::PAGE);
    }

Should be able to assign this to someone else to create the PR for all of the Nova resources in this package using this technique.

drewroberts commented 3 years ago

Perfect. Thank you.

@wolfrednicolas Can you knock out this issue today?

wolfrednicolas commented 3 years ago

https://github.com/drewroberts/blog/pull/86