diff --git a/app/Console/Commands/MakeClass.php b/app/Console/Commands/MakeClass.php index bbb0b50d7491..142b1035d193 100644 --- a/app/Console/Commands/MakeClass.php +++ b/app/Console/Commands/MakeClass.php @@ -68,6 +68,7 @@ class MakeClass extends GeneratorCommand 'DATATABLE_COLUMNS' => $this->getColumns(), 'FORM_FIELDS' => $this->getFormFields(), 'DATABASE_FIELDS' => $this->getDatabaseFields($module), + 'TRANSFORMER_FIELDS' => $this->getTransformerFields($module), ]))->render(); } @@ -137,4 +138,19 @@ class MakeClass extends GeneratorCommand return $str; } + + protected function getTransformerFields($module) + { + $fields = $this->option('fields'); + $fields = explode(',', $fields); + $str = ''; + + foreach ($fields as $field) { + $field = explode(':', $field)[0]; + $str .= "'{$field}' => $" . $module->getLowerName() . "->$field,\n "; + } + + return rtrim($str); + + } } diff --git a/app/Console/Commands/MakeModule.php b/app/Console/Commands/MakeModule.php index b014d8863985..706cc0c36fa4 100644 --- a/app/Console/Commands/MakeModule.php +++ b/app/Console/Commands/MakeModule.php @@ -66,7 +66,7 @@ class MakeModule extends Command Artisan::call('ninja:make-class', ['name' => $name, 'module' => $name, 'class' => 'request', 'prefix' => 'create']); Artisan::call('ninja:make-class', ['name' => $name, 'module' => $name, 'class' => 'request', 'prefix' => 'update']); Artisan::call('ninja:make-class', ['name' => $name, 'module' => $name, 'class' => 'api-controller']); - Artisan::call('ninja:make-class', ['name' => $name, 'module' => $name, 'class' => 'transformer']); + Artisan::call('ninja:make-class', ['name' => $name, 'module' => $name, 'class' => 'transformer', '--fields' => $fields]); Artisan::call('module:dump'); } diff --git a/app/Console/Commands/stubs/api-controller.stub b/app/Console/Commands/stubs/api-controller.stub index 6508ae9354bc..8a047352ca8d 100644 --- a/app/Console/Commands/stubs/api-controller.stub +++ b/app/Console/Commands/stubs/api-controller.stub @@ -2,9 +2,6 @@ namespace $NAMESPACE$; -//use Response; -//use Input; -//use App\Models\$STUDLY_NAME$; use App\Http\Controllers\BaseAPIController; use Modules\$STUDLY_NAME$\Repositories\$STUDLY_NAME$Repository; use Modules\$STUDLY_NAME$\Http\Requests\$STUDLY_NAME$Request; @@ -127,8 +124,6 @@ class $STUDLY_NAME$ApiController extends BaseAPIController return $this->handleAction($request); } - //$data = $request->input(); - //$data['public_id'] = $publicId; $$LOWER_NAME$ = $this->$LOWER_NAME$Repo->save($request->input(), $request->entity()); return $this->itemResponse($$LOWER_NAME$); diff --git a/app/Console/Commands/stubs/controller.stub b/app/Console/Commands/stubs/controller.stub index b21fddb0076f..a39e631e5427 100755 --- a/app/Console/Commands/stubs/controller.stub +++ b/app/Console/Commands/stubs/controller.stub @@ -3,9 +3,6 @@ namespace $CLASS_NAMESPACE$; use Auth; -//use Illuminate\Http\Request; -//use Illuminate\Http\Response; -//use Illuminate\Routing\Controller; use App\Http\Controllers\BaseController; use App\Services\DatatableService; use Modules\$STUDLY_NAME$\Datatables\$STUDLY_NAME$Datatable; @@ -119,14 +116,6 @@ class $CLASS$ extends BaseController ->with('message', trans('texts.updated_$LOWER_NAME$')); } - /** - * Remove the specified resource from storage. - * @return Response - */ - public function destroy() - { - } - /** * Update multiple resources */ diff --git a/app/Console/Commands/stubs/transformer.stub b/app/Console/Commands/stubs/transformer.stub index 3503971c2e31..27636445b238 100644 --- a/app/Console/Commands/stubs/transformer.stub +++ b/app/Console/Commands/stubs/transformer.stub @@ -26,6 +26,7 @@ class $STUDLY_NAME$Transformer extends EntityTransformer public function transform($STUDLY_NAME$ $$LOWER_NAME$) { return array_merge($this->getDefaults($$LOWER_NAME$), [ + $TRANSFORMER_FIELDS$ 'id' => (int) $$LOWER_NAME$->public_id, 'updated_at' => $this->getTimestamp($$LOWER_NAME$->updated_at), 'archived_at' => $this->getTimestamp($$LOWER_NAME$->deleted_at), diff --git a/resources/views/header.blade.php b/resources/views/header.blade.php index 8c1d8434360a..ef213fd387d1 100644 --- a/resources/views/header.blade.php +++ b/resources/views/header.blade.php @@ -495,50 +495,22 @@ 'tasks', 'expenses', 'vendors', - 'settings', ] as $option) @if (in_array($option, ['dashboard', 'settings']) || Auth::user()->can('view', substr($option, 0, -1)) || Auth::user()->can('create', substr($option, 0, -1))) -
  • - @if ($option == 'settings') - - - - @elseif ($option != 'dashboard') - @if (Auth::user()->can('create', substr($option, 0, -1))) - - - - @endif - @endif - - - {{ ($option == 'recurring_invoices') ? trans('texts.recurring') : trans("texts.{$option}") }} - {!! Utils::isTrial() && in_array($option, ['quotes', 'tasks', 'expenses', 'vendors']) ? ' ' . trans('texts.pro') . '' : '' !!} - @if (false && $option == 'self-update' && Updater::source()->isNewVersionAvailable('v'.NINJA_VERSION)) - 1 - @endif - -
  • + @include('partials.navigation_option') @endif @endforeach @if ( ! Utils::isNinjaProd()) @foreach (Module::all() as $module) -
  • getAlias()}*") ? 'active' : '' }}"> - getAlias()}*") ? 'active' : '' }}"> - - {{ $module->getName() }} - -
  • + @include('partials.navigation_option', [ + 'option' => $module->getAlias(), + 'icon' => $module->get('icon', 'th-large'), + ]) @endforeach @endif + @include('partials.navigation_option', ['option' => 'settings']) diff --git a/resources/views/partials/navigation_option.blade.php b/resources/views/partials/navigation_option.blade.php new file mode 100644 index 000000000000..5b8c20a75dbc --- /dev/null +++ b/resources/views/partials/navigation_option.blade.php @@ -0,0 +1,27 @@ +
  • + + @if ($option == 'settings') + + + + + + @elseif (Auth::user()->can('create', substr($option, 0, -1))) + + + + + + @endif + + + + {{ ($option == 'recurring_invoices') ? trans('texts.recurring') : trans("texts.{$option}") }} + {!! Utils::isTrial() && in_array($option, ['quotes', 'tasks', 'expenses', 'vendors']) ? ' ' . trans('texts.pro') . '' : '' !!} + + +