<?php

namespace App;

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

class Complaint extends Model
{

	use SoftDeletes;
	
	public function company()
	{
		return $this->belongsTo('App\Company');
	}
	
	public function employee()
	{
		return $this->belongsTo('App\Employee')->select('id', 'company_id', 'name', 'preferences')->withTrashed();
	}
	
	public function customer()
	{
		return $this->belongsTo('App\Customer')->select('id', 'name')->withTrashed();
	}
	
	protected $hidden = ['created_at', 'updated_at', 'deleted_at'];
	
	protected $appends = ['created_at_formatted'];
	
	public function getCreatedAtFormattedAttribute()
    {
		if (isset($this->attributes['created_at'])) {
			return date('m/d/Y h:i A', strtotime($this->attributes['created_at']));
		}
        return null;
    }

}
