<?php

namespace App;

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

class CustomerSource extends Model
{
	
	use SoftDeletes;
	
	protected $hidden = ['created_at', 'updated_at', 'deleted_at'];
	
	protected $appends = ['total_customers'];
	
	public function company()
	{
		return $this->belongsTo('App\Company');
	}
	
	public function customers()
	{
		return $this->hasMany('App\Customer');
	}
	
	public function getTotalCustomersAttribute()
    {
        return Customer::where('customer_source_id', $this->id)->count();
    }
	
}
