gamify reputation added

This commit is contained in:
Benjamin Takats
2023-01-15 17:09:04 +01:00
parent 41cbce2add
commit d1c211fd5a
7 changed files with 154 additions and 0 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Models;
use App\Gamify\Points\BookCaseOrangePilled;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -27,6 +28,13 @@ class OrangePill extends Model
'date' => 'datetime',
];
protected static function booted()
{
static::creating(function ($model) {
$model->user->givePoint(new BookCaseOrangePilled($model));
});
}
public function user(): BelongsTo
{
return $this->belongsTo(User::class);