HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/structura.komma.pro/app/KommaApp/Shop/MigrationsAndSeedsController.php
<?php
namespace App\KommaApp\Shop;

/**
 * Class MigrationsController
 * @package App\KommaApp\Shop
 */
class MigrationsAndSeedsController implements MigrationsAndSeedsControllerInterface
{
    /**
     * Where the migrations are stored
     * @var string $migrationsDirectory
     */
    private $migrationsDirectory;

    /**
     * MigrationsAndSeedsController constructor.
     */
    public function __construct()
    {
        $baseDirectory = DIRECTORY_SEPARATOR.lcfirst(str_replace('\\', DIRECTORY_SEPARATOR,__NAMESPACE__)).DIRECTORY_SEPARATOR;
        $this->migrationsDirectory = $baseDirectory.'migrations';
    }

    /**
     * Run migrations
     */
    public function migrate()
    {
        \Artisan::call('migrate', [
           '--path' => $this->migrationsDirectory,
            '--force' => true
        ]);
        echo \Artisan::output();
    }

    /**
     * Rollback migrations
     *
     * @param null $step
     */
    public function rollback($step = null)
    {
        $command = 'migrate:rollback';
        if($step !== null && is_numeric($step)) $command .= ' --step='.$step;

        \Artisan::call($command, [
            '--path' => $this->migrationsDirectory,
            '--force' => true
        ]);
        echo \Artisan::output();
    }

    /**
     * Initialize the shop
     */
    public function seed()
    {
        $rootSeederFQCN = __NAMESPACE__.'\\Seeds\\DatabaseSeeder';

        \Artisan::call('db:seed', [
            '--class' => $rootSeederFQCN
        ]);
        echo \Artisan::output();
    }
}