<?php
// app/KegiatanLog.php

namespace App;

use Illuminate\Database\Eloquent\Model;

class KegiatanLog extends Model
{
    protected $fillable = [
        'kegiatan_id', 
        'user_id', 
        'aksi', 
        'catatan', 
        'tujuan_user_id'
    ];

    public function kegiatan() 
    { 
        return $this->belongsTo(Kegiatan::class); 
    }
    
    public function user()     
    { 
        return $this->belongsTo(User::class); 
    }
    
    public function tujuan()   
    { 
        return $this->belongsTo(User::class, 'tujuan_user_id'); 
    }

    // Label per aksi
    public function getAksiLabelAttribute()
    {
        $labels = [
            'terkirim'   => 'Laporan Dikirim',
            'diterima'   => 'Diterima Admin',
            'diproses'   => 'Sedang Diproses',
            'diteruskan' => 'Diteruskan',
            'selesai'    => 'Selesai',
        ];
        return $labels[$this->aksi] ?? ucfirst($this->aksi);
    }

    // Icon per aksi
    public function getAksiIconAttribute()
    {
        $icons = [
            'terkirim'   => ['icon' => 'fa-paper-plane', 'bg' => '#eff6ff', 'color' => '#1d4ed8'],
            'diterima'   => ['icon' => 'fa-inbox',       'bg' => '#fefce8', 'color' => '#854d0e'],
            'diproses'   => ['icon' => 'fa-sync-alt',    'bg' => '#fff7ed', 'color' => '#c2410c'],
            'diteruskan' => ['icon' => 'fa-share',       'bg' => '#f5f3ff', 'color' => '#6d28d9'],
            'selesai'    => ['icon' => 'fa-check-circle','bg' => '#f0fdf4', 'color' => '#15803d'],
        ];
        return $icons[$this->aksi] ?? ['icon' => 'fa-circle', 'bg' => '#f1f5f9', 'color' => '#475569'];
    }
}