mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 20:22:42 +01:00
CRUD
This commit is contained in:
parent
dc981b40ab
commit
a0af7f4b96
@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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');
|
||||
}
|
||||
|
@ -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$);
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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),
|
||||
|
@ -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)))
|
||||
<li class="{{ Request::is("{$option}*") ? 'active' : '' }}">
|
||||
@if ($option == 'settings')
|
||||
<a type="button" class="btn btn-default btn-sm pull-right"
|
||||
href="{{ Utils::getDocsUrl(request()->path()) }}" target="_blank">
|
||||
<i class="fa fa-question-circle" style="width:20px" title="{{ trans('texts.help') }}"></i>
|
||||
</a>
|
||||
@elseif ($option != 'dashboard')
|
||||
@if (Auth::user()->can('create', substr($option, 0, -1)))
|
||||
<a type="button" class="btn btn-primary btn-sm pull-right"
|
||||
href="{{ url("/{$option}/create") }}">
|
||||
<i class="fa fa-plus-circle" style="width:20px" title="{{ trans('texts.create_new') }}"></i>
|
||||
</a>
|
||||
@endif
|
||||
@endif
|
||||
<a href="{{ url($option == 'recurring' ? 'recurring_invoice' : $option) }}"
|
||||
style="font-size:16px; padding-top:6px; padding-bottom:6px"
|
||||
class="{{ Request::is("{$option}*") ? 'active' : '' }}">
|
||||
<i class="fa fa-{{ \App\Models\EntityModel::getIcon($option) }}" style="width:46px; padding-right:10px"></i>
|
||||
{{ ($option == 'recurring_invoices') ? trans('texts.recurring') : trans("texts.{$option}") }}
|
||||
{!! Utils::isTrial() && in_array($option, ['quotes', 'tasks', 'expenses', 'vendors']) ? ' <sup>' . trans('texts.pro') . '</sup>' : '' !!}
|
||||
@if (false && $option == 'self-update' && Updater::source()->isNewVersionAvailable('v'.NINJA_VERSION))
|
||||
<span class="badge alert-danger">1</span>
|
||||
@endif
|
||||
</a>
|
||||
</li>
|
||||
@include('partials.navigation_option')
|
||||
@endif
|
||||
@endforeach
|
||||
@if ( ! Utils::isNinjaProd())
|
||||
@foreach (Module::all() as $module)
|
||||
<li class="{{ Request::is("{$module->getAlias()}*") ? 'active' : '' }}">
|
||||
<a href="{{ url($module->getAlias()) }}"
|
||||
style="font-size:16px; padding-top:6px; padding-bottom:6px"
|
||||
class="{{ Request::is("{$module->getAlias()}*") ? 'active' : '' }}">
|
||||
<i class="fa fa-{{ $module->get('icon', 'th-large') }}" style="width:46px; padding-right:10px"></i>
|
||||
{{ $module->getName() }}
|
||||
</a>
|
||||
</li>
|
||||
@include('partials.navigation_option', [
|
||||
'option' => $module->getAlias(),
|
||||
'icon' => $module->get('icon', 'th-large'),
|
||||
])
|
||||
@endforeach
|
||||
@endif
|
||||
@include('partials.navigation_option', ['option' => 'settings'])
|
||||
</ul>
|
||||
</div>
|
||||
<!-- /#left-sidebar-wrapper -->
|
||||
|
27
resources/views/partials/navigation_option.blade.php
Normal file
27
resources/views/partials/navigation_option.blade.php
Normal file
@ -0,0 +1,27 @@
|
||||
<li class="{{ Request::is("{$option}*") ? 'active' : '' }}">
|
||||
|
||||
@if ($option == 'settings')
|
||||
|
||||
<a type="button" class="btn btn-default btn-sm pull-right"
|
||||
href="{{ Utils::getDocsUrl(request()->path()) }}" target="_blank">
|
||||
<i class="fa fa-question-circle" style="width:20px" title="{{ trans('texts.help') }}"></i>
|
||||
</a>
|
||||
|
||||
@elseif (Auth::user()->can('create', substr($option, 0, -1)))
|
||||
|
||||
<a type="button" class="btn btn-primary btn-sm pull-right"
|
||||
href="{{ url("/{$option}/create") }}">
|
||||
<i class="fa fa-plus-circle" style="width:20px" title="{{ trans('texts.create_new') }}"></i>
|
||||
</a>
|
||||
|
||||
@endif
|
||||
|
||||
<a href="{{ url($option == 'recurring' ? 'recurring_invoice' : $option) }}"
|
||||
style="font-size:16px; padding-top:6px; padding-bottom:6px"
|
||||
class="{{ Request::is("{$option}*") ? 'active' : '' }}">
|
||||
<i class="fa fa-{{ empty($icon) ? \App\Models\EntityModel::getIcon($option) : $icon }}" style="width:46px; padding-right:10px"></i>
|
||||
{{ ($option == 'recurring_invoices') ? trans('texts.recurring') : trans("texts.{$option}") }}
|
||||
{!! Utils::isTrial() && in_array($option, ['quotes', 'tasks', 'expenses', 'vendors']) ? ' <sup>' . trans('texts.pro') . '</sup>' : '' !!}
|
||||
</a>
|
||||
|
||||
</li>
|
Loading…
Reference in New Issue
Block a user