first upload all files
This commit is contained in:
249
app/Scaffold/Module/Generators/EntityGenerator.php
Normal file
249
app/Scaffold/Module/Generators/EntityGenerator.php
Normal file
@@ -0,0 +1,249 @@
|
||||
<?php
|
||||
|
||||
namespace FleetCart\Scaffold\Module\Generators;
|
||||
|
||||
use DateTime;
|
||||
|
||||
class EntityGenerator extends Generator
|
||||
{
|
||||
/**
|
||||
* Array of views to be generated.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $views = [
|
||||
'views/index.stub' => 'Resources/views/admin/$ENTITY_NAME$/index.blade.php',
|
||||
'views/create.stub' => 'Resources/views/admin/$ENTITY_NAME$/create.blade.php',
|
||||
'views/edit.stub' => 'Resources/views/admin/$ENTITY_NAME$/edit.blade.php',
|
||||
'views/shortcuts.stub' => 'Resources/views/admin/$ENTITY_NAME$/partials/shortcuts.blade.php',
|
||||
];
|
||||
|
||||
/**
|
||||
* Generate the given entities.
|
||||
*
|
||||
* @param array $entities
|
||||
* @param bool $generateSidebar
|
||||
* @return void
|
||||
*/
|
||||
public function generate(array $entities, $generateSidebar = true)
|
||||
{
|
||||
if (count($entities) !== 0 && $generateSidebar) {
|
||||
$this->generateSidebarExtender($entities);
|
||||
}
|
||||
|
||||
foreach ($entities as $entity) {
|
||||
$this->appendPermissions($entity);
|
||||
$this->generateMigrations($entity);
|
||||
$this->generateEntity($entity);
|
||||
$this->generateController($entity);
|
||||
$this->generateRequests($entity);
|
||||
$this->generateLang($entity);
|
||||
$this->generateViews($entity);
|
||||
$this->appendRoutes($entity);
|
||||
$this->appendSidebarExtender($entity);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a filled sidebar view composer
|
||||
* Or an empty one of no entities.
|
||||
*
|
||||
* @param $entities
|
||||
* @return void
|
||||
*/
|
||||
private function generateSidebarExtender($entities)
|
||||
{
|
||||
return $this->finder->put(
|
||||
$this->getModulesPath('Sidebar/SidebarExtender.php'),
|
||||
$this->getContentForStub('sidebar/sidebar-extender.stub', $entities[0])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Append permissions.
|
||||
*
|
||||
* @param string $entity
|
||||
* @return void
|
||||
*/
|
||||
private function appendPermissions($entity)
|
||||
{
|
||||
$permissionsContent = $this->finder->get($this->getModulesPath('Config/permissions.php'));
|
||||
|
||||
$this->finder->put(
|
||||
$this->getModulesPath('Config/permissions.php'),
|
||||
str_replace('// append', $this->getContentForStub('config/permissions-append.stub', $entity), $permissionsContent)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate migrations file for eloquent entities.
|
||||
*
|
||||
* @param string $entity
|
||||
* @return void
|
||||
*/
|
||||
private function generateMigrations($entity)
|
||||
{
|
||||
$entityName = snake_case(str_plural($entity));
|
||||
$migrationFileName = $this->getDateTimePrefix() . "create_{$entityName}_table.php";
|
||||
|
||||
$this->finder->put(
|
||||
$this->getModulesPath("Database/Migrations/{$migrationFileName}"),
|
||||
$this->getContentForStub('migrations/create-table-migration.stub', $entity)
|
||||
);
|
||||
|
||||
$migrationFileName = $this->getDateTimePrefix() . 'create_' . str_singular($entityName) . '_translations_table.php';
|
||||
|
||||
$this->finder->put(
|
||||
$this->getModulesPath("Database/Migrations/{$migrationFileName}"),
|
||||
$this->getContentForStub('migrations/create-translation-table-migration.stub', $entity)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current time with microseconds.
|
||||
*
|
||||
* @return string
|
||||
* @return void
|
||||
*/
|
||||
private function getDateTimePrefix()
|
||||
{
|
||||
$time = microtime(true);
|
||||
$micro = sprintf('%06d', ($time - floor($time)) * 1000000);
|
||||
$date = new DateTime(date('Y-m-d H:i:s.' . $micro, $time));
|
||||
|
||||
return $date->format('Y_m_d_Hisu_');
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate entity.
|
||||
*
|
||||
* @param string $entity
|
||||
* @return void
|
||||
*/
|
||||
private function generateEntity($entity)
|
||||
{
|
||||
$this->finder->put(
|
||||
$this->getModulesPath("Entities/{$entity}.php"),
|
||||
$this->getContentForStub('entities/entity.stub', $entity)
|
||||
);
|
||||
|
||||
$this->finder->put(
|
||||
$this->getModulesPath("Entities/{$entity}Translation.php"),
|
||||
$this->getContentForStub('entities/translation-entity.stub', $entity)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the controller for the given entity.
|
||||
*
|
||||
* @param string $entity
|
||||
* @return void
|
||||
*/
|
||||
private function generateController($entity)
|
||||
{
|
||||
$this->createDirectory('Http/Controllers/Admin');
|
||||
|
||||
$this->finder->put(
|
||||
$this->getModulesPath("Http/Controllers/Admin/{$entity}Controller.php"),
|
||||
$this->getContentForStub('admin-controller.stub', $entity)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the requests for the given entity.
|
||||
*
|
||||
* @param string $entity
|
||||
* @return void
|
||||
*/
|
||||
private function generateRequests($entity)
|
||||
{
|
||||
$this->createDirectory('Http/Requests');
|
||||
|
||||
$this->finder->put(
|
||||
$this->getModulesPath("Http/Requests/Save{$entity}Request.php"),
|
||||
$this->getContentForStub('save-entity-request.stub', $entity)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate views for the given entity.
|
||||
*
|
||||
* @param string $entity
|
||||
* @return void
|
||||
*/
|
||||
private function generateViews($entity)
|
||||
{
|
||||
$entityName = snake_case(str_plural($entity));
|
||||
|
||||
$this->createDirectory("Resources/views/admin/{$entityName}/partials");
|
||||
|
||||
foreach ($this->views as $stub => $view) {
|
||||
$view = str_replace('$ENTITY_NAME$', $entityName, $view);
|
||||
|
||||
$this->finder->put(
|
||||
$this->getModulesPath($view),
|
||||
$this->getContentForStub($stub, $entity)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate language files for the given entity.
|
||||
*
|
||||
* @param string $entity
|
||||
* @return void
|
||||
*/
|
||||
private function generateLang($entity)
|
||||
{
|
||||
$this->createDirectory('Resources/lang/en');
|
||||
|
||||
$entityName = snake_case(str_plural($entity));
|
||||
|
||||
$this->finder->put(
|
||||
$this->getModulesPath("Resources/lang/en/{$entityName}.php"),
|
||||
$this->getContentForStub('lang/entity.stub', $entity)
|
||||
);
|
||||
|
||||
$this->finder->put(
|
||||
$this->getModulesPath('Resources/lang/en/permissions.php'),
|
||||
$this->getContentForStub('lang/permissions.stub', $entity)
|
||||
);
|
||||
|
||||
$this->finder->put(
|
||||
$this->getModulesPath('Resources/lang/en/attributes.php'),
|
||||
$this->getContentForStub('lang/attributes.stub', $entity)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Append the routes for the given entity to the routes file.
|
||||
*
|
||||
* @param string $entity
|
||||
* @return void
|
||||
*/
|
||||
private function appendRoutes($entity)
|
||||
{
|
||||
$routeContent = $this->finder->get($this->getModulesPath('Routes/admin.php'));
|
||||
|
||||
$this->finder->put(
|
||||
$this->getModulesPath('Routes/admin.php'),
|
||||
str_replace('// append', $this->getContentForStub('routes/routes-append.stub', $entity), $routeContent)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Append sidebar extender.
|
||||
*
|
||||
* @param string $entity
|
||||
* @return void
|
||||
*/
|
||||
private function appendSidebarExtender($entity)
|
||||
{
|
||||
$sidebarComposerContent = $this->finder->get($this->getModulesPath('Sidebar/SidebarExtender.php'));
|
||||
|
||||
$this->finder->put(
|
||||
$this->getModulesPath('Sidebar/SidebarExtender.php'),
|
||||
str_replace('// append', $this->getContentForStub('sidebar/sidebar-extender-append.stub', $entity), $sidebarComposerContent)
|
||||
);
|
||||
}
|
||||
}
|
||||
58
app/Scaffold/Module/Generators/FilesGenerator.php
Normal file
58
app/Scaffold/Module/Generators/FilesGenerator.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace FleetCart\Scaffold\Module\Generators;
|
||||
|
||||
use Illuminate\Contracts\Filesystem\FileNotFoundException;
|
||||
|
||||
class FilesGenerator extends Generator
|
||||
{
|
||||
/**
|
||||
* Generate the given files.
|
||||
*
|
||||
* @param array $files
|
||||
* @return void
|
||||
*/
|
||||
public function generate(array $files)
|
||||
{
|
||||
foreach ($files as $stub => $file) {
|
||||
$this->finder->put(
|
||||
$this->getModulesPath($file),
|
||||
$this->getContentFor($stub)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the base module service provider.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function generateModuleProvider()
|
||||
{
|
||||
$this->finder->put(
|
||||
$this->getModulesPath("Providers/{$this->name}ServiceProvider.php"),
|
||||
$this->getContentFor('providers/module-service-provider.stub')
|
||||
);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the content for the given file.
|
||||
*
|
||||
* @param string $stub
|
||||
* @return string
|
||||
*
|
||||
* @throws FileNotFoundException
|
||||
*/
|
||||
private function getContentFor($stub)
|
||||
{
|
||||
$stub = $this->finder->get($this->getStubPath($stub));
|
||||
|
||||
return str_replace(
|
||||
['$MODULE$', '$LOWERCASE_MODULE$', '$PLURAL_MODULE$', '$UPPERCASE_PLURAL_MODULE$'],
|
||||
[$this->name, strtolower($this->name), strtolower(str_plural($this->name)), str_plural($this->name)],
|
||||
$stub
|
||||
);
|
||||
}
|
||||
}
|
||||
134
app/Scaffold/Module/Generators/Generator.php
Normal file
134
app/Scaffold/Module/Generators/Generator.php
Normal file
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
namespace FleetCart\Scaffold\Module\Generators;
|
||||
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
|
||||
abstract class Generator
|
||||
{
|
||||
/**
|
||||
* The instance of Filesystem.
|
||||
*
|
||||
* @var \Illuminate\Filesystem\Filesystem
|
||||
*/
|
||||
protected $finder;
|
||||
|
||||
/**
|
||||
* Name of the module.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param \Illuminate\Filesystem\Filesystem $finder
|
||||
*/
|
||||
public function __construct(Filesystem $finder)
|
||||
{
|
||||
$this->finder = $finder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the given files.
|
||||
*
|
||||
* @param array $files
|
||||
* @return void
|
||||
*/
|
||||
abstract public function generate(array $files);
|
||||
|
||||
/**
|
||||
* Set the module name.
|
||||
*
|
||||
* @param string $name
|
||||
* @return $this
|
||||
*/
|
||||
public function module($name)
|
||||
{
|
||||
$this->name = ucfirst($name);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current module path.
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
protected function getModulesPath($path = '')
|
||||
{
|
||||
return config('modules.paths.modules') . "/{$this->name}/{$path}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Create directory if not exists.
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
protected function createDirectory($path)
|
||||
{
|
||||
$path = $this->getModulesPath($path);
|
||||
|
||||
if (! $this->finder->isDirectory($path)) {
|
||||
$this->finder->makeDirectory($path, 0755, true);
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get stub path for the given stub file.
|
||||
*
|
||||
* @param string $filename
|
||||
* @return string
|
||||
*/
|
||||
protected function getStubPath($filename)
|
||||
{
|
||||
return __DIR__ . "/../stubs/{$filename}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content of the given stub.
|
||||
*
|
||||
* @param string $stub
|
||||
* @param string $class
|
||||
* @return string
|
||||
*/
|
||||
protected function getContentForStub($stub, $class = '')
|
||||
{
|
||||
$stub = $this->finder->get($this->getStubPath($stub));
|
||||
|
||||
return str_replace([
|
||||
'$MODULE_NAME$',
|
||||
'$LOWERCASE_MODULE_NAME$',
|
||||
'$LCFIRST_ENTITY_NAME$',
|
||||
'$ENTITY_NAME$',
|
||||
'$LOWERCASE_ENTITY_NAME$',
|
||||
'$TITLE_CASE_ENTITY_NAME$',
|
||||
'$SNAKE_CASE_ENTITY_NAME$',
|
||||
'$KEBAB_CASE_ENTITY_NAME$',
|
||||
'$PLURAL_ENTITY_NAME$',
|
||||
'$PLURAL_LOWERCASE_ENTITY_NAME$',
|
||||
'$PLURAL_TITLE_CASE_ENTITY_NAME$',
|
||||
'$PLURAL_SNAKE_CASE_ENTITY_NAME$',
|
||||
'$PLURAL_KEBAB_CASE_ENTITY_NAME$',
|
||||
], [
|
||||
$this->name,
|
||||
strtolower($this->name),
|
||||
lcfirst($class),
|
||||
$class,
|
||||
strtolower($class),
|
||||
title_case(str_replace('_', ' ', snake_case($class))),
|
||||
snake_case($class),
|
||||
kebab_case($class),
|
||||
str_plural($class),
|
||||
str_plural(strtolower($class)),
|
||||
title_case(str_replace('_', ' ', snake_case(str_plural($class)))),
|
||||
snake_case(str_plural($class)),
|
||||
kebab_case(str_plural($class)),
|
||||
], $stub);
|
||||
}
|
||||
}
|
||||
333
app/Scaffold/Module/ModuleScaffold.php
Normal file
333
app/Scaffold/Module/ModuleScaffold.php
Normal file
@@ -0,0 +1,333 @@
|
||||
<?php
|
||||
|
||||
namespace FleetCart\Scaffold\Module;
|
||||
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use FleetCart\Scaffold\Module\Generators\FilesGenerator;
|
||||
use FleetCart\Scaffold\Module\Generators\EntityGenerator;
|
||||
|
||||
class ModuleScaffold
|
||||
{
|
||||
/**
|
||||
* The vendor name of the module.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $vendor;
|
||||
|
||||
/**
|
||||
* The module name which will be generated.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* The instance of Filesystem.
|
||||
*
|
||||
* @var \Illuminate\Filesystem\Filesystem
|
||||
*/
|
||||
private $finder;
|
||||
|
||||
/**
|
||||
* The instance of EntityGenerator.
|
||||
*
|
||||
* @var \FleetCart\Scaffold\Module\Generators\EntityGenerator
|
||||
*/
|
||||
private $entityGenerator;
|
||||
|
||||
/**
|
||||
* The instance of FilesGenerator.
|
||||
*
|
||||
* @var \FleetCart\Scaffold\Module\Generators\FilesGenerator
|
||||
*/
|
||||
private $filesGenerator;
|
||||
|
||||
/**
|
||||
* Array of files to be generated.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $files = [
|
||||
'config/assets.stub' => 'Config/assets.php',
|
||||
'config/permissions.stub' => 'Config/permissions.php',
|
||||
'routes/routes.stub' => 'Routes/admin.php',
|
||||
];
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param \Illuminate\Filesystem\Filesystem $finder
|
||||
* @param \FleetCart\Scaffold\Module\Generators\EntityGenerator $entityGenerator
|
||||
* @param \FleetCart\Scaffold\Module\Generators\FilesGenerator $filesGenerator
|
||||
*/
|
||||
public function __construct(Filesystem $finder, EntityGenerator $entityGenerator, FilesGenerator $filesGenerator)
|
||||
{
|
||||
$this->finder = $finder;
|
||||
$this->entityGenerator = $entityGenerator;
|
||||
$this->filesGenerator = $filesGenerator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $module
|
||||
* @param array $entities
|
||||
* @return void
|
||||
*/
|
||||
public function scaffold(array $module, array $entities)
|
||||
{
|
||||
$this->vendor = $module['vendor'];
|
||||
$this->name = $module['name'];
|
||||
|
||||
Artisan::call('module:make', ['name' => [$this->name]]);
|
||||
|
||||
$this->addFolders();
|
||||
$this->removeUnneededFiles();
|
||||
$this->addDataToComposerJsonFile();
|
||||
|
||||
$this->filesGenerator->module($this->name)
|
||||
->generateModuleProvider()
|
||||
->generate($this->files);
|
||||
|
||||
$this->addDataToModuleJson();
|
||||
$this->cleanupModuleJsonFile();
|
||||
|
||||
$this->entityGenerator->module($this->getName())->generate($entities);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get studly cased module name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return studly_case($this->name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path on the module.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getModulesPath($path = '')
|
||||
{
|
||||
return config('modules.paths.modules') . "/{$this->getName()}/{$path}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the paths on the module.
|
||||
*
|
||||
* @param array $paths
|
||||
* @return array
|
||||
*/
|
||||
private function getModulesPaths(array $paths)
|
||||
{
|
||||
$list = [];
|
||||
|
||||
foreach ($paths as $path) {
|
||||
$list[] = $this->getModulesPath($path);
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove vendor name from composer.json file.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function renameVendorName()
|
||||
{
|
||||
$composerJsonContent = $this->finder->get($this->getModulesPath('composer.json'));
|
||||
$composerJsonContent = str_replace('nwidart', $this->vendor, $composerJsonContent);
|
||||
|
||||
$this->finder->put($this->getModulesPath('composer.json'), $composerJsonContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove view files.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function removeViewFiles()
|
||||
{
|
||||
$this->finder->delete($this->getModulesPath('Resources/views/index.blade.php'));
|
||||
$this->finder->delete($this->getModulesPath('Resources/views/layouts/master.blade.php'));
|
||||
$this->finder->deleteDirectory($this->getModulesPath('Resources/views/layouts'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add required folders.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function addFolders()
|
||||
{
|
||||
$this->finder->makeDirectory($this->getModulesPath('Sidebar'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove unneeded files and folders.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function removeUnneededFiles()
|
||||
{
|
||||
$this->renameVendorName();
|
||||
$this->removeViewFiles();
|
||||
|
||||
$this->finder->deleteDirectory($this->getModulesPath('Database/factories'));
|
||||
$this->finder->deleteDirectory($this->getModulesPath('Database/Seeders'));
|
||||
$this->finder->deleteDirectory($this->getModulesPath('Events'));
|
||||
$this->finder->deleteDirectory($this->getModulesPath('Console'));
|
||||
$this->finder->deleteDirectory($this->getModulesPath('Http/Middleware'));
|
||||
$this->finder->deleteDirectory($this->getModulesPath('Jobs'));
|
||||
$this->finder->deleteDirectory($this->getModulesPath('Mail'));
|
||||
$this->finder->deleteDirectory($this->getModulesPath('Resources/assets'));
|
||||
$this->finder->deleteDirectory($this->getModulesPath('Tests'));
|
||||
|
||||
$files = $this->getModulesPaths([
|
||||
'Config/.gitkeep',
|
||||
'Config/config.php',
|
||||
'Entities/.gitkeep',
|
||||
'Database/Migrations/.gitkeep',
|
||||
'Http/Controllers/.gitkeep',
|
||||
'Http/Requests/.gitkeep',
|
||||
"Http/Controllers/{$this->name}Controller.php",
|
||||
'Providers/.gitkeep',
|
||||
'Providers/RouteServiceProvider.php',
|
||||
'Resources/lang/.gitkeep',
|
||||
'Resources/views/.gitkeep',
|
||||
'Routes/.gitkeep',
|
||||
'Routes/web.php',
|
||||
'Routes/api.php',
|
||||
'package.json',
|
||||
'webpack.mix.js',
|
||||
]);
|
||||
|
||||
$this->finder->delete($files);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add data to module.json file.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function addDataToModuleJson()
|
||||
{
|
||||
$moduleJson = $this->finder->get($this->getModulesPath('module.json'));
|
||||
|
||||
$moduleJson = $this->setModulePriority($moduleJson);
|
||||
|
||||
$this->finder->put($this->getModulesPath('module.json'), $moduleJson);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the module priority for composer.json file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function setModulePriority($content)
|
||||
{
|
||||
return str_replace('"priority": 0,', '"priority": 100,', $content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove unneeded data from module.json file.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function cleanupModuleJsonFile()
|
||||
{
|
||||
$moduleJson = $this->finder->get($this->getModulesPath('module.json'));
|
||||
|
||||
$moduleName = ucfirst($this->name);
|
||||
|
||||
// Update module description.
|
||||
$search = <<<JSON
|
||||
"description": "",
|
||||
JSON;
|
||||
|
||||
$replace = <<<JSON
|
||||
"description": "The FleetCart {$moduleName} Module.",
|
||||
JSON;
|
||||
|
||||
$moduleJson = str_replace($search, $replace, $moduleJson);
|
||||
|
||||
// Remove "keywords" node.
|
||||
$search = <<<JSON
|
||||
"keywords": [],
|
||||
JSON;
|
||||
|
||||
$moduleJson = str_replace($search, '', $moduleJson);
|
||||
|
||||
// Remove unneeded nodes.
|
||||
$search = <<<JSON
|
||||
],
|
||||
"aliases": {},
|
||||
"files": [],
|
||||
"requires": []
|
||||
JSON;
|
||||
|
||||
$moduleJson = str_replace($search, ']', $moduleJson);
|
||||
|
||||
$this->finder->put($this->getModulesPath('module.json'), $moduleJson);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add data to composer.json file.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function addDataToComposerJsonFile()
|
||||
{
|
||||
$composerJson = $this->finder->get($this->getModulesPath('composer.json'));
|
||||
|
||||
$moduleName = ucfirst($this->name);
|
||||
|
||||
$composerJsonText = '';
|
||||
|
||||
foreach (explode(PHP_EOL, $composerJson) as $lineNumber => $textLine) {
|
||||
if ($lineNumber === 2) {
|
||||
$composerJsonText .= " \"description\": \"The FleetCart {$moduleName} Module.\"," . PHP_EOL;
|
||||
|
||||
continue;
|
||||
} elseif ($lineNumber >= 9 && $lineNumber <= 23) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$composerJsonText .= $textLine . PHP_EOL;
|
||||
}
|
||||
|
||||
$search = <<<JSON
|
||||
],
|
||||
JSON;
|
||||
|
||||
$replace = <<<JSON
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.3.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Modules\\\\{$moduleName}\\\\": ""
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
},
|
||||
"minimum-stability": "dev"
|
||||
}
|
||||
JSON;
|
||||
|
||||
$composerJson = str_replace($search, $replace, $composerJsonText);
|
||||
|
||||
$this->finder->put($this->getModulesPath('composer.json'), $composerJson);
|
||||
}
|
||||
}
|
||||
41
app/Scaffold/Module/stubs/admin-controller.stub
Normal file
41
app/Scaffold/Module/stubs/admin-controller.stub
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\$MODULE_NAME$\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Routing\Controller;
|
||||
use Modules\Admin\Traits\HasCrudActions;
|
||||
use Modules\$MODULE_NAME$\Entities\$ENTITY_NAME$;
|
||||
use Modules\$MODULE_NAME$\Http\Requests\Save$ENTITY_NAME$Request;
|
||||
|
||||
class $ENTITY_NAME$Controller extends Controller
|
||||
{
|
||||
use HasCrudActions;
|
||||
|
||||
/**
|
||||
* Model for the resource.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = $ENTITY_NAME$::class;
|
||||
|
||||
/**
|
||||
* Label of the resource.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $label = '$LOWERCASE_MODULE_NAME$::$PLURAL_SNAKE_CASE_ENTITY_NAME$.$SNAKE_CASE_ENTITY_NAME$';
|
||||
|
||||
/**
|
||||
* View path of the resource.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $viewPath = '$LOWERCASE_MODULE_NAME$::admin.$PLURAL_SNAKE_CASE_ENTITY_NAME$';
|
||||
|
||||
/**
|
||||
* Form requests for the resource.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $validation = Save$ENTITY_NAME$Request::class;
|
||||
}
|
||||
22
app/Scaffold/Module/stubs/config/assets.stub
Normal file
22
app/Scaffold/Module/stubs/config/assets.stub
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Define which assets will be available through the asset manager
|
||||
|--------------------------------------------------------------------------
|
||||
| These assets are registered on the asset manager
|
||||
*/
|
||||
'all_assets' => [
|
||||
'admin.$LOWERCASE_MODULE$.css' => ['module' => '$LOWERCASE_MODULE$:admin/css/$LOWERCASE_MODULE$.css'],
|
||||
'admin.$LOWERCASE_MODULE$.js' => ['module' => '$LOWERCASE_MODULE$:admin/js/$LOWERCASE_MODULE$.js'],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Define which default assets will always be included in your pages
|
||||
| through the asset pipeline
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'required_assets' => [],
|
||||
];
|
||||
8
app/Scaffold/Module/stubs/config/permissions-append.stub
Normal file
8
app/Scaffold/Module/stubs/config/permissions-append.stub
Normal file
@@ -0,0 +1,8 @@
|
||||
'admin.$PLURAL_SNAKE_CASE_ENTITY_NAME$' => [
|
||||
'index' => '$LOWERCASE_MODULE_NAME$::permissions.index',
|
||||
'create' => '$LOWERCASE_MODULE_NAME$::permissions.create',
|
||||
'edit' => '$LOWERCASE_MODULE_NAME$::permissions.edit',
|
||||
'destroy' => '$LOWERCASE_MODULE_NAME$::permissions.destroy',
|
||||
],
|
||||
|
||||
// append
|
||||
5
app/Scaffold/Module/stubs/config/permissions.stub
Normal file
5
app/Scaffold/Module/stubs/config/permissions.stub
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
// append
|
||||
];
|
||||
39
app/Scaffold/Module/stubs/entities/entity.stub
Normal file
39
app/Scaffold/Module/stubs/entities/entity.stub
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\$MODULE_NAME$\Entities;
|
||||
|
||||
use Modules\Support\Eloquent\Model;
|
||||
use Modules\Support\Eloquent\Translatable;
|
||||
|
||||
class $ENTITY_NAME$ extends Model
|
||||
{
|
||||
use Translatable;
|
||||
|
||||
/**
|
||||
* The relations to eager load on every query.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $with = ['translations'];
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [];
|
||||
|
||||
/**
|
||||
* The attributes that are translatable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $translatedAttributes = [];
|
||||
}
|
||||
15
app/Scaffold/Module/stubs/entities/translation-entity.stub
Normal file
15
app/Scaffold/Module/stubs/entities/translation-entity.stub
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\$MODULE_NAME$\Entities;
|
||||
|
||||
use Modules\Support\Eloquent\TranslationModel;
|
||||
|
||||
class $ENTITY_NAME$Translation extends TranslationModel
|
||||
{
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [];
|
||||
}
|
||||
5
app/Scaffold/Module/stubs/lang/attributes.stub
Normal file
5
app/Scaffold/Module/stubs/lang/attributes.stub
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
//
|
||||
];
|
||||
6
app/Scaffold/Module/stubs/lang/entity.stub
Normal file
6
app/Scaffold/Module/stubs/lang/entity.stub
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'$SNAKE_CASE_ENTITY_NAME$' => '$TITLE_CASE_ENTITY_NAME$',
|
||||
'$PLURAL_SNAKE_CASE_ENTITY_NAME$' => '$PLURAL_TITLE_CASE_ENTITY_NAME$',
|
||||
];
|
||||
8
app/Scaffold/Module/stubs/lang/permissions.stub
Normal file
8
app/Scaffold/Module/stubs/lang/permissions.stub
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'index' => 'Index $TITLE_CASE_ENTITY_NAME$',
|
||||
'create' => 'Create $TITLE_CASE_ENTITY_NAME$',
|
||||
'edit' => 'Edit $TITLE_CASE_ENTITY_NAME$',
|
||||
'destroy' => 'Delete $TITLE_CASE_ENTITY_NAME$',
|
||||
];
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class Create$PLURAL_ENTITY_NAME$Table extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('$PLURAL_SNAKE_CASE_ENTITY_NAME$', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('$PLURAL_SNAKE_CASE_ENTITY_NAME$');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class Create$ENTITY_NAME$TranslationsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('$SNAKE_CASE_ENTITY_NAME$_translations', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('$SNAKE_CASE_ENTITY_NAME$_id')->unsigned();
|
||||
$table->string('locale');
|
||||
|
||||
$table->unique(['$SNAKE_CASE_ENTITY_NAME$_id', 'locale']);
|
||||
$table->foreign('$SNAKE_CASE_ENTITY_NAME$_id')->references('id')->on('$PLURAL_SNAKE_CASE_ENTITY_NAME$')->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('$SNAKE_CASE_ENTITY_NAME$_translations');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\$MODULE$\Providers;
|
||||
|
||||
use Modules\Support\Traits\AddsAsset;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class $MODULE$ServiceProvider extends ServiceProvider
|
||||
{
|
||||
use AddsAsset;
|
||||
|
||||
/**
|
||||
* Bootstrap the application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
37
app/Scaffold/Module/stubs/routes/routes-append.stub
Normal file
37
app/Scaffold/Module/stubs/routes/routes-append.stub
Normal file
@@ -0,0 +1,37 @@
|
||||
Route::get('$PLURAL_KEBAB_CASE_ENTITY_NAME$', [
|
||||
'as' => 'admin.$PLURAL_SNAKE_CASE_ENTITY_NAME$.index',
|
||||
'uses' => '$ENTITY_NAME$Controller@index',
|
||||
'middleware' => 'can:admin.$PLURAL_SNAKE_CASE_ENTITY_NAME$.index',
|
||||
]);
|
||||
|
||||
Route::get('$PLURAL_KEBAB_CASE_ENTITY_NAME$/create', [
|
||||
'as' => 'admin.$PLURAL_SNAKE_CASE_ENTITY_NAME$.create',
|
||||
'uses' => '$ENTITY_NAME$Controller@create',
|
||||
'middleware' => 'can:admin.$PLURAL_SNAKE_CASE_ENTITY_NAME$.create',
|
||||
]);
|
||||
|
||||
Route::post('$PLURAL_KEBAB_CASE_ENTITY_NAME$', [
|
||||
'as' => 'admin.$PLURAL_SNAKE_CASE_ENTITY_NAME$.store',
|
||||
'uses' => '$ENTITY_NAME$Controller@store',
|
||||
'middleware' => 'can:admin.$PLURAL_SNAKE_CASE_ENTITY_NAME$.create',
|
||||
]);
|
||||
|
||||
Route::get('$PLURAL_KEBAB_CASE_ENTITY_NAME$/{id}/edit', [
|
||||
'as' => 'admin.$PLURAL_SNAKE_CASE_ENTITY_NAME$.edit',
|
||||
'uses' => '$ENTITY_NAME$Controller@edit',
|
||||
'middleware' => 'can:admin.$PLURAL_SNAKE_CASE_ENTITY_NAME$.edit',
|
||||
]);
|
||||
|
||||
Route::put('$PLURAL_KEBAB_CASE_ENTITY_NAME$/{id}', [
|
||||
'as' => 'admin.$PLURAL_SNAKE_CASE_ENTITY_NAME$.update',
|
||||
'uses' => '$ENTITY_NAME$Controller@update',
|
||||
'middleware' => 'can:admin.$PLURAL_SNAKE_CASE_ENTITY_NAME$.edit',
|
||||
]);
|
||||
|
||||
Route::delete('$PLURAL_KEBAB_CASE_ENTITY_NAME$/{ids?}', [
|
||||
'as' => 'admin.$PLURAL_SNAKE_CASE_ENTITY_NAME$.destroy',
|
||||
'uses' => '$ENTITY_NAME$Controller@destroy',
|
||||
'middleware' => 'can:admin.$PLURAL_SNAKE_CASE_ENTITY_NAME$.destroy',
|
||||
]);
|
||||
|
||||
// append
|
||||
5
app/Scaffold/Module/stubs/routes/routes.stub
Normal file
5
app/Scaffold/Module/stubs/routes/routes.stub
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
// append
|
||||
25
app/Scaffold/Module/stubs/save-entity-request.stub
Normal file
25
app/Scaffold/Module/stubs/save-entity-request.stub
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\$MODULE_NAME$\Http\Requests;
|
||||
|
||||
use Modules\Core\Http\Requests\Request;
|
||||
|
||||
class Save$ENTITY_NAME$Request extends Request
|
||||
{
|
||||
/**
|
||||
* Available attributes.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $availableAttributes = '$LOWERCASE_MODULE_NAME$::attributes';
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
$item->item(trans('$LOWERCASE_MODULE_NAME$::$PLURAL_SNAKE_CASE_ENTITY_NAME$.$PLURAL_SNAKE_CASE_ENTITY_NAME$'), function (Item $item) {
|
||||
$item->weight(5);
|
||||
$item->route('admin.$PLURAL_SNAKE_CASE_ENTITY_NAME$.index');
|
||||
$item->authorize(
|
||||
$this->auth->hasAccess('admin.$PLURAL_SNAKE_CASE_ENTITY_NAME$.index')
|
||||
);
|
||||
});
|
||||
|
||||
// append
|
||||
26
app/Scaffold/Module/stubs/sidebar/sidebar-extender.stub
Normal file
26
app/Scaffold/Module/stubs/sidebar/sidebar-extender.stub
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\$MODULE_NAME$\Sidebar;
|
||||
|
||||
use Maatwebsite\Sidebar\Menu;
|
||||
use Maatwebsite\Sidebar\Item;
|
||||
use Maatwebsite\Sidebar\Group;
|
||||
use Modules\Admin\Sidebar\BaseSidebarExtender;
|
||||
|
||||
class SidebarExtender extends BaseSidebarExtender
|
||||
{
|
||||
public function extend(Menu $menu)
|
||||
{
|
||||
$menu->group(trans('admin::sidebar.content'), function (Group $group) {
|
||||
$group->item(trans('$LOWERCASE_MODULE_NAME$::$PLURAL_SNAKE_CASE_ENTITY_NAME$.$PLURAL_SNAKE_CASE_ENTITY_NAME$'), function (Item $item) {
|
||||
$item->icon('fa fa-copy');
|
||||
$item->weight(0);
|
||||
$item->authorize(
|
||||
/* append */
|
||||
);
|
||||
|
||||
// append
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
16
app/Scaffold/Module/stubs/views/create.stub
Normal file
16
app/Scaffold/Module/stubs/views/create.stub
Normal file
@@ -0,0 +1,16 @@
|
||||
@extends('admin::layout')
|
||||
|
||||
@component('admin::components.page.header')
|
||||
@slot('title', trans('admin::resource.create', ['resource' => trans('$LOWERCASE_MODULE_NAME$::$PLURAL_SNAKE_CASE_ENTITY_NAME$.$SNAKE_CASE_ENTITY_NAME$')]))
|
||||
|
||||
<li><a href="{{ route('admin.$PLURAL_SNAKE_CASE_ENTITY_NAME$.index') }}">{{ trans('$LOWERCASE_MODULE_NAME$::$PLURAL_SNAKE_CASE_ENTITY_NAME$.$PLURAL_SNAKE_CASE_ENTITY_NAME$') }}</a></li>
|
||||
<li class="active">{{ trans('admin::resource.create', ['resource' => trans('$LOWERCASE_MODULE_NAME$::$PLURAL_SNAKE_CASE_ENTITY_NAME$.$SNAKE_CASE_ENTITY_NAME$')]) }}</li>
|
||||
@endcomponent
|
||||
|
||||
@section('content')
|
||||
<form method="POST" action="{{ route('admin.$PLURAL_SNAKE_CASE_ENTITY_NAME$.store') }}" class="form-horizontal" id="$KEBAB_CASE_ENTITY_NAME$-create-form" novalidate>
|
||||
{{ csrf_field() }}
|
||||
</form>
|
||||
@endsection
|
||||
|
||||
@include('$LOWERCASE_MODULE_NAME$::admin.$PLURAL_SNAKE_CASE_ENTITY_NAME$.partials.shortcuts')
|
||||
18
app/Scaffold/Module/stubs/views/edit.stub
Normal file
18
app/Scaffold/Module/stubs/views/edit.stub
Normal file
@@ -0,0 +1,18 @@
|
||||
@extends('admin::layout')
|
||||
|
||||
@component('admin::components.page.header')
|
||||
@slot('title', trans('admin::resource.edit', ['resource' => trans('$LOWERCASE_MODULE_NAME$::$PLURAL_SNAKE_CASE_ENTITY_NAME$.$SNAKE_CASE_ENTITY_NAME$')]))
|
||||
@slot('subtitle', '')
|
||||
|
||||
<li><a href="{{ route('admin.$PLURAL_SNAKE_CASE_ENTITY_NAME$.index') }}">{{ trans('$LOWERCASE_MODULE_NAME$::$PLURAL_SNAKE_CASE_ENTITY_NAME$.$PLURAL_SNAKE_CASE_ENTITY_NAME$') }}</a></li>
|
||||
<li class="active">{{ trans('admin::resource.edit', ['resource' => trans('$LOWERCASE_MODULE_NAME$::$PLURAL_SNAKE_CASE_ENTITY_NAME$.$SNAKE_CASE_ENTITY_NAME$')]) }}</li>
|
||||
@endcomponent
|
||||
|
||||
@section('content')
|
||||
<form method="POST" action="{{ route('admin.$PLURAL_SNAKE_CASE_ENTITY_NAME$.update', $$LCFIRST_ENTITY_NAME$) }}" class="form-horizontal" id="$KEBAB_CASE_ENTITY_NAME$-edit-form" novalidate>
|
||||
{{ csrf_field() }}
|
||||
{{ method_field('put') }}
|
||||
</form>
|
||||
@endsection
|
||||
|
||||
@include('$LOWERCASE_MODULE_NAME$::admin.$PLURAL_SNAKE_CASE_ENTITY_NAME$.partials.shortcuts')
|
||||
1
app/Scaffold/Module/stubs/views/fields.stub
Normal file
1
app/Scaffold/Module/stubs/views/fields.stub
Normal file
@@ -0,0 +1 @@
|
||||
@include('$LOWERCASE_MODULE_NAME$::$PLURAL_SNAKE_CASE_ENTITY_NAME$.$LOWERCASE_ENTITY_NAME$.partials.shortcuts')
|
||||
32
app/Scaffold/Module/stubs/views/index.stub
Normal file
32
app/Scaffold/Module/stubs/views/index.stub
Normal file
@@ -0,0 +1,32 @@
|
||||
@extends('admin::layout')
|
||||
|
||||
@component('admin::components.page.header')
|
||||
@slot('title', trans('$LOWERCASE_MODULE_NAME$::$PLURAL_SNAKE_CASE_ENTITY_NAME$.$PLURAL_SNAKE_CASE_ENTITY_NAME$'))
|
||||
|
||||
<li class="active">{{ trans('$LOWERCASE_MODULE_NAME$::$PLURAL_SNAKE_CASE_ENTITY_NAME$.$PLURAL_SNAKE_CASE_ENTITY_NAME$') }}</li>
|
||||
@endcomponent
|
||||
|
||||
@component('admin::components.page.index_table')
|
||||
@slot('buttons', ['create'])
|
||||
@slot('resource', '$PLURAL_SNAKE_CASE_ENTITY_NAME$')
|
||||
@slot('name', trans('$LOWERCASE_MODULE_NAME$::$PLURAL_SNAKE_CASE_ENTITY_NAME$.$SNAKE_CASE_ENTITY_NAME$'))
|
||||
|
||||
@component('admin::components.table')
|
||||
@slot('thead')
|
||||
<tr>
|
||||
@include('admin::partials.table.select_all')
|
||||
</tr>
|
||||
@endslot
|
||||
@endcomponent
|
||||
@endcomponent
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
new DataTable('#$PLURAL_SNAKE_CASE_ENTITY_NAME$-table .table', {
|
||||
columns: [
|
||||
{ data: 'checkbox', orderable: false, searchable: false, width: '3%' },
|
||||
//
|
||||
],
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
14
app/Scaffold/Module/stubs/views/shortcuts.stub
Normal file
14
app/Scaffold/Module/stubs/views/shortcuts.stub
Normal file
@@ -0,0 +1,14 @@
|
||||
@push('shortcuts')
|
||||
<dl class="dl-horizontal">
|
||||
<dt><code>b</code></dt>
|
||||
<dd>{{ trans('admin::admin.shortcuts.back_to_index', ['name' => trans('$LOWERCASE_MODULE_NAME$::$PLURAL_SNAKE_CASE_ENTITY_NAME$.$SNAKE_CASE_ENTITY_NAME$')]) }}</dd>
|
||||
</dl>
|
||||
@endpush
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
keypressAction([
|
||||
{ key: 'b', route: "{{ route('admin.$PLURAL_SNAKE_CASE_ENTITY_NAME$.index') }}" }
|
||||
]);
|
||||
</script>
|
||||
@endpush
|
||||
Reference in New Issue
Block a user