-
|
Hi, thanks for creating this amazing package! I was wondering if it comes along with any event listeners to track achievements and streaks or do I need to implement it myself? Can I also confirm that it doesn't include CRUD interfaces to allow users to manage Levels, Achievements, Streak Activities and that has to be done separately? Lastly, could you improve on the documentation for the Auditing feature? I can't seem to understand how it works: $user->addPoints( Appreciate if you can clarify on these, thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
|
Hi, Thanks for the kind words, glad you're liking it! To answer your questions:
There are also events for when Streak activities happen too -- see README here
By default, the data is auto-populated based on the actions taken, but you can overwrite it by supplying a This needs to be enabled in the config first, before it can be used, change |
Beta Was this translation helpful? Give feedback.
-
|
Hi,
Thanks for getting back to me so quickly. I’m still slightly confused and hope you can help me out.
Basically, what I’m trying to achieve is this (after user performs an action):
// Award points
$user->addPoints(
amount: 10,
reason: "User login",
);
// Updates achievement progress
$achievement = \LevelUp\Experience\Models\Achievement::find(1);
$user->incrementAchievementProgress(
achievement: $achievement,
amount: 10 // 10%
);
// Record streaks
$activity = \LevelUp\Experience\Models\Activity::find(1);
$user->recordStreak($activity);
My question is, instead of me having to query the database to fetch the respective $achievement and $activity each time the user performs the action (2 eloquent queries). Is there a more efficient way of doing this?
As for AuditType, I understand that it is auto-populated but I don’t understand in what cases would I need to overwrite it? Can you give me an example to illustrate this?
Thank you.
Regards,
Peh
…On 13 Aug 2025 at 5:19 PM +0800, Chris Mellor ***@***.***>, wrote:
Hi,
Thanks for the kind words, glad you're liking it!
To answer your questions:
1. There are some Events for when Achievement activities happen -- check the README here
There are also events for when Streak activities happen too -- see README here
2. > Correct, the package does not come with any frontend components. If you were to make one I'd be happy to link it as an unofficial add-on
3. > When points are added, a new type and reason are added to an activities table.
By default, the data is auto-populated based on the actions taken, but you can overwrite it by supplying a type and reason attribute in the addPoints method
type: AuditType::Add->value,
reason: "Some reason here",
This needs to be enabled in the config first, before it can be used, change audit.enabled to true
/*
| -------------------------------------------------------------------------
| Audit
| -------------------------------------------------------------------------
|
| Set the audit configuration.
|
*/
'audit' => [
'enabled' => env(key: 'AUDIT_POINTS', default: false),
],
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Not at this time. I am open to accepting PR's for this.
Overwrite the |
Beta Was this translation helpful? Give feedback.
Not at this time. I am open to accepting PR's for this.
Overwrite the
reasonto just provide your own custom reasoning message.