<?php

namespace App\Models;

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

class Rental extends Model
{
    use SoftDeletes;

    protected $fillable = [
            'contract_date',
            'end_date',
            'client_id',
            'authorized_name',
            'address',
            'prop_location',
            'monthly_rent',
            'deposit',
            'advance',
            'agent_id',
            'unit_manager_id',
            'user_id'
        ];

    protected $table = 'rentals';

    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(UnitManager::class, 'unit_manager_id');
    }

    public function client()
    {
        return $this->belongsTo(Client::class, 'client_id');
    }

    /*public function sales_detail()
    {
        return $this->hasOne(SalesComm::class, 'id');
    }*/

    /*public function getRateAttribute()
    {
        return $this->attributes['comm_rate'] = $this->rates['comm_rate'];
    }*/

}
