'integer', 'parent' => 'integer' ]; const CREATED_AT = 'created_at'; const UPDATED_AT = 'updated_at'; public static function boot() { parent::boot(); static::deleting(function ($data) { $data->children()->delete(); }); } public function parent() { return $this->belongsTo(self::class, 'parent')->where('parent', null); } public function children() { return $this->hasMany(self::class, 'parent'); } }