<?php

namespace App;

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

class CallLogs extends Model
{

    use SoftDeletes;

    protected $table = 'call_logs';

    public function consumer(){
        return $this->hasOne('App\ConsumerApplication','id','_id')/*->where('call_logs.id_type','application_id')*/;
    }

    public function merchant(){
        $this->where('id_type','merchant');
        return $this->hasOne('App\Merchant','id','_id');
    }

    public function center(){
        $this->where('id_type','merchant_location_id');
        return $this->hasOne('App\MerchantLocation','id','_id');
    }

    public function users(){
               $this->where('id_type','user_id');
        return $this->hasOne('App\User','id','_id');
    }

    public function picked_by(){
        return $this->hasOne('App\User','id','user_id');
    }

    public function received_by(){
        $this->where('id_type','application_id');
        return $this->hasOne('App\ConsumerApplication','id','_id');
    }
}
