Browse Source

Use attribute casting on the activity data

pull/72/head
Nafies Luthfi 5 years ago
parent
commit
81cec84ff0
  1. 4
      app/Entities/Users/Activity.php
  2. 4
      app/Listeners/Jobs/LogJobUpdateActivity.php
  3. 4
      app/Listeners/Projects/LogProjectJobDeletionActivity.php
  4. 4
      app/Listeners/Projects/LogProjectUpdateActivity.php

4
app/Entities/Users/Activity.php

@ -9,4 +9,8 @@ class Activity extends Model
protected $table = 'user_activities';
protected $fillable = ['type', 'parent_id', 'user_id', 'object_id', 'object_type', 'data'];
protected $casts = [
'data' => 'array',
];
}

4
app/Listeners/Jobs/LogJobUpdateActivity.php

@ -20,11 +20,11 @@ class LogJobUpdateActivity
'user_id' => auth()->id(),
'object_id' => $job->id,
'object_type' => 'jobs',
'data' => json_encode([
'data' => [
'before' => $this->getBeforeValues($originalJob, $attributeKeys),
'after' => $this->getAfterValues($job->toArray(), $attributeKeys),
'notes' => null,
]),
],
];
Activity::create($activityEntry);

4
app/Listeners/Projects/LogProjectJobDeletionActivity.php

@ -18,11 +18,11 @@ class LogProjectJobDeletionActivity
'user_id' => auth()->id(),
'object_id' => $projectId,
'object_type' => 'projects',
'data' => json_encode([
'data' => [
'name' => $job->name,
'description' => $job->description,
'price' => $job->price,
]),
],
];
Activity::create($activityEntry);

4
app/Listeners/Projects/LogProjectUpdateActivity.php

@ -26,11 +26,11 @@ class LogProjectUpdateActivity
'user_id' => auth()->id(),
'object_id' => $project->id,
'object_type' => 'projects',
'data' => json_encode([
'data' => [
'before' => $this->getBeforeValues($originalProject, $attributeKeys),
'after' => $this->getAfterValues($project->toArray(), $attributeKeys),
'notes' => null,
]),
],
];
Activity::create($activityEntry);

Loading…
Cancel
Save