Skip to content

Commit

Permalink
Update themes to Bootstrap 5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeAlhayek committed Jan 23, 2024
1 parent b502395 commit ddac1eb
Show file tree
Hide file tree
Showing 55 changed files with 1,722 additions and 1,619 deletions.
9 changes: 6 additions & 3 deletions config/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
|--------------------------------------------------------------------------
|
*/
'api_docs_controller_path' => 'Http/Controllers/ApiDocs',
'api_docs_controller_path' => 'Http/Controllers',

/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -338,10 +338,13 @@
],
],
[
'match' => ['picture', 'file', 'photo', 'avatar'],
'match' => ['picture', 'file', 'photo', 'avatar', 'image', 'document', 'attachment*'],
'set' => [
'is-on-index' => false,
'html-type' => 'file',
'data-type' => 'string',
'data-type-params' => [2500],
'validation' => 'file',
],
],
[
Expand Down Expand Up @@ -373,7 +376,7 @@
],
],
[
'match' => ['created_at', 'updated_at', 'deleted_at'],
'match' => ['created_at', 'updated_at', 'deleted_at', 'modified_at'],
'set' => [
'data-type' => 'datetime',
'is-on-form' => false,
Expand Down
13 changes: 8 additions & 5 deletions src/Commands/Api/CreateApiControllerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CreateApiControllerCommand extends ControllerCommandBase
*/
protected $signature = 'create:api-controller
{model-name : The model name that this controller will represent.}
{--controller-name= : The name of the controler.}
{--controller-name= : The name of the controller.}
{--controller-directory= : The directory where the controller should be created under.}
{--model-directory= : The path where the model should be created under.}
{--resource-file= : The name of the resource-file to import from.}
Expand All @@ -37,7 +37,7 @@ class CreateApiControllerCommand extends ControllerCommandBase
{--language-filename= : The languages file name to put the labels in.}
{--with-form-request : This will extract the validation into a request form class.}
{--without-form-request : Generate the controller without the form-request file. }
{--with-auth : Generate the controller with Laravel auth middlewear. }
{--with-auth : Generate the controller with Laravel auth middleware. }
{--template-name= : The template name to use when generating the code.}
{--form-request-directory= : The directory of the form-request.}
{--controller-extends=default-controller : The base controller to be extend.}
Expand All @@ -46,7 +46,7 @@ class CreateApiControllerCommand extends ControllerCommandBase
{--api-resource-collection-directory= : The directory where the api-resource-collection should be created.}
{--api-resource-name= : The api-resource file name.}
{--api-resource-collection-name= : The api-resource-collection file name.}
{--api-version= : The api version to prefix your resurces with.}
{--api-version= : The api version to prefix your resources with.}
{--force : This option will override the controller if one already exists.}';

/**
Expand Down Expand Up @@ -74,7 +74,7 @@ public function handle()

if ($input->withApiResource) {
if (!Helpers::isApiResourceSupported()) {
$this->info('Api-resource is not supported in the current Laravel version. To use Api-resource, pleae upgrade to Laravel 5.5+.');
$this->info('Api-resource is not supported in the current Laravel version. To use Api-resource, please upgrade to Laravel 5.5+.');
$this->warn('*** Continuing without create api-resource! ***');
} else {
$this->makeApiResource($input, false)
Expand Down Expand Up @@ -162,7 +162,7 @@ protected function getAdditionalNamespaces($input)
protected function getNamespacesForUsedRelations(array $fields)
{
// Since there is no create/edit forms in the API controller,
// No need for any relation's namespances.
// No need for any relation's namespaces.

return [];
}
Expand Down Expand Up @@ -498,6 +498,9 @@ protected function getCommandInput()
{
$input = parent::getCommandInput();

$cName = trim($this->option('controller-name'));
$input->controllerName = $cName ? Str::finish($cName, Config::getControllerNamePostFix()) : Helpers::makeControllerName($modelName . 'Api');

$input->apiResourceDirectory = trim($this->option('api-resource-directory'));
$input->apiResourceCollectionDirectory = trim($this->option('api-resource-collection-directory'));
$input->apiResourceName = trim($this->option('api-resource-name'));
Expand Down
5 changes: 4 additions & 1 deletion src/Commands/Api/CreateApiScaffoldCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ protected function createRoutes(ApiScaffoldInput $input, Field $primaryField = n
}

/**
* Get the Api folder after removing the controllers path.
* Get the API folder after removing the controllers path.
*
* @param string $path
*
Expand Down Expand Up @@ -222,6 +222,9 @@ protected function getCommandInput()
{
$input = new ApiScaffoldInput(parent::getCommandInput());

$cName = trim($this->option('controller-name'));

$input->controllerName = $cName ? Str::finish($cName, Config::getControllerNamePostFix()) : Helpers::makeControllerName($input->modelName . 'Api');
$input->withApiResource = $this->option('with-api-resource');
$input->apiResourceDirectory = $this->option('api-resource-directory');
$input->apiResourceCollectionDirectory = $this->option('api-resource-collection-directory');
Expand Down
4 changes: 2 additions & 2 deletions src/Commands/ApiDocs/CreateApiDocsControllerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ protected function getControllerDirectory($controllerDirectory)
}

/**
* Gets the destenation file to be created.
* Gets the destination file to be created.
*
* @param string $name
* @param string $path
Expand Down Expand Up @@ -262,7 +262,7 @@ protected function getCommandInput()
{
$modelName = trim($this->argument('model-name'));
$cName = trim($this->option('controller-name'));
$controllerName = $cName ? Str::finish($cName, Config::getControllerNamePostFix()) : Helpers::makeControllerName($modelName);
$controllerName = $cName ? Str::finish($cName, Config::getControllerNamePostFix()) : Helpers::makeControllerName($modelName . 'ApiDocs');
$prefix = ($this->option('routes-prefix') == 'default-form') ? Helpers::makeRouteGroup($modelName) : $this->option('routes-prefix');
$resourceFile = trim($this->option('resource-file')) ?: Helpers::makeJsonFileName($modelName);
$force = $this->option('force');
Expand Down
7 changes: 5 additions & 2 deletions src/Commands/ApiDocs/CreateApiDocsScaffoldCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
use CrestApps\CodeGenerator\Traits\CommonCommand;
use CrestApps\CodeGenerator\Traits\ScaffoldTrait;
use Illuminate\Console\Command;
use CrestApps\CodeGenerator\Support\Helpers;
use CrestApps\CodeGenerator\Traits\LanguageTrait;

class CreateApiDocsScaffoldCommand extends command
{
use ApiDocViewsTrait, CommonCommand, ScaffoldTrait;
use ApiDocViewsTrait, CommonCommand, ScaffoldTrait, LanguageTrait;

/**
* The console command description.
Expand Down Expand Up @@ -169,7 +171,8 @@ protected function createLanguageFile($input)
protected function getCommandInput()
{
$modelName = $this->argument('model-name');
$controllerName = $this->option('controller-name');
$cName = trim($this->option('controller-name'));
$controllerName = $cName ? Str::finish($cName, Config::getControllerNamePostFix()) : Helpers::makeControllerName($modelName . 'ApiDocs');
$prefix = $this->option('routes-prefix');
$resourceFile = $this->option('resource-file');
$force = $this->option('force');
Expand Down
10 changes: 5 additions & 5 deletions src/Commands/ApiDocs/CreateApiDocsViewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ class CreateApiDocsViewCommand extends Command
*/
protected $signature = 'api-docs:create-view
{model-name : The model name that this controller will represent.}
{--controller-name= : The name of the controler.}
{--controller-name= : The name of the controller.}
{--controller-directory= : The directory where the controller should be created under.}
{--resource-file= : The name of the resource-file to import from.}
{--routes-prefix=default-form : Prefix of the route group.}
{--language-filename= : The languages file name to put the labels in.}
{--with-auth : Generate the controller with Laravel auth middlewear. }
{--with-auth : Generate the controller with Laravel auth middleware. }
{--views-directory= : The name of the directory to create the views under.}
{--api-version= : The api version to prefix your resurces with.}
{--layout-name=layouts.api-doc-layout : This will extract the validation into a request form class.}
{--api-version= : The api version to prefix your resources with.}
{--layout-name=layouts.app : This will extract the validation into a request form class.}
{--template-name= : The template name to use when generating the code.}
{--force : This option will override the controller if one already exists.}';

Expand Down Expand Up @@ -205,7 +205,7 @@ protected function makeStandardSubView($name, $input, array $apiDocLabels, array
}

/**
* Gets the destenation file to be created.
* Gets the destination file to be created.
*
* @param string $name
* @param string $path
Expand Down
12 changes: 6 additions & 6 deletions src/Commands/Bases/ViewsCommandBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected function getViewName()
}

/**
* It gets the views destenation path
* It gets the views destination path
*
* @param $viewsDirectory
*
Expand Down Expand Up @@ -119,7 +119,7 @@ protected function getDestinationViewFullname($viewsDirectory, $routesPrefix, $v
}

/**
* It generate the destenation view name
* It generate the destination view name
*
* @param $action
*
Expand All @@ -138,7 +138,7 @@ protected function getDestinationViewName($action)
*
* @return $this
*/
protected function replaceCommonTemplates(&$stub, ViewInput $input, array $fields)
protected function replaceCommonTemplates(&$stub, $input, array $fields)
{
$viewLabels = new ViewLabelsGenerator($input->modelName, $fields, $this->isCollectiveTemplate());

Expand Down Expand Up @@ -222,7 +222,7 @@ protected function replaceFormName(&$stub, $name)
/**
* Get the view's name of a given file.
*
* @param string $fillname
* @param string $filename
*
* @return string
*/
Expand Down Expand Up @@ -347,7 +347,7 @@ protected function createLanguageFile($langFile, $resourceFile, $modelName)
}

/**
* Gets destenation view path
* Gets destination view path
*
* @param string $viewsDirectory
* @param string $routesPrefix
Expand Down Expand Up @@ -413,7 +413,7 @@ protected function getHtmlGenerator(array $fields, $modelName, $template)
}

/**
* Replace the modele's header fo the given stub.
* Replace the model's header for the given stub.
*
* @param string $stub
* @param string $title
Expand Down
5 changes: 3 additions & 2 deletions src/Commands/Views/CreateCreateViewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ protected function getStubName()
protected function handleCreateView()
{
$input = $this->getCommandInput();

$resources = Resource::fromFile($input->resourceFile, $input->languageFileName);
$destenationFile = $this->getDestinationViewFullname($input->viewsDirectory, $input->prefix);

Expand All @@ -68,7 +69,7 @@ protected function handleCreateView()
}

/**
* Gets te create form name
* Gets the create form name
*
* @param string $modelName
*
Expand All @@ -80,7 +81,7 @@ protected function getFormName($modelName)
}

/**
* Gets te create form id
* Gets the create form id
*
* @param string $modelName
*
Expand Down
1 change: 1 addition & 0 deletions src/Commands/Views/CreateFormViewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ protected function handleCreateView()
{
$input = $this->getCommandInput();
$resources = Resource::fromFile($input->resourceFile, $input->languageFileName);

$destenationFile = $this->getDestinationViewFullname($input->viewsDirectory, $input->prefix);

if ($this->canCreateView($destenationFile, $input->force, $resources)) {
Expand Down
62 changes: 62 additions & 0 deletions src/Commands/Views/CreateIndexViewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@

use CrestApps\CodeGenerator\Commands\Bases\ViewsCommandBase;
use CrestApps\CodeGenerator\Models\Resource;
use CrestApps\CodeGenerator\Support\Helpers;
use CrestApps\CodeGenerator\Traits\LanguageTrait;

class CreateIndexViewCommand extends ViewsCommandBase
{
use LanguageTrait;

/**
* The name and signature of the console command.
*
Expand All @@ -19,6 +23,7 @@ class CreateIndexViewCommand extends ViewsCommandBase
{--routes-prefix=default-form : Prefix of the route group.}
{--language-filename= : The name of the language file.}
{--layout-name=layouts.app : This will extract the validation into a request form class.}
{--pagination-view-name=pagination : the name of the view to use for pagination.}
{--template-name= : The template name to use when generating the code.}
{--force : This option will override the view if one already exists.}';

Expand Down Expand Up @@ -47,9 +52,19 @@ protected function getStubName()
protected function handleCreateView()
{
$input = $this->getCommandInput();

$resources = Resource::fromFile($input->resourceFile, $input->languageFileName);
$destenationFile = $this->getDestinationViewFullname($input->viewsDirectory, $input->prefix);

$paginationFileName = $this->getDestinationViewFullname($input->viewsDirectory, '', $input->paginationViewName);

if(!$this->alreadyExists($paginationFileName))
{
$pagerStub = $this->getStubContent('pagination.blade', $this->getTemplateName());

$this->createFile($paginationFileName, $pagerStub);
}

if ($this->canCreateView($destenationFile, $input->force, $resources)) {
$stub = $this->getStub();
$htmlCreator = $this->getHtmlGenerator($resources->fields, $input->modelName, $this->getTemplateName());
Expand All @@ -59,11 +74,58 @@ protected function handleCreateView()
->replaceHeaderCells($stub, $htmlCreator->getIndexHeaderCells())
->replaceBodyCells($stub, $htmlCreator->getIndexBodyCells())
->replaceModelHeader($stub, $this->getHeaderFieldAccessor($resources->fields, $input->modelName))
->replacePaginationViewName($stub, $input->paginationViewName)
->createFile($destenationFile, $stub)
->info('Index view was crafted successfully.');
}
}

/**
* Replaces the fillable for the given stub.
*
* @param string $stub
* @param string $fillable
*
* @return $this
*/
protected function replacePaginationViewName(&$stub, $name)
{
return $this->replaceTemplate('pagination_view_name', $name, $stub);
}

/**
* Gets a clean user inputs.
*
* @return object
*/
protected function getCommandInput()
{
$options = $this->options();

$modelName = trim($this->arguments()['model-name']);
$resourceFile = trim($options['resource-file']) ?: Helpers::makeJsonFileName($modelName);
$viewsDirectory = trim($options['views-directory']);
$prefix = trim($options['routes-prefix']);
$prefix = ($prefix == 'default-form') ? Helpers::makeRouteGroup($modelName) : $prefix;
$force = $options['force'];
$languageFileName = trim($options['language-filename']) ?: self::makeLocaleGroup($modelName);
$layout = trim($options['layout-name']);
$template = trim($options['template-name']);
$paginationViewName = trim($options['pagination-view-name']);

return (object) compact(
'modelName',
'prefix',
'force',
'resourceFile',
'languageFileName',
'layout',
'template',
'paginationViewName',
'viewsDirectory'
);
}

/**
* Replaces the column headers in a given stub.
*
Expand Down
6 changes: 3 additions & 3 deletions src/Commands/Views/CreateViewLayoutCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class CreateViewLayoutCommand extends Command
{--layout-directory=layouts : The directory of the layouts.}
{--without-validation : This option will create a layout without client-side validation.}
{--template-name= : The template name to use when generating the code.}
{--force : Override existsing layout.}';
{--force : Override existing layout.}';

/**
* The console command description.
Expand Down Expand Up @@ -96,7 +96,7 @@ protected function fileExists($filename, $force)
}

/**
* Gets the destenation path.
* Gets the destination path.
*
* @param string $path
*
Expand Down Expand Up @@ -128,7 +128,7 @@ protected function getCommandInput()
}

/**
* Replaces the application'd name fo the given stub.
* Replaces the application's name for the given stub.
*
* @param string $stub
* @param string $appName
Expand Down
Loading

0 comments on commit ddac1eb

Please sign in to comment.