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

Use model events to handle different modes of user deletion #819

Open
alexweissman opened this issue Dec 5, 2017 · 3 comments
Open

Use model events to handle different modes of user deletion #819

alexweissman opened this issue Dec 5, 2017 · 3 comments
Labels
architecture Related to the framework architecture core feature request Feature request long-range planning Long term roadmap
Milestone

Comments

@alexweissman
Copy link
Member

Discussed in #785. Basically we should stop overriding User::delete, and instead factor out this code and its decision points into model events and controller methods.

The way I see it, we might have three modes of deletion:

  • Soft delete (deleted_at timestamp)
  • Medium delete (deleted_at timestamp and clear out most user details)
  • Hard delete (delete record and delete/null out any orphaned related entities)

It's possible that if we make all related entities have nullable FKs, then medium-delete and hard-delete can be essentially the same thing.

This also brings up the question of what to do when a new user wants to use the username/email of an account that was deleted previously.

@alexweissman alexweissman added architecture Related to the framework architecture core feature request Feature request labels Dec 5, 2017
@splitt3r
Copy link
Contributor

splitt3r commented Dec 7, 2017

I think adding pre and postDelete events would be a pretty nice solution. That way a sprinkle could listen to e.g. user.preDelete / onPreUserDelete (http://symfony.com/doc/current/components/event_dispatcher/generic_event.html & https://learn.userfrosting.com/services/default-services#eventdispatcher) and remove everything so that there won´t be any constraint problems. And perhaps rename the events to follow https://symfony.com/doc/current/components/event_dispatcher.html#naming-conventions.

@alexweissman
Copy link
Member Author

So actually, Eloquent already supports model events: https://laravel.com/docs/5.4/eloquent#events

@splitt3r
Copy link
Contributor

splitt3r commented Dec 8, 2017

Looks great 👍

@lcharette lcharette added the long-range planning Long term roadmap label Apr 19, 2019
@lcharette lcharette added this to the 5.1.0 milestone Nov 25, 2023
@lcharette lcharette moved this to Todo 5.1.0 in UserFrosting Task Planner Nov 26, 2023
@lcharette lcharette moved this from Todo 5.1.0 to Todo 5.2.0 in UserFrosting Task Planner Mar 10, 2024
@lcharette lcharette moved this from Todo 5.2.0 to Not Started in UserFrosting Task Planner Apr 13, 2024
@lcharette lcharette modified the milestones: 5.1.0, 5.3.0 Apr 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
architecture Related to the framework architecture core feature request Feature request long-range planning Long term roadmap
Projects
Status: Not Started
Development

No branches or pull requests

3 participants