<?php

class Checkcall extends \Eloquent {

	use SoftDeletingTrait;

	protected $guarded		 = array();

	const STATUS_NEW		 = 0;
	const STATUS_SUCCESS = 1;
	const STATUS_FAIL		 = 2;

	public function checkquestions() {
		return $this->belongsToMany('Checkquestion', 'checkcalls_checkquestions', 'checkcall_id', 'checkquestion_id');
	}

	public function checkquestionsLess() {
		return Checkquestion::whereProjectId($this->project_id)->whereRaw('id NOT IN (SELECT checkquestion_id FROM checkcalls_checkquestions WHERE checkcall_id=?)', array($this->id))->get();
	}

	public function project() {
		return $this->belongsTo('Project')->remember(60);
	}

	public function checkerUser() {
		return $this->belongsTo('User', 'checker_user_id')->remember(60);
	}

	public function user() {
		return $this->belongsTo('User')->withTrashed()->remember(60);
	}

	public function mlsitcall() {
		return $this->belongsTo('Mlsitcall')->remember(60);
	}

}
