<?php
/**
 * Webkul Software.
 *
 * @category  Webkul
 * @package   Webkul_AdvanceSeoManager
 * @author    Webkul
 * @copyright Copyright (c) Webkul Software Private Limited (https://webkul.com)
 * @license   https://store.webkul.com/license.html
 */
namespace Webkul\AdvanceSeoManager\Setup\Patch\Data;

use Magento\Eav\Setup\EavSetup;
use Magento\Eav\Setup\EavSetupFactory;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;

class CreateAttributes implements DataPatchInterface
{
    /**
     * @var ModuleDataSetupInterface
     */
    private $moduleDataSetup;
    /**
     * @var EavSetupFactory
     */
    private $eavSetupFactory;

    /**
     * @param ModuleDataSetupInterface $moduleDataSetup
     * @param EavSetupFactory $eavSetupFactory
     */
    public function __construct(
        ModuleDataSetupInterface $moduleDataSetup,
        EavSetupFactory $eavSetupFactory
    ) {
        $this->moduleDataSetup = $moduleDataSetup;
        $this->eavSetupFactory = $eavSetupFactory;
    }

    /**
     * {@inheritdoc}
     */
    public function apply()
    {
        /** @var EavSetup $eavSetup */
        $eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]);
         
        /**
         * Add attributes to the eav/attribute
         */

        // $eavSetup->removeAttribute(\Magento\Catalog\Model\Product::ENTITY,'focus_keyword');
        $eavSetup->addAttribute(
            \Magento\Catalog\Model\Product::ENTITY,
            'focus_keyword',
            [
                'group' => '',
                'type' => 'varchar',
                'backend' => '',
                'frontend' => '',
                'label' => 'Focus Keyword',
                'input' => 'text',
                'class' => '',
                'source' => '',
                'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
                'visible' => false,
                'required' => true,
                'user_defined' => false,
                'default' => '',
                'searchable' => false,
                'filterable' => false,
                'comparable' => false,
                'visible_on_front' => false,
                'used_in_product_listing' => false,
                'unique' => false
            ]
        );

        // $eavSetup->removeAttribute(\Magento\Catalog\Model\Product::ENTITY,'facebook_title');
        $eavSetup->addAttribute(
            \Magento\Catalog\Model\Product::ENTITY,
            'facebook_title',
            [
                'group' => '',
                'type' => 'varchar',
                'backend' => '',
                'frontend' => '',
                'label' => 'Facebook Open Graph Title',
                'input' => 'text',
                'class' => '',
                'source' => '',
                'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
                'visible' => false,
                'required' => true,
                'user_defined' => false,
                'default' => '',
                'searchable' => false,
                'filterable' => false,
                'comparable' => false,
                'visible_on_front' => false,
                'used_in_product_listing' => false,
                'unique' => false
            ]
        );

        // $eavSetup->removeAttribute(\Magento\Catalog\Model\Product::ENTITY,'facebook_image');
        $eavSetup->addAttribute(
            \Magento\Catalog\Model\Product::ENTITY,
            'facebook_image',
            [
                'group' => '',
                'type' => 'varchar',
                'backend' => '',
                'frontend' => '',
                'label' => 'Facebook Open Graph Image',
                'input' => 'text',
                'class' => '',
                'source' => '',
                'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
                'visible' => false,
                'required' => true,
                'user_defined' => false,
                'default' => '',
                'searchable' => false,
                'filterable' => false,
                'comparable' => false,
                'visible_on_front' => false,
                'used_in_product_listing' => false,
                'unique' => false
            ]
        );

        // $eavSetup->removeAttribute(\Magento\Catalog\Model\Product::ENTITY,'facebook_description');
        $eavSetup->addAttribute(
            \Magento\Catalog\Model\Product::ENTITY,
            'facebook_description',
            [
                'group' => '',
                'type' => 'text',
                'backend' => '',
                'frontend' => '',
                'label' => 'Facebook Open Graph Description',
                'input' => 'text',
                'class' => '',
                'source' => '',
                'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
                'visible' => false,
                'required' => true,
                'user_defined' => false,
                'default' => '',
                'searchable' => false,
                'filterable' => false,
                'comparable' => false,
                'visible_on_front' => false,
                'used_in_product_listing' => false,
                'unique' => false
            ]
        );

        // $eavSetup->removeAttribute(\Magento\Catalog\Model\Product::ENTITY,'twitter_title');
        $eavSetup->addAttribute(
            \Magento\Catalog\Model\Product::ENTITY,
            'twitter_title',
            [
                'group' => '',
                'type' => 'varchar',
                'backend' => '',
                'frontend' => '',
                'label' => 'Twitter Card Title',
                'input' => 'text',
                'class' => '',
                'source' => '',
                'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
                'visible' => false,
                'required' => true,
                'user_defined' => false,
                'default' => '',
                'searchable' => false,
                'filterable' => false,
                'comparable' => false,
                'visible_on_front' => false,
                'used_in_product_listing' => false,
                'unique' => false
            ]
        );

        // $eavSetup->removeAttribute(\Magento\Catalog\Model\Product::ENTITY,'twitter_image');
        $eavSetup->addAttribute(
            \Magento\Catalog\Model\Product::ENTITY,
            'twitter_image',
            [
                'group' => '',
                'type' => 'varchar',
                'backend' => '',
                'frontend' => '',
                'label' => 'Twitter Card Image',
                'input' => 'text',
                'class' => '',
                'source' => '',
                'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
                'visible' => false,
                'required' => true,
                'user_defined' => false,
                'default' => '',
                'searchable' => false,
                'filterable' => false,
                'comparable' => false,
                'visible_on_front' => false,
                'used_in_product_listing' => false,
                'unique' => false
            ]
        );

        // $eavSetup->removeAttribute(\Magento\Catalog\Model\Product::ENTITY,'twitter_description');
        $eavSetup->addAttribute(
            \Magento\Catalog\Model\Product::ENTITY,
            'twitter_description',
            [
                'group' => '',
                'type' => 'text',
                'backend' => '',
                'frontend' => '',
                'label' => 'Twitter Card Description',
                'input' => 'text',
                'class' => '',
                'source' => '',
                'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
                'visible' => false,
                'required' => true,
                'user_defined' => false,
                'default' => '',
                'searchable' => false,
                'filterable' => false,
                'comparable' => false,
                'visible_on_front' => false,
                'used_in_product_listing' => false,
                'unique' => false
            ]
        );

        // $eavSetup->removeAttribute(\Magento\Catalog\Model\Category::ENTITY,'category_focus_keyword');
        $eavSetup->addAttribute(
            \Magento\Catalog\Model\Category::ENTITY,
            'category_focus_keyword',
            [
                'group' => '',
                'type' => 'varchar',
                'backend' => '',
                'frontend' => '',
                'label' => 'Focus Keyword',
                'input' => 'text',
                'class' => '',
                'source' => '',
                'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
                'visible' => false,
                'required' => true,
                'user_defined' => false,
                'default' => '',
                'searchable' => false,
                'filterable' => false,
                'comparable' => false,
                'visible_on_front' => false,
                'used_in_product_listing' => false,
                'unique' => false
            ]
        );
    }

    /**
     * {@inheritdoc}
     */
    public static function getDependencies()
    {
        return [];
    }

    /**
     * {@inheritdoc}
     */
    public function getAliases()
    {
        return [];
    }
}
