71 lines
1.8 KiB
PHP
71 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Spatie\Activitylog\Traits\LogsActivity;
|
|
use Spatie\Activitylog\LogOptions;
|
|
|
|
class CooperationCompletion extends Model
|
|
{
|
|
use LogsActivity;
|
|
protected $table = 'cooperation_completions';
|
|
|
|
protected $fillable = [
|
|
'payment_request_letter',
|
|
'invoice',
|
|
'bank_reference',
|
|
'electronic_tax_invoice',
|
|
'other_document',
|
|
'description',
|
|
'status',
|
|
'rejection_reason',
|
|
'media_id',
|
|
'order_id',
|
|
];
|
|
|
|
public function order(){
|
|
return $this->belongsTo(Order::class, 'order_id', 'id');
|
|
}
|
|
|
|
public function media(){
|
|
return $this->belongsTo(Media::class, 'media_id', 'id');
|
|
}
|
|
|
|
public function getActivitylogOptions(): LogOptions
|
|
{
|
|
return LogOptions::defaults()
|
|
->logOnly([
|
|
'payment_request_letter',
|
|
'invoice',
|
|
'bank_reference',
|
|
'electronic_tax_invoice',
|
|
'other_document',
|
|
'description',
|
|
'status',
|
|
'rejection_reason',
|
|
'media_id',
|
|
'order_id',
|
|
])
|
|
->useLogName('cooperation_completion') // 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 "Penyelesaian kerja sama telah {$eventName}";
|
|
}
|
|
}
|