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

[2.x] Fix duplicate feature nested module #1846

Open
wants to merge 1 commit into
base: 2.x
Choose a base branch
from

Conversation

mazeeblanke
Copy link
Contributor

Description

This PR introduces a new hook that allows the developer to add extra data for duplicating a nested module item.
For example, if the nested module is genericDetail and the main module is page, the following error is triggered

Screenshot 2022-10-10 at 11 01 27

The page route parameter is missing above, and this PR helps us fix it by allowing us add it as an extra parameter in the controller:

class PageGenericDetailController extends ModuleController
{
    protected $moduleName = 'genericDetails';
    protected $modelName = 'GenericDetail';
    ...
   
    protected function duplicateItemData()
    {
        return [
            'page' => request()->id,
        ];
    }

    ...
}

And if we need to add any extra data in the repository, we can do that like so:

class GenericDetailRepository extends ModuleRepository
{
   ....

   protected function duplicateItemData()
    {
        return [
            'page_id' => request()->id
        ];
    }

  ...
}

Related Issues

This PR fixes this issue #1730

@ifox ifox changed the title fix duplicate feature nested module [2.x] Fix duplicate feature nested module Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants