加入新增MenuItemController與Repository的Artisan指令

This commit is contained in:
kroutony 2020-02-23 16:43:34 +08:00
parent 9ebaa6fcd2
commit de7c084c0f
4 changed files with 113 additions and 0 deletions

View File

@ -0,0 +1,43 @@
<?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);
}
}
}

View File

@ -0,0 +1,35 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Console\GeneratorCommand;
class MakeRepository extends GeneratorCommand
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $name = 'make:repository';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Make a repository';
protected $type = 'Repository';
protected function getStub()
{
return __DIR__ . '/stubs/Repository.stub';
}
protected function getDefaultNamespace($rootNamespace)
{
return $rootNamespace . '\Repositories';
}
}

View File

@ -0,0 +1,24 @@
<?php
namespace DummyNamespace;
use App\Http\Controllers\Admin\Menu\BaseMenuItemController;
use Illuminate\Http\Request;
class DummyClass extends BaseMenuItemController
{
public function __construct()
{
$this->name = '';
$this->slug = '';
$this->permissions = [];
$this->iconClasses = 'nav-icon icon-wrench';
}
public function handle(Request $request)
{
}
}

View File

@ -0,0 +1,11 @@
<?php
namespace DummyNamespace;
class DummyClass extends BaseRepository
{
public function __construct()
{
//$this->setModel();
}
}