74 lines
1.8 KiB
PHP
74 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Spatie\Activitylog\LogOptions;
|
|
use Spatie\Activitylog\Traits\LogsActivity;
|
|
|
|
class ContentRecap extends Model
|
|
{
|
|
use LogsActivity, SoftDeletes;
|
|
|
|
protected $table = 'content_recaps';
|
|
|
|
protected $fillable = [
|
|
'content_theme',
|
|
'posted_date',
|
|
'channel',
|
|
'link',
|
|
'classification_id',
|
|
'social_media',
|
|
'image',
|
|
'content_type',
|
|
'description',
|
|
'enhancer_id',
|
|
];
|
|
|
|
public function enhancer()
|
|
{
|
|
return $this->belongsTo(User::class, 'enhancer_id', 'id');
|
|
}
|
|
|
|
public function classification()
|
|
{
|
|
return $this->belongsTo(ContentRecapClassification::class, 'classification_id', 'id');
|
|
}
|
|
|
|
public function getActivitylogOptions(): LogOptions
|
|
{
|
|
return LogOptions::defaults()
|
|
->logOnly([
|
|
'content_theme',
|
|
'posted_date',
|
|
'channel',
|
|
'link',
|
|
'classification_id',
|
|
'social_media',
|
|
'image',
|
|
'content_type',
|
|
'description',
|
|
'enhancer_id', ]) // kolom yang dicatat
|
|
->useLogName('content_recap') // nama log
|
|
->logOnlyDirty(); // hanya log kalau ada perubahan
|
|
}
|
|
|
|
public function getDescriptionForEvent(string $eventName): string
|
|
{
|
|
switch ($eventName) {
|
|
case 'created':
|
|
$eventName = 'dibuat';
|
|
break;
|
|
case 'updated':
|
|
$eventName = 'diubah';
|
|
break;
|
|
case 'deleted':
|
|
$eventName = 'dihapus';
|
|
break;
|
|
}
|
|
|
|
return "Rekap Konten '{$this->content_theme}' telah {$eventName}";
|
|
}
|
|
}
|