<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class RoadTechnicalBuildingHistory extends Model
{
    protected $fillable = [
        'user_id',
        'previous_axis_name',
        'previous_axis_type',
        'previous_project_name',
        'previous_cities_id',
        'previous_contractor_name',
        'previous_consultant_name',
        'previous_contract_date',
        'previous_contract_credit',
        'previous_start_latlng',
        'previous_end_latlng',
        'previous_team_latlng',
        'previous_stop_reason',
        'previous_submited_at',
        'previous_last_updated_at',
        'previous_project_distance',
        'previous_project_distance_update',
        'previous_contractor_credit',
        'previous_physical_progress',
        'previous_description',
        'previous_status',
        'previous_project_status',
        'new_files'
    ];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [
        'previous_cities_id' => 'array',
        'previous_project_distance' => 'array',
        'previous_project_distance_update' => 'array',
        'previous_start_latlng' => 'array',
        'previous_team_latlng' => 'array',
        'previous_end_latlng' => 'array'
    ];

    public function project()
    {
        return $this->belongsTo('App\Models\RoadTechnicalBulding');
    }
    
    public function files()
    {
        return $this->morphMany('App\Models\ProjectFile', 'project_fileable');
    }
}
