feat: tambah sistem poin anggota (kehadiran +10, artikel +5)
- Model MemberPoint + migration - PostObserver: +5 poin saat artikel dipublish - ActivityObserver: +10 poin saat peserta hadir di kegiatan - MemberPointResource: tampil di grup Organisasi - MemberPointSeeder + update ActivitySeeder dengan pivot status kehadiran - Update PermissionSeeder: anggota bisa lihat poin
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class MemberPoint extends Model
|
||||
{
|
||||
protected $fillable = ['user_id', 'points', 'reason', 'source_type', 'source_id'];
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\MemberPoint;
|
||||
use Database\Factories\UserFactory;
|
||||
use Filament\Models\Contracts\FilamentUser;
|
||||
use Filament\Panel;
|
||||
@@ -54,6 +55,16 @@ class User extends Authenticatable implements FilamentUser
|
||||
return $this->hasMany(CashRecord::class, 'created_by');
|
||||
}
|
||||
|
||||
public function points(): HasMany
|
||||
{
|
||||
return $this->hasMany(MemberPoint::class);
|
||||
}
|
||||
|
||||
public function totalPoints(): int
|
||||
{
|
||||
return $this->points()->sum('points');
|
||||
}
|
||||
|
||||
public function canAccessPanel(Panel $panel): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user