Files
Global-Jain/app/Traits/HasKarmaPoint.php

32 lines
747 B
PHP
Raw Normal View History

2025-11-05 10:37:10 +05:30
<?php
namespace App\Traits;
use App\Models\User;
use Illuminate\Support\Facades\Log;
trait HasKarmaPoint
{
public function addKarmaPoints($model, $userId, string $message, $points, string $key, array $properties)
{
// dd($model, $userId, $message, $points, $key, $properties);
$model->addPoints()->create([
'user_id' => $userId,
'message' => $message,
'points' => $points,
'key' => $key,
'trasaction_type' => 'credit',
'properties' => $properties,
]);
if ($model instanceof User) {
User::find($userId)->increment('karma_dhan', $points);
}
}
public function revokeKarmaPoints()
{
//
}
}