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

feat: dynemic permissions and detail resource #19

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

Conversation

prolaxu
Copy link

@prolaxu prolaxu commented Jan 11, 2025

feat : Enhance CrudBaseController with Dynamic Permissions and Detailed Resources

Summary

This PR introduces dynamic permissions and enhances resource handling in the CrudBaseController.

Changes

  1. Dynamic Permissions: Implemented flexible permission rules that can be overridden in child classes.
  2. Detailed Resource Handling: Added support for using different resources for detail views.
  3. PR Description Format: Updated the PR description template for clarity and consistency.

Notes

  • The dynamic permissions system improves flexibility and reduces IT workload.
  • The detailed resource handling enhances customization options for views.

How to Test

  1. Verify that dynamic permissions are applied correctly for different models.
  2. Test that detail views use the specified $detailResource.

Example:

public function __construct()
{
    $this->permissionRules = [
        'view' => ['index', 'show'],
        'alter' => ['store', 'update', 'changeStatus', 'changeStatusOtherColumn', 'restore'],
        'delete' => ['delete'],
    ];
    parent::__construct(
        model: User::class,
        storeRequest: UserRequest::class,
        updateRequest: UserRequest::class,
        resource: UserResource::class,
        detailResource: UserDetailResource::class
    );
}

Copy link

codesandbox bot commented Jan 11, 2025

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

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.

1 participant