qcod/laravel-gamify

subject for reputation

Closed this issue · 3 comments

Hello
Please how to add a dynamic subject like , the user X created the post Y ?

And thanks

If you want to print history of reputation you can just use this and build the dynamic msg https://github.com/qcod/laravel-gamify#get-reputation-history

foreach($user->reputations as $reputation) {
    echo 'user '. $reputation->payee->name . ' created  post ' . $reputation->subject->title;
}

Or if you just want to define a dynamic subject you can do it by method getSubject on point class

public function getSubject()
{
    return $this->payee()->post()->latest()->first();
}

You can also pass subject via points constructor https://github.com/qcod/laravel-gamify#give-point-to-user

Please explain more if I miss understood your issue.

Just how to add subject text because in my db i have subject empty (NULL)

Ok, share your subject model and point type which is giving you null subject. What about subject_id, does that has value? You should add this relation on the subject model

 /**
     * Get all the post's reputation.
     */
    public function reputations()
    {
        return $this->morphMany('QCod\Gamify\Reputation', 'subject');
    }