<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class RahdariPoint extends Model
{

    public static function boot()
    {
        parent::boot();

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

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

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

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

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

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

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'province_name',
        'city_name',
        'province_id',
        'city_id',
        'name',
        'status',
        'type',
        'type_fa',
        'team_num',
        'staff_num',
        'phone',
        'responsible_name',
        'responsible_mobile',
        'successor_name',
        'successor_mobile',
        'machines_light',
        'machines_sheavy',
        'machines_heavy',
        'code',
        'lat',
        'lng',
        'lat_from',
        'lng_from',
        'geometry',
        'color',
        'lat_to',
        'lng_to',
        'updated_at_fa',
    ];

    /**
     * Get all of the point's files.
     */
    public function files()
    {
        return $this->morphMany('App\Models\PointFile', 'point_fileable');
    }

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