<?php

namespace App\Models;

use App\User;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Model;

class CommRelease extends Model
{
    use SoftDeletes;

    protected $fillable = ['gr_id', 'agent_id', 'umanager_id', 'referrer_id', 'remarks', 'user_id'];

    protected $table = 'comm_releases';

    public static function boot()
    {
        //parent::boot();
        //Developer::observe(new \App\Observers\UserActionsObserver);
    }

    public function agent() {
        return $this->belongsTo(Agent::class, 'agent_id');
    }

    public function manager() {
        return $this->belongsTo(Agent::class, 'umanager_id');
    }

    public function referrer() {
        return $this->belongsTo(Agent::class, 'referrer_id');
    }

    public function user() {
        return $this->belongsTo(User::class, 'user_id');
    }

    public function release_dtl() {
        return $this->hasmany(CommReleaseDtl::class, 'id');
    }

    /*public function getTotalAmountAttribute()
    {
        return $this->commission->sum('release_amount');
        //return $this->release_amount;
    }*/


}
