<?php

namespace App;

use App\Traits\MultiTenantModelTrait;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Spatie\MediaLibrary\HasMedia\HasMedia;
use Spatie\MediaLibrary\HasMedia\HasMediaTrait;

class Kegiatanpkapk extends Model implements HasMedia
{
    use SoftDeletes, MultiTenantModelTrait, HasMediaTrait;

    public $table = 'kegiatanpkapks';

    const PENILAIAN_RADIO = [
        '1' => 'Setuju',
        '0' => 'Tolak',
    ];

    protected $dates = [
        'created_at',
        'updated_at',
        'deleted_at',
    ];

    protected $fillable = [
        'nama_id',
        'team_id',
        'penilaian',
        'created_at',
        'updated_at',
        'deleted_at',
        'kegiatan_id',
        'nama_klien_id',
    ];

    public function nama()
    {
        return $this->belongsTo(Referensipkapk::class, 'nama_id');
    }

    public function kegiatan()
    {
        return $this->belongsTo(Referensi::class, 'kegiatan_id');
    }

    public function nama_klien()
    {
        return $this->belongsTo(IdentitasKlien::class, 'nama_klien_id');
    }

    public function getdokumenAttribute()
    {
        return $this->getMedia('dokumen');
    }

    public function team()
    {
        return $this->belongsTo(Team::class, 'team_id');
    }
}
