<?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 RevenueStream extends Model
{
	use HasFactory, LogsActivity;
	
	protected $table = 'revenuestreams';
	
	protected  $primaryKey = 'StreamID';
	
	public $timestamps = false;
	
    protected $fillable = [
    'StreamName',
	'CategoryID',
	'Description'
  ];
  
  public function getActivitylogOptions(): LogOptions
    {
        return LogOptions::defaults()
        ->logFillable()
		->logOnlyDirty(); //only the changed
    }
	
	public function tapActivity(Activity $activity)
    {
        $activity->table_name = "revenuestreams";
    }
  
  public function category(): BelongsTo
    {
        return $this->BelongsTo(Category::class,'CategoryID','CategoryID'); //'foreign_key', 'local_key'
    }
  
	
}
