85 lines
2.0 KiB
PHP
85 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Spatie\Activitylog\Traits\LogsActivity;
|
|
use Spatie\Activitylog\LogOptions;
|
|
|
|
class MediaMonitoring extends Model
|
|
{
|
|
use SoftDeletes, LogsActivity;
|
|
|
|
protected $table = 'media_monitorings';
|
|
|
|
protected $fillable = [
|
|
'code',
|
|
'media_name',
|
|
'theme',
|
|
'title',
|
|
'channel',
|
|
'writter',
|
|
'link',
|
|
'news_page',
|
|
'quote',
|
|
'content',
|
|
'influencer',
|
|
'keyword',
|
|
'image',
|
|
'release_date',
|
|
'enhancer_id',
|
|
];
|
|
|
|
public function issue(){
|
|
return $this->hasOne(IssueManagement::class, 'media_monitoring_id', 'id');
|
|
}
|
|
|
|
public function enhancer()
|
|
{
|
|
return $this->belongsTo(User::class, 'enhancer_id', 'id');
|
|
}
|
|
|
|
public function getActivitylogOptions(): LogOptions
|
|
{
|
|
return LogOptions::defaults()
|
|
->logOnly([
|
|
'code',
|
|
'media_name',
|
|
'theme',
|
|
'title',
|
|
'channel',
|
|
'writter',
|
|
'link',
|
|
'news_page',
|
|
'quote',
|
|
'content',
|
|
'influencer',
|
|
'keyword',
|
|
'image',
|
|
'release_date',
|
|
'enhancer_id',
|
|
]) // kolom yang dicatat
|
|
->useLogName('media_monitoring') // 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 "Monitoring Media '{$this->title}' telah {$eventName}";
|
|
}
|
|
|
|
}
|