You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: digital_garden.rb
    path of file: ./repos/wreeto_official/app/models
    
    the code of the file until where you have to start completion: class DigitalGarden < ApplicationRecord
  belongs_to :user
  has_and_belongs_to_many :notes

  before_validation :set_slug

  # TODO: Improve valid
    
  def categories 
    cats = {par: [], sub: []}
    enabled_notes.map do |note|
      category = note.category
      parent = note.category.parent
      if parent.present? 
        cats[:par] << parent 
        cats[:sub] << category
      else 
        cats[:par] << category
      end
    end