Reputation:
I haven't seen anyone doing this, so i'm bit confused if it can be good approach.
Some small system with login. And i have simple group management withing that system. I want to be able to easily set and execute some triggers depending of action and on group in which user belongs.
First idea that came to my mind is to have in groups table 4 fields for triggers, named like this:
Now i'm wondering how to relate that to an actual trigger code?
Should i have separated class triggers that should receive just "names" of triggers and in that class to hold all possible trigger's code? So that i'm able to execute that in some kind of a loop?
Does anyone have any other idea how to organize that?
p.s. those groups are quite an important part of a system. Most of the things should be based on them. They even has extending tables for complex type of groups.
thnx
Upvotes: 0
Views: 450
Reputation: 21531
What your looking for is Laravel Events.
I would definetly recommend making a class that the event calls rather than writing procedural style code.
Event::listen('auth.login', 'LoginHandler@onLogin');
Upvotes: 0