<?php

namespace App;

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

use Carbon\Carbon;

class Boat extends Model
{
	use SoftDeletes;

	
	protected $table = 'boat';

	protected $dates = ['deleted_at','launch'];
	
	protected $fillable = [
		'user_id',
		'name',
		'launch',
		'maker',
		'number',
		'model',
		'port_id',
		'boattype_id'
	];
	
	public function customer()
	{
		return $this->belongsTo('App\Customer');
	}

	public function customers()
    {
        return $this->belongsToMany('App\Customer');
    }

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

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

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

	public function getFullNameAttribute() {
        return ucfirst($this->fiscal_reason);
    }
	
}
