Support the ongoing development of Laravel.io →
Requests Database Architecture
Last updated 1 year ago.
0

So I guess you want to build a system a bit like stackoverflow/stackexchange? I think the best would be to work with Events or model observers, depends on your actions which you want to log.

For example fire an event when the user uploads a picture. You could store the events in a database and log the user actions. And than you get badges too the user.

http://laravel.com/docs/events

Last updated 1 year ago.
0

@psychonetic - That system would be a great example. I was thinking that events might be the best route after doing some research. It sounds much simpler after I read your example... Thanks for the feedback!

Last updated 1 year ago.
0

We did a bit of work on an event based achievement system in Laravel for http://worldwalking.org.

Essentially in our service provider we bind a checker class to each achievement name (corresponding to the name in the achievements database table), e.g.

 $this->app->bind('challenge.achievement.healthy_heart', 'Walking\Challenge\Achievements\HealthyHeartAchievement');

Each achievement check class extends an abstract AchievementCheck class and implements a gained() method which returns true or false depending on whether the user should receive the achievement.

Finally we have an event handler that listens for specific achievement-rewarding events and fires a custom queue job that loops through all the achievements the user hasn't already gained, resolves the checker class out of IoC and 'gains' the achievement (pivot table relation) if the checker class returns true.

Last updated 1 year ago.
0

Hi @davidrushton, Do you maybe have a code sample for the Achievement class? Thank you!

0

notflip said:

Hi @davidrushton, Do you maybe have a code sample for the Achievement class? Thank you!

@notflip did you end up implementing this?

0

@dangelsaurus @notflip Im curious too. Any of you ended up implementing this?

0

@dangelsaurus @notflip @bar2 Don't know whether you already solved your issue, but I've implemented this feature and release it as an open-source package to Laravel. Here is the link: https://github.com/gstt/laravel-achievements

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Failcookie failcookie Joined 20 Mar 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.