<?php

namespace App;

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

use Carbon\Carbon;

class CreditUser extends Model
{
	use SoftDeletes;
	
	protected $table = 'credit_user';
    protected $dates = ['deleted_at', 'date'];
    
		protected $fillable = [
        'quantity',
		'date',
		'user_id',
		'credit_id',
		'reservation_id'
		
    ];

	public function user()
	{
		return $this->belongsTo('App\User');
	}

	public function reservation()
	{
			return $this->hasOne('App\Reservations','id','reservation_id');
	}

		public function credit()
	{
		return $this->belongsTo('App\Credit');
	}


    public function setDateAttribute($date){
			$this->attributes['date'] = Carbon::parse($date);
		}
		
		public function getDateAttribute($date){
			return Carbon::parse($date)->format('m/d/Y');
		}

	
}
