<?php

namespace App;

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

use Carbon\Carbon;

class Incidence extends Model
{
	use SoftDeletes;
	
	protected $dates = ['deleted_at', 'date'];
	protected $table = 'incidences';
	
	protected $fillable = [
		'user_id',
		'read',
		'subject',
		'date',
		'comments'
	];
	
	public function user()
	{
		return $this->belongsTo('App\User');
	}
	
	
	
	public function setDateAttribute($date){
		$this->attributes['date'] = Carbon::parse($date);
	}
	
	public function getDateAttribute($date){
		return Carbon::parse($date)->format('m/d/Y');
	}
}
