File: D:/HostingSpaces/SBogers95/rentman.io/app/Komma/Shop/MigrationsAndSeedsController.php
<?php
namespace App\Komma\Shop;
/**
* Class MigrationsController
*/
class MigrationsAndSeedsController implements MigrationsAndSeedsControllerInterface
{
/**
* Where the migrations are stored
* @var string
*/
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();
}
}