diff --git a/src/CrudSimpleMake.php b/src/CrudSimpleMake.php index 8b75b5b..328b47e 100644 --- a/src/CrudSimpleMake.php +++ b/src/CrudSimpleMake.php @@ -108,6 +108,6 @@ class CrudSimpleMake extends GeneratorCommand { app('Luthfi\CrudGenerator\Generators\LangFileGenerator', ['command' => $this])->generate(); app('Luthfi\CrudGenerator\Generators\FormViewGenerator', ['command' => $this])->generate(); - app('Luthfi\CrudGenerator\Generators\IndexViewGenerator', ['command' => $this])->generate(); + app('Luthfi\CrudGenerator\Generators\IndexViewGenerator', ['command' => $this])->generate('simple'); } } diff --git a/src/Generators/IndexViewGenerator.php b/src/Generators/IndexViewGenerator.php index c5e0c25..a33e3d5 100644 --- a/src/Generators/IndexViewGenerator.php +++ b/src/Generators/IndexViewGenerator.php @@ -14,7 +14,7 @@ class IndexViewGenerator extends BaseGenerator { $viewPath = $this->makeDirectory(resource_path('views/'.$this->modelNames['table_name'])); - $this->generateFile($viewPath.'/index.blade.php', $this->getContent('view-index')); + $this->generateFile($viewPath.'/index.blade.php', $this->getContent('view-index-'.$type)); $this->command->info($this->modelNames['model_name'].' index view file generated.'); } diff --git a/src/stubs/view-index-full.stub b/src/stubs/view-index-full.stub new file mode 100644 index 0000000..bacad5b --- /dev/null +++ b/src/stubs/view-index-full.stub @@ -0,0 +1,58 @@ +@extends('layouts.app') + +@section('title', trans('master.list')) + +@section('content') +

+
+ @can('create', new fullMstr) + {{ link_to_route('masters.index', trans('master.create'), ['action' => 'create'], ['class' => 'btn btn-success']) }} + @endcan +
+ {{ trans('master.list') }} + {{ trans('app.total') }} : {{ $mstrCollections->total() }} {{ trans('master.master') }} +

+
+
+
+
+ {{ Form::open(['method' => 'get','class' => 'form-inline']) }} + {!! FormField::text('q', ['value' => request('q'), 'label' => trans('master.search'), 'class' => 'input-sm']) !!} + {{ Form::submit(trans('master.search'), ['class' => 'btn btn-sm']) }} + {{ link_to_route('masters.index', trans('app.reset')) }} + {{ Form::close() }} +
+ + + + + + + + + + + @foreach($mstrCollections as $key => $singleMstr) + + + + + + + @endforeach + +
{{ trans('app.table_no') }}{{ trans('master.name') }}{{ trans('master.description') }}{{ trans('app.action') }}
{{ $mstrCollections->firstItem() + $key }}{{ $singleMstr->name }}{{ $singleMstr->description }} + @can('view', $singleMstr) + {!! link_to_route( + 'masters.show', + trans('app.show'), + [$singleMstr], + ['class' => 'btn btn-default', 'id' => 'show-master-' . $singleMstr->id] + ) !!} + @endcan +
+
{{ $mstrCollections->appends(Request::except('page'))->render() }}
+
+
+
+@endsection diff --git a/src/stubs/view-index.stub b/src/stubs/view-index-simple.stub similarity index 100% rename from src/stubs/view-index.stub rename to src/stubs/view-index-simple.stub diff --git a/tests/Generators/ViewsGeneratorTest.php b/tests/Generators/ViewsGeneratorTest.php index 9469f00..893eedb 100644 --- a/tests/Generators/ViewsGeneratorTest.php +++ b/tests/Generators/ViewsGeneratorTest.php @@ -29,7 +29,7 @@ class ViewsGeneratorTest extends TestCase {{ trans('app.total') }} : {{ \${$this->collection_model_var_name}->total() }} {{ trans('{$this->lang_name}.{$this->lang_name}') }}
-
+
{{ Form::open(['method' => 'get','class' => 'form-inline']) }} @@ -54,20 +54,12 @@ class ViewsGeneratorTest extends TestCase {{ \${$this->single_model_var_name}->name }} {{ \${$this->single_model_var_name}->description }} - @can('update', \${$this->single_model_var_name}) + @can('view', \${$this->single_model_var_name}) {!! link_to_route( - '{$this->table_name}.index', - trans('app.edit'), - ['action' => 'edit', 'id' => \${$this->single_model_var_name}->id] + Request::only('page', 'q'), - ['id' => 'edit-{$this->single_model_var_name}-' . \${$this->single_model_var_name}->id] - ) !!} | - @endcan - @can('delete', \${$this->single_model_var_name}) - {!! link_to_route( - '{$this->table_name}.index', - trans('app.delete'), - ['action' => 'delete', 'id' => \${$this->single_model_var_name}->id] + Request::only('page', 'q'), - ['id' => 'del-{$this->single_model_var_name}-' . \${$this->single_model_var_name}->id] + '{$this->table_name}.show', + trans('app.show'), + [\${$this->single_model_var_name}], + ['class' => 'btn btn-default', 'id' => 'show-{$this->lang_name}-' . \${$this->single_model_var_name}->id] ) !!} @endcan @@ -78,11 +70,6 @@ class ViewsGeneratorTest extends TestCase
{{ \${$this->collection_model_var_name}->appends(Request::except('page'))->render() }}
-
- @if(Request::has('action')) - @include('{$this->table_name}.forms') - @endif -
@endsection ";