fix: gunakan author_id (bukan user_id) di PostObserver dan MemberPointSeeder
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
/storage/*.key
|
/storage/*.key
|
||||||
/storage/pail
|
/storage/pail
|
||||||
/vendor
|
/vendor
|
||||||
|
/.plan
|
||||||
_ide_helper.php
|
_ide_helper.php
|
||||||
Homestead.json
|
Homestead.json
|
||||||
Homestead.yaml
|
Homestead.yaml
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class PostObserver
|
|||||||
{
|
{
|
||||||
if ($post->wasChanged('status') && $post->status === 'published') {
|
if ($post->wasChanged('status') && $post->status === 'published') {
|
||||||
MemberPoint::create([
|
MemberPoint::create([
|
||||||
'user_id' => $post->user_id,
|
'user_id' => $post->author_id,
|
||||||
'points' => 5,
|
'points' => 5,
|
||||||
'reason' => "Artikel dipublikasi: {$post->title}",
|
'reason' => "Artikel dipublikasi: {$post->title}",
|
||||||
'source_type' => 'post',
|
'source_type' => 'post',
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class MemberPointSeeder extends Seeder
|
|||||||
// Poin dari artikel yang sudah published
|
// Poin dari artikel yang sudah published
|
||||||
Post::where('status', 'published')->each(function ($post) {
|
Post::where('status', 'published')->each(function ($post) {
|
||||||
MemberPoint::firstOrCreate(
|
MemberPoint::firstOrCreate(
|
||||||
['user_id' => $post->user_id, 'source_type' => 'post', 'source_id' => $post->id],
|
['user_id' => $post->author_id, 'source_type' => 'post', 'source_id' => $post->id],
|
||||||
['points' => 5, 'reason' => "Artikel dipublikasi: {$post->title}"]
|
['points' => 5, 'reason' => "Artikel dipublikasi: {$post->title}"]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user