加入新增MenuItemController與Repository的Artisan指令
This commit is contained in:
parent
9ebaa6fcd2
commit
de7c084c0f
43
app/Console/Commands/MakeMenuItemController.php
Normal file
43
app/Console/Commands/MakeMenuItemController.php
Normal 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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
35
app/Console/Commands/MakeRepository.php
Normal file
35
app/Console/Commands/MakeRepository.php
Normal 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';
|
||||
}
|
||||
}
|
||||
24
app/Console/Commands/stubs/MenuItemController.stub
Normal file
24
app/Console/Commands/stubs/MenuItemController.stub
Normal 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)
|
||||
{
|
||||
}
|
||||
}
|
||||
11
app/Console/Commands/stubs/Repository.stub
Normal file
11
app/Console/Commands/stubs/Repository.stub
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace DummyNamespace;
|
||||
|
||||
class DummyClass extends BaseRepository
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
//$this->setModel();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user