<?php

class VisitCost extends Eloquent {

	use SoftDeletingTrait;

	protected $guarded		 = array();
	public static $rules	 = array();

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

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

	public function setCostAttribute($value) {
		$value										 = str_replace(',', '.', $value);
		$value										 = str_replace(' ', '', $value);
		$this->attributes['cost']	 = round($value * 100, 0);
	}

	public function getCostAttribute() {
		return round($this->attributes['cost'] / 100, 2);
	}

}
