1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-18 00:53:10 +01:00
This commit is contained in:
Hillel Coren 2016-12-09 00:06:31 +02:00
parent 758e06b79b
commit da55195b8a
8 changed files with 117 additions and 6 deletions

View File

@ -50,6 +50,7 @@ class MakeClass extends GeneratorCommand
{
return array(
array('fields', null, InputOption::VALUE_OPTIONAL, 'The model attributes.', null),
array('filename', null, InputOption::VALUE_OPTIONAL, 'The class filename.', null),
);
}
@ -65,6 +66,7 @@ class MakeClass extends GeneratorCommand
'CLASS' => $this->getClass(),
'STUDLY_NAME' => Str::studly($module->getLowerName()),
'COLUMNS' => $this->getColumns(),
'FORM_FIELDS' => $this->getFormFields(),
]))->render();
}
@ -81,6 +83,9 @@ class MakeClass extends GeneratorCommand
*/
protected function getFileName()
{
if ($this->option('filename')) {
return $this->option('filename');
}
return studly_case($this->argument('prefix')) . studly_case($this->argument('name')) . Str::studly($this->argument('class'));
}
@ -103,4 +108,18 @@ class MakeClass extends GeneratorCommand
return $str;
}
protected function getFormFields()
{
$fields = $this->option('fields');
$fields = explode(',', $fields);
$str = '';
foreach ($fields as $field) {
$field = explode(':', $field)[0];
$str .= '{!! Former::text(\''. $field . '\') !!}
';
}
return $str;
}
}

View File

@ -56,12 +56,12 @@ class MakeModule extends Command
Artisan::call('module:migrate', ['module' => $name]);
Artisan::call('module:make-model', ['model' => $name, 'module' => $name, '--fillable' => $fillable]);
Artisan::call('ninja:make-class', ['name' => $name, 'module' => $name, 'class' => 'views', '--fields' => $fields, '--filename' => 'edit.blade']);
Artisan::call('ninja:make-class', ['name' => $name, 'module' => $name, 'class' => 'datatable', '--fields' => $fields]);
Artisan::call('ninja:make-class', ['name' => $name, 'module' => $name, 'class' => 'repository']);
Artisan::call('ninja:make-class', ['name' => $name, 'module' => $name, 'class' => 'policy']);
Artisan::call('ninja:make-class', ['name' => $name, 'module' => $name, 'class' => 'auth-provider']);
Artisan::call('ninja:make-class', ['name' => $name, 'module' => $name, 'class' => 'presenter']);
Artisan::call('ninja:make-class', ['name' => $name, 'module' => $name, 'class' => 'request']);
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']);

View File

@ -57,7 +57,7 @@ class $STUDLY_NAME$Repository extends BaseRepository
}
*/
//$entity->fill($data);
$entity->fill($data);
$entity->save();
/*

View File

@ -11,7 +11,7 @@ class Update$CLASS$Request extends $CLASS$Request
*/
public function authorize()
{
return $this->user()->can('edit', '$LOWER_NAME$');
return $this->user()->can('edit', $this->entity());
}
/**

View File

@ -0,0 +1,47 @@
@extends('header')
@section('content')
{!! Former::open($url)
->addClass('col-md-10 col-md-offset-1 warn-on-exit')
->method($method)
->rules([]) !!}
@if ($$LOWER_NAME$)
{!! Former::populate($$LOWER_NAME$) !!}
<div style="display:none">
{!! Former::text('public_id') !!}
</div>
@endif
<div class="row">
<div class="col-md-10 col-md-offset-1">
<div class="panel panel-default">
<div class="panel-body">
$FORM_FIELDS$
</div>
</div>
</div>
</div>
<center class="buttons">
{!! Button::normal(trans('texts.cancel'))
->large()
->asLinkTo(URL::to('/$LOWER_NAME$'))
->appendIcon(Icon::create('remove-circle')) !!}
{!! Button::success(trans('texts.save'))
->submit()
->large()
->appendIcon(Icon::create('floppy-disk')) !!}
</center>
{!! Former::close() !!}
@stop

View File

@ -0,0 +1,47 @@
@extends('header')
@section('content')
{!! Former::open($url)
->addClass('col-md-10 col-md-offset-1 warn-on-exit')
->method($method)
->rules([]) !!}
@if ($$LOWER_NAME$)
{!! Former::populate($$LOWER_NAME$) !!}
<div style="display:none">
{!! Former::text('public_id') !!}
</div>
@endif
<div class="row">
<div class="col-md-10 col-md-offset-1">
<div class="panel panel-default">
<div class="panel-body">
$FORM_FIELDS$
</div>
</div>
</div>
</div>
<center class="buttons">
{!! Button::normal(trans('texts.cancel'))
->large()
->asLinkTo(URL::to('/$LOWER_NAME$'))
->appendIcon(Icon::create('remove-circle')) !!}
{!! Button::success(trans('texts.save'))
->submit()
->large()
->appendIcon(Icon::create('floppy-disk')) !!}
</center>
{!! Former::close() !!}
@stop

View File

@ -29,7 +29,6 @@ return [
'start' => 'start.php',
'routes' => 'Http/routes.php',
'json' => 'module.json',
'views/edit' => 'Resources/views/edit.blade.php',
'views/master' => 'Resources/views/layouts/master.blade.php',
'scaffold/config' => 'Config/config.php',
'composer' => 'composer.json',
@ -38,7 +37,6 @@ return [
'start' => ['LOWER_NAME'],
'routes' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE'],
'json' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE'],
'views/edit' => ['LOWER_NAME'],
'views/master' => ['STUDLY_NAME'],
'scaffold/config' => ['STUDLY_NAME'],
'composer' => [