cms/app/Console/Commands/MakeMenuItemController.php

44 lines
1.1 KiB
PHP

<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Console\GeneratorCommand;
class MakeMenuItemController extends GeneratorCommand
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $name = 'make:menu-item-controller';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Make an admin menu item controller';
protected $type = 'MenuItemController';
protected function getStub()
{
return __DIR__ . '/stubs/MenuItemController.stub';
}
protected function getDefaultNamespace($rootNamespace)
{
$inputName = $this->getNameInput();
\Log::info($inputName);
if(strpos($inputName, '/') !== false) {
$inputName = explode('/', $inputName);
return $rootNamespace . '\Http\Controllers\Admin\Menu';
} else {
return $rootNamespace . '\Http\Controllers\Admin\Menu\\' . str_replace('MenuItemController', '', $inputName);
}
}
}