Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/old/app/code/Soon/Faq/Setup/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/app/code/Soon/Faq/Setup/InstallSchema.php
<?php
/**
 * @license http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 * @author Hervé Guétin <[email protected]> <@herveguetin>
 * @copyright Copyright (c) 2016 Agence Soon (http://www.agence-soon.fr)
 */

namespace Soon\Faq\Setup;


use Magento\Framework\DB\Ddl\Table;
use Magento\Framework\Setup\InstallSchemaInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;

class InstallSchema implements InstallSchemaInterface
{
    /**
     * @var SchemaSetupInterface
     */
    private $installer;

    /**
     * Installs DB schema for a module
     *
     * @param SchemaSetupInterface $setup
     * @param ModuleContextInterface $context
     * @return void
     */
    public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
    {
        $this->installer = $setup;
        $this->installer->startSetup();

        $this->createQuestionTable();
        $this->createCategoryTable();
        $this->createCategoryStoreTable();

        $this->installer->endSetup();
    }

    private function createQuestionTable()
    {
        $table = $this->installer->getConnection()
            ->newTable($this->installer->getTable('soon_faq_question'))
            ->addColumn('id', Table::TYPE_SMALLINT, null, [
                'identity' => true,
                'nullable' => false,
                'primary' => true,
            ], 'Question ID')
            ->addColumn('category_id', Table::TYPE_INTEGER, null, [
                'nullable' => false,
            ], 'FAQ Category ID')
            ->addColumn('sort_order', Table::TYPE_INTEGER, null, [
                'nullable' => true,
            ], 'Question Sort Order')
            ->addColumn('question', Table::TYPE_TEXT, null, [
                'nullable' => false,
            ], 'Question')
            ->addColumn('answer', Table::TYPE_TEXT, null, [
                'nullable' => false,
            ], 'Answer')
            ->addColumn('is_active', Table::TYPE_SMALLINT, null, [
                'nullable' => false,
                'default' => '1',
            ], 'Is Question Visible')
            ->addColumn('is_most_frequently_asked', Table::TYPE_SMALLINT, null, [
                'nullable' => false,
                'default' => 0,
            ], 'Is most frequently asked question flag')
            ->setComment('Questions');

        $this->installer->getConnection()->createTable($table);
    }

    private function createCategoryTable()
    {
        $table = $this->installer->getConnection()
            ->newTable($this->installer->getTable('soon_faq_category'))
            ->addColumn('id', Table::TYPE_SMALLINT, null, [
                'identity' => true,
                'nullable' => false,
                'primary' => true,
            ], 'Category Id')
            ->addColumn('name', Table::TYPE_TEXT, null, [
                'nullable' => false,
            ], 'Category Name')
            ->addColumn('is_active', Table::TYPE_SMALLINT, null, [
                'nullable' => false,
                'default' => '1',
            ], 'Is Category Active')
            ->setComment('Categories');

        $this->installer->getConnection()->createTable($table);
    }

    private function createCategoryStoreTable()
    {
        $table = $this->installer->getConnection()
            ->newTable($this->installer->getTable('soon_faq_category_store'))
            ->addColumn('category_id', Table::TYPE_SMALLINT, null, [
                'nullable' => false,
                'primary' => true
            ], 'Category ID')
            ->addColumn('store_id', Table::TYPE_SMALLINT, null, [
                'unsigned' => true,
                'nullable' => false,
                'primary' => true
            ], 'Store ID')
            ->addIndex(
                $this->installer->getIdxName('soon_faq_category_store', ['store_id']),
                ['store_id'])
            ->addForeignKey(
                $this->installer->getFkName('soon_faq_category_store', 'category_id', 'soon_faq_category', 'id'),
                'category_id',
                $this->installer->getTable('soon_faq_category'),
                'id',
                Table::ACTION_CASCADE)
            ->addForeignKey(
                $this->installer->getFkName('soon_faq_category_store', 'store_id', 'store', 'store_id'),
                'store_id',
                $this->installer->getTable('store'),
                'store_id',
                Table::ACTION_CASCADE)
            ->setComment('FAQ category to store linkage table');
        $this->installer->getConnection()->createTable($table);
    }
}

Spamworldpro Mini