<?php

namespace App\Models;

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

class Receivables extends Model
{
    use SoftDeletes;

    protected $fillable = ['sales_id',
            'rcvd_code',
            'contract_amount',
            'comm_rate',
            'num_month',
            'remarks',
            'user_id'
        ];


    protected $table = 'rcvd_comm';

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

    /*public function getFullnameAttribute() {
        return "{$this->firstname} {$this->lastname}";
    }*/

    /*public function developer() {
        return $this->belongsTo(Developer::class, 'developer_id');
    }

    public function project() {
        return $this->belongsTo(Project::class, 'project_id');
    }*/

    public function sales() {
        return $this->belongsTo(Sales::class, 'sales_id');
    }

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

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

}
