diff --git a/src/stubs/resources/views/full/create-formfield.stub b/src/stubs/resources/views/full/create-formfield.stub new file mode 100644 index 0000000..b4f2704 --- /dev/null +++ b/src/stubs/resources/views/full/create-formfield.stub @@ -0,0 +1,23 @@ +@extends('layouts.app') + +@section('title', __('master.create')) + +@section('content') +
{{ $singleMstr->name }}
+ +{{ $singleMstr->description }}
+ {!! $errors->first('master_id', ':message') !!} +| {{ __('app.table_no') }} | +{{ __('master.name') }} | +{{ __('master.description') }} | +{{ __('app.action') }} | +
|---|---|---|---|
| {{ $mstrCollections->firstItem() + $key }} | +{{ $singleMstr->name_link }} | +{{ $singleMstr->description }} | ++ @can('view', $singleMstr) + {!! link_to_route( + 'masters.show', + __('app.show'), + [$singleMstr], + ['class' => 'btn btn-default btn-xs', 'id' => 'show-master-' . $singleMstr->id] + ) !!} + @endcan + | +
| {{ $singleMstr->description }} | @can('view', $singleMstr) - {!! link_to_route( - 'masters.show', - __('app.show'), - [$singleMstr], - ['class' => 'btn btn-default btn-xs', 'id' => 'show-master-' . $singleMstr->id] - ) !!} + {{ __('app.show') }} @endcan | diff --git a/src/stubs/resources/views/full/show-formfield.stub b/src/stubs/resources/views/full/show-formfield.stub new file mode 100644 index 0000000..d115485 --- /dev/null +++ b/src/stubs/resources/views/full/show-formfield.stub @@ -0,0 +1,25 @@ +@extends('layouts.app') + +@section('title', __('master.detail')) + +@section('content') +
| {{ __('master.name') }} | {{ $singleMstr->name }} |
| {{ __('master.description') }} | {{ $singleMstr->description }} |
{{ $editableMaster->name }}
+ +{{ $editableMaster->description }}
+ {!! $errors->first('master_id', ':message') !!} +| {{ __('app.table_no') }} | +{{ __('master.name') }} | +{{ __('master.description') }} | +{{ __('app.action') }} | +
|---|---|---|---|
| {{ $mstrCollections->firstItem() + $key }} | +{{ $singleMstr->name }} | +{{ $singleMstr->description }} | ++ @can('update', $singleMstr) + {!! link_to_route( + 'masters.index', + __('app.edit'), + ['action' => 'edit', 'id' => $singleMstr->id] + Request::only('page', 'q'), + ['id' => 'edit-master-'.$singleMstr->id] + ) !!} + @endcan + | +
| {{ $singleMstr->description }} | @can('update', $singleMstr) - {!! link_to_route( - 'masters.index', - __('app.edit'), - ['action' => 'edit', 'id' => $singleMstr->id] + Request::only('page', 'q'), - ['id' => 'edit-master-'.$singleMstr->id] - ) !!} + {{ __('app.edit') }} @endcan | diff --git a/tests/Generators/Simple/ViewsGeneratorTest.php b/tests/Generators/Simple/ViewsGeneratorTest.php index 1fed9e6..3472c08 100644 --- a/tests/Generators/Simple/ViewsGeneratorTest.php +++ b/tests/Generators/Simple/ViewsGeneratorTest.php @@ -22,7 +22,7 @@ class ViewsGeneratorTest extends TestCase
| {{ \${$this->single_model_var_name}->description }} | @can('update', \${$this->single_model_var_name}) - {!! link_to_route( - '{$this->table_name}.index', - __('app.edit'), - ['action' => 'edit', 'id' => \${$this->single_model_var_name}->id] + Request::only('page', 'q'), - ['id' => 'edit-{$this->lang_name}-'.\${$this->single_model_var_name}->id] - ) !!} + table_name}.index', ['action' => 'edit', 'id' => \${$this->single_model_var_name}->id] + Request::only('page', 'q')) }}\" id=\"edit-{$this->lang_name}-{{ \${$this->single_model_var_name}->id }}\">{{ __('app.edit') }} @endcan | @@ -90,36 +88,45 @@ class ViewsGeneratorTest extends TestCase $this->assertFileExists($formViewPath); $formViewContent = "@if (Request::get('action') == 'create') @can('create', new {$this->full_model_name}) - {!! Form::open(['route' => '{$this->table_name}.store']) !!} - {!! FormField::text('name', ['required' => true, 'label' => __('{$this->lang_name}.name')]) !!} - {!! FormField::textarea('description', ['label' => __('{$this->lang_name}.description')]) !!} - {!! Form::submit(__('{$this->lang_name}.create'), ['class' => 'btn btn-success']) !!} - {{ link_to_route('{$this->table_name}.index', __('app.cancel'), [], ['class' => 'btn btn-default']) }} - {!! Form::close() !!} + @endcan @endif @if (Request::get('action') == 'edit' && \$editable{$this->model_name}) @can('update', \$editable{$this->model_name}) - {!! Form::model(\$editable{$this->model_name}, ['route' => ['{$this->table_name}.update', \$editable{$this->model_name}], 'method' => 'patch']) !!} - {!! FormField::text('name', ['required' => true, 'label' => __('{$this->lang_name}.name')]) !!} - {!! FormField::textarea('description', ['label' => __('{$this->lang_name}.description')]) !!} - @if (request('q')) - {{ Form::hidden('q', request('q')) }} - @endif - @if (request('page')) - {{ Form::hidden('page', request('page')) }} - @endif - {!! Form::submit(__('{$this->lang_name}.update'), ['class' => 'btn btn-success']) !!} - {{ link_to_route('{$this->table_name}.index', __('app.cancel'), Request::only('page', 'q'), ['class' => 'btn btn-default']) }} - @can('delete', \$editable{$this->model_name}) - {!! link_to_route( - '{$this->table_name}.index', - __('app.delete'), - ['action' => 'delete', 'id' => \$editable{$this->model_name}->id] + Request::only('page', 'q'), - ['id' => 'del-{$this->lang_name}-'.\$editable{$this->model_name}->id, 'class' => 'btn btn-danger pull-right'] - ) !!} - @endcan - {!! Form::close() !!} + @endcan @endif @if (Request::get('action') == 'delete' && \$editable{$this->model_name}) @@ -136,17 +143,14 @@ class ViewsGeneratorTest extends TestCase
| {{ \${$this->single_model_var_name}->description }} | @can('view', \${$this->single_model_var_name}) - {!! link_to_route( - '{$this->table_name}.show', - __('app.show'), - [\${$this->single_model_var_name}], - ['class' => 'btn btn-default btn-xs', 'id' => 'show-{$this->lang_name}-' . \${$this->single_model_var_name}->id] - ) !!} + table_name}.show', \${$this->single_model_var_name}) }}\" id=\"show-{$this->lang_name}-{{ \${$this->single_model_var_name}->id }}\" class=\"btn btn-default btn-xs\">{{ __('app.show') }} @endcan | @@ -100,9 +98,9 @@ class ViewsGeneratorTest extends TestCase