<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class HierarchyFtth extends Model
{
  protected $table = "m_hierarchy_ftth";

  const CREATED_AT = 'created_at';
  const UPDATED_AT = 'updated_at';

  protected $fillable = [
    'name', 'parent_id', 'project_id', 'created_at', 'updated_at', 'progress', 'bobot_planning'
  ];
  
  public static function boot() {
		parent::boot();

		static::deleted(function($data) {
      $ftths = HierarchyFtth::where('parent_id', $data->id)->get();
      foreach ($ftths as $ftth) {
          $ftth->delete();
      }
		});
	}
}