api code global jain
This commit is contained in:
31
app/Traits/HasKarmaPoint.php
Normal file
31
app/Traits/HasKarmaPoint.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?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()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user