<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Spatie\Activitylog\Traits\LogsActivity;
use Spatie\Activitylog\Contracts\Activity;
use Spatie\Activitylog\LogOptions;

class ProposalApprovals extends Model
{
	use HasFactory, LogsActivity;
	
	protected $table = 'proposalapprovals';
	
	protected  $primaryKey = 'ProposalApprovalID';
	
	public $timestamps = false;
	
    protected $fillable = [
    'ProposalID',
	'Response',
	'UserID'
  ];
  
  public function getActivitylogOptions(): LogOptions
    {
        return LogOptions::defaults()
        ->logFillable()
		->logOnlyDirty(); //only the changed
    }
	
	public function tapActivity(Activity $activity)
    {
        $activity->table_name = "proposalapprovals";
    }
  
	public function user(): BelongsTo
		{
			return $this->BelongsTo(User::class,'UserID','id'); //'foreign_key', 'local_key'
		}
		
	public function proposal(): BelongsTo
		{
			return $this->BelongsTo(Proposal::class,'ProposalID','ProposalID'); //'foreign_key', 'local_key'
		}
  
}
