<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Coridor extends Model
{
    public static function boot()
    {
        parent::boot();

        self::creating(function($model){
        });

        self::created(function($model){
        });

        self::updating(function($model){
            auth()->user()->addActivityComplete(1052,$model);
        });

        self::updated(function($model){
        });

        self::deleting(function($model){
            auth()->user()->addActivityComplete(1053,$model);
        });

        self::deleted(function($model){
        });
    }

    protected $fillable = [
        'province_name',
        'city_name',
        'name',
        'status',
        'type',
        'team_num',
        'staff_num',
        'phone',
        'responsible_name',
        'responsible_mobile',
        'successor_name',
        'successor_mobile',
        'machine_data',
        'team_data',
        'code',
        'lat',
        'lng',
        'start_lat',
        'start_lng',
        'geometry',
        'color',
        'end_lat',
        'end_lng'
        ];
    public function files()
    {
        return $this->morphMany('App\Models\PointFile', 'point_fileable');
    }

    public function rahdariPointHistories()
    {
        return $this->hasMany('App\Models\RahdariPointHistory', 'point_id');
    }
}