Sha256: fb7f8eba220131278ac65c7c63c606b7a373efdcc6eeded7cfe756dd041fd763

Contents?: true

Size: 1.58 KB

Versions: 1

Compression:

Stored size: 1.58 KB

Contents

module PhcdevworksCoreModules
  class Marketing::Optimization < ApplicationRecord

    # Clean URL Initialize
    extend FriendlyId

    # Image Upload
    has_one_attached :seo_twitter_image
    has_one_attached :seo_open_graph_image

    # Paper Trail Initialize
    has_paper_trail :class_name => "PhcdevworksCoreModules::CoreOptimizationVersions"

    # Relationships for Local
    belongs_to :user, class_name: "PhcdevworksAccounts::User"
    has_many :categories, class_name: "PhcdevworksCoreModules::Post::Category"
    
    # Relationships for PHCDevworks Plugins
    if defined?phcdevworks_members
      has_many :listings, class_name: "PhcdevworksMembers::Member::Listing"
    end
    if defined?phcdevworks_scripts
      has_many :listings, class_name: "PhcdevworksScripts::Script::Listing"
    end
    if defined?phcdevworks_press
      has_many :posts, class_name: "PhcdevworksPress::Article::Post"
    end
    if defined?phcdevworks_portfolio
      has_many :posts, class_name: "PhcdevworksPortfolio::Project::Post"
    end
    if defined?phcdevworks_tutorials
      has_many :posts, class_name: "PhcdevworksTutorials::Tutorial::Post"
      has_many :posts, class_name: "PhcdevworksTutorials::Command::Post"
    end

    # Form Fields Validation
    validates :seo_title,
      presence: true

    validates :seo_open_graph_title,
      presence: true

    validates :seo_twitter_title,
      presence: true

    # Clean URL Define
    friendly_id :phcdev_core_optimization_nice_urls, use: [:slugged, :finders]

    def phcdev_core_optimization_nice_urls
      [:seo_title].join("-")
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
phcdevworks_core_modules-3.0.0 app/models/phcdevworks_core_modules/marketing/optimization.rb