Browse Source

Change trans() helper usage to __()

tags/1.1.6
Nafies Luthfi 8 years ago
parent
commit
d475f1ace7
  1. 4
      src/stubs/model.stub
  2. 4
      src/stubs/test-unit.stub
  3. 12
      src/stubs/view-create.stub
  4. 26
      src/stubs/view-edit.stub
  5. 30
      src/stubs/view-forms.stub
  6. 28
      src/stubs/view-index-full.stub
  7. 28
      src/stubs/view-index-simple.stub
  8. 12
      src/stubs/view-show.stub
  9. 8
      tests/Generators/ModelGeneratorTest.php
  10. 8
      tests/Generators/ModelTestGeneratorTest.php
  11. 58
      tests/Generators/Simple/ViewsGeneratorTest.php
  12. 78
      tests/Generators/ViewsGeneratorTest.php

4
src/stubs/model.stub

@ -12,9 +12,9 @@ class Master extends Model
public function getNameLinkAttribute()
{
return link_to_route('masters.show', $this->name, [$this], [
'title' => trans(
'title' => __(
'app.show_detail_title',
['name' => $this->name, 'type' => trans('master.master')]
['name' => $this->name, 'type' => __('master.master')]
),
]);
}

4
src/stubs/test-unit.stub

@ -18,9 +18,9 @@ class MasterTest extends TestCase
$this->assertEquals(
link_to_route('masters.show', $singleMstr->name, [$singleMstr], [
'title' => trans(
'title' => __(
'app.show_detail_title',
['name' => $singleMstr->name, 'type' => trans('master.master')]
['name' => $singleMstr->name, 'type' => __('master.master')]
),
]), $singleMstr->name_link
);

12
src/stubs/view-create.stub

@ -1,20 +1,20 @@
@extends('layouts.app')
@section('title', trans('master.create'))
@section('title', __('master.create'))
@section('content')
<div class="row">
<div class="col-md-6 col-md-offset-3">
<div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title">{{ trans('master.create') }}</h3></div>
<div class="panel-heading"><h3 class="panel-title">{{ __('master.create') }}</h3></div>
{!! Form::open(['route' => 'masters.store']) !!}
<div class="panel-body">
{!! FormField::text('name', ['required' => true, 'label' => trans('master.name')]) !!}
{!! FormField::textarea('description', ['label' => trans('master.description')]) !!}
{!! FormField::text('name', ['required' => true, 'label' => __('master.name')]) !!}
{!! FormField::textarea('description', ['label' => __('master.description')]) !!}
</div>
<div class="panel-footer">
{!! Form::submit(trans('master.create'), ['class' => 'btn btn-success']) !!}
{{ link_to_route('masters.index', trans('app.cancel'), [], ['class' => 'btn btn-default']) }}
{!! Form::submit(__('master.create'), ['class' => 'btn btn-success']) !!}
{{ link_to_route('masters.index', __('app.cancel'), [], ['class' => 'btn btn-default']) }}
</div>
{!! Form::close() !!}
</div>

26
src/stubs/view-edit.stub

@ -1,6 +1,6 @@
@extends('layouts.app')
@section('title', trans('master.edit'))
@section('title', __('master.edit'))
@section('content')
<div class="row">
@ -8,20 +8,20 @@
@if (request('action') == 'delete' && $singleMstr)
@can('delete', $singleMstr)
<div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title">{{ trans('master.delete') }}</h3></div>
<div class="panel-heading"><h3 class="panel-title">{{ __('master.delete') }}</h3></div>
<div class="panel-body">
<label class="control-label">{{ trans('master.name') }}</label>
<label class="control-label">{{ __('master.name') }}</label>
<p>{{ $singleMstr->name }}</p>
<label class="control-label">{{ trans('master.description') }}</label>
<label class="control-label">{{ __('master.description') }}</label>
<p>{{ $singleMstr->description }}</p>
{!! $errors->first('master_id', '<span class="form-error small">:message</span>') !!}
</div>
<hr style="margin:0">
<div class="panel-body">{{ trans('app.delete_confirm') }}</div>
<div class="panel-body">{{ __('app.delete_confirm') }}</div>
<div class="panel-footer">
{!! FormField::delete(
['route' => ['masters.destroy', $singleMstr]],
trans('app.delete_confirm_button'),
__('app.delete_confirm_button'),
['class'=>'btn btn-danger'],
[
'master_id' => $singleMstr->id,
@ -29,23 +29,23 @@
'q' => request('q'),
]
) !!}
{{ link_to_route('masters.edit', trans('app.cancel'), [$singleMstr], ['class' => 'btn btn-default']) }}
{{ link_to_route('masters.edit', __('app.cancel'), [$singleMstr], ['class' => 'btn btn-default']) }}
</div>
</div>
@endcan
@else
<div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title">{{ trans('master.edit') }}</h3></div>
<div class="panel-heading"><h3 class="panel-title">{{ __('master.edit') }}</h3></div>
{!! Form::model($singleMstr, ['route' => ['masters.update', $singleMstr],'method' => 'patch']) !!}
<div class="panel-body">
{!! FormField::text('name', ['required' => true, 'label' => trans('master.name')]) !!}
{!! FormField::textarea('description', ['label' => trans('master.description')]) !!}
{!! FormField::text('name', ['required' => true, 'label' => __('master.name')]) !!}
{!! FormField::textarea('description', ['label' => __('master.description')]) !!}
</div>
<div class="panel-footer">
{!! Form::submit(trans('master.update'), ['class' => 'btn btn-success']) !!}
{{ link_to_route('masters.show', trans('app.cancel'), [$singleMstr], ['class' => 'btn btn-default']) }}
{!! Form::submit(__('master.update'), ['class' => 'btn btn-success']) !!}
{{ link_to_route('masters.show', __('app.cancel'), [$singleMstr], ['class' => 'btn btn-default']) }}
@can('delete', $singleMstr)
{{ link_to_route('masters.edit', trans('app.delete'), [$singleMstr, 'action' => 'delete'], ['class' => 'btn btn-danger pull-right', 'id' => 'del-master-'.$singleMstr->id]) }}
{{ link_to_route('masters.edit', __('app.delete'), [$singleMstr, 'action' => 'delete'], ['class' => 'btn btn-danger pull-right', 'id' => 'del-master-'.$singleMstr->id]) }}
@endcan
</div>
{!! Form::close() !!}

30
src/stubs/view-forms.stub

@ -1,30 +1,30 @@
@if (Request::get('action') == 'create')
@can('create', new fullMstr)
{!! Form::open(['route' => 'masters.store']) !!}
{!! FormField::text('name', ['required' => true, 'label' => trans('master.name')]) !!}
{!! FormField::textarea('description', ['label' => trans('master.description')]) !!}
{!! Form::submit(trans('master.create'), ['class' => 'btn btn-success']) !!}
{{ link_to_route('masters.index', trans('app.cancel'), [], ['class' => 'btn btn-default']) }}
{!! FormField::text('name', ['required' => true, 'label' => __('master.name')]) !!}
{!! FormField::textarea('description', ['label' => __('master.description')]) !!}
{!! Form::submit(__('master.create'), ['class' => 'btn btn-success']) !!}
{{ link_to_route('masters.index', __('app.cancel'), [], ['class' => 'btn btn-default']) }}
{!! Form::close() !!}
@endcan
@endif
@if (Request::get('action') == 'edit' && $editableMaster)
@can('update', $editableMaster)
{!! Form::model($editableMaster, ['route' => ['masters.update', $editableMaster], 'method' => 'patch']) !!}
{!! FormField::text('name', ['required' => true, 'label' => trans('master.name')]) !!}
{!! FormField::textarea('description', ['label' => trans('master.description')]) !!}
{!! FormField::text('name', ['required' => true, 'label' => __('master.name')]) !!}
{!! FormField::textarea('description', ['label' => __('master.description')]) !!}
@if (request('q'))
{{ Form::hidden('q', request('q')) }}
@endif
@if (request('page'))
{{ Form::hidden('page', request('page')) }}
@endif
{!! Form::submit(trans('master.update'), ['class' => 'btn btn-success']) !!}
{{ link_to_route('masters.index', trans('app.cancel'), Request::only('page', 'q'), ['class' => 'btn btn-default']) }}
{!! Form::submit(__('master.update'), ['class' => 'btn btn-success']) !!}
{{ link_to_route('masters.index', __('app.cancel'), Request::only('page', 'q'), ['class' => 'btn btn-default']) }}
@can('delete', $singleMstr)
{!! link_to_route(
'masters.index',
trans('app.delete'),
__('app.delete'),
['action' => 'delete', 'id' => $singleMstr->id] + Request::only('page', 'q'),
['id' => 'del-master-'.$singleMstr->id, 'class' => 'btn btn-danger pull-right']
) !!}
@ -35,20 +35,20 @@
@if (Request::get('action') == 'delete' && $editableMaster)
@can('delete', $editableMaster)
<div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title">{{ trans('master.delete') }}</h3></div>
<div class="panel-heading"><h3 class="panel-title">{{ __('master.delete') }}</h3></div>
<div class="panel-body">
<label class="control-label">{{ trans('master.name') }}</label>
<label class="control-label">{{ __('master.name') }}</label>
<p>{{ $editableMaster->name }}</p>
<label class="control-label">{{ trans('master.description') }}</label>
<label class="control-label">{{ __('master.description') }}</label>
<p>{{ $editableMaster->description }}</p>
{!! $errors->first('master_id', '<span class="form-error small">:message</span>') !!}
</div>
<hr style="margin:0">
<div class="panel-body">{{ trans('app.delete_confirm') }}</div>
<div class="panel-body">{{ __('app.delete_confirm') }}</div>
<div class="panel-footer">
{!! FormField::delete(
['route' => ['masters.destroy', $editableMaster]],
trans('app.delete_confirm_button'),
__('app.delete_confirm_button'),
['class'=>'btn btn-danger'],
[
'master_id' => $editableMaster->id,
@ -56,7 +56,7 @@
'q' => request('q'),
]
) !!}
{{ link_to_route('masters.index', trans('app.cancel'), Request::only('page', 'q'), ['class' => 'btn btn-default']) }}
{{ link_to_route('masters.index', __('app.cancel'), Request::only('page', 'q'), ['class' => 'btn btn-default']) }}
</div>
</div>
@endcan

28
src/stubs/view-index-full.stub

@ -1,34 +1,34 @@
@extends('layouts.app')
@section('title', trans('master.list'))
@section('title', __('master.list'))
@section('content')
<h1 class="page-header">
<div class="pull-right">
@can('create', new fullMstr)
{{ link_to_route('masters.create', trans('master.create'), [], ['class' => 'btn btn-success']) }}
@endcan
@can('create', new fullMstr)
{{ link_to_route('masters.create', __('master.create'), [], ['class' => 'btn btn-success']) }}
@endcan
</div>
{{ trans('master.list') }}
<small>{{ trans('app.total') }} : {{ $mstrCollections->total() }} {{ trans('master.master') }}</small>
{{ __('master.list') }}
<small>{{ __('app.total') }} : {{ $mstrCollections->total() }} {{ __('master.master') }}</small>
</h1>
<div class="row">
<div class="col-md-12">
<div class="panel panel-default table-responsive">
<div class="panel-heading">
{{ 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')) }}
{!! FormField::text('q', ['value' => request('q'), 'label' => __('master.search'), 'class' => 'input-sm']) !!}
{{ Form::submit(__('master.search'), ['class' => 'btn btn-sm']) }}
{{ link_to_route('masters.index', __('app.reset')) }}
{{ Form::close() }}
</div>
<table class="table table-condensed">
<thead>
<tr>
<th class="text-center">{{ trans('app.table_no') }}</th>
<th>{{ trans('master.name') }}</th>
<th>{{ trans('master.description') }}</th>
<th class="text-center">{{ trans('app.action') }}</th>
<th class="text-center">{{ __('app.table_no') }}</th>
<th>{{ __('master.name') }}</th>
<th>{{ __('master.description') }}</th>
<th class="text-center">{{ __('app.action') }}</th>
</tr>
</thead>
<tbody>
@ -41,7 +41,7 @@
@can('view', $singleMstr)
{!! link_to_route(
'masters.show',
trans('app.show'),
__('app.show'),
[$singleMstr],
['class' => 'btn btn-default btn-xs', 'id' => 'show-master-' . $singleMstr->id]
) !!}

28
src/stubs/view-index-simple.stub

@ -1,34 +1,34 @@
@extends('layouts.app')
@section('title', trans('master.list'))
@section('title', __('master.list'))
@section('content')
<h1 class="page-header">
<div class="pull-right">
@can('create', new fullMstr)
{{ link_to_route('masters.index', trans('master.create'), ['action' => 'create'], ['class' => 'btn btn-success']) }}
@endcan
@can('create', new fullMstr)
{{ link_to_route('masters.index', __('master.create'), ['action' => 'create'], ['class' => 'btn btn-success']) }}
@endcan
</div>
{{ trans('master.list') }}
<small>{{ trans('app.total') }} : {{ $mstrCollections->total() }} {{ trans('master.master') }}</small>
{{ __('master.list') }}
<small>{{ __('app.total') }} : {{ $mstrCollections->total() }} {{ __('master.master') }}</small>
</h1>
<div class="row">
<div class="col-md-8">
<div class="panel panel-default table-responsive">
<div class="panel-heading">
{{ 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')) }}
{!! FormField::text('q', ['value' => request('q'), 'label' => __('master.search'), 'class' => 'input-sm']) !!}
{{ Form::submit(__('master.search'), ['class' => 'btn btn-sm']) }}
{{ link_to_route('masters.index', __('app.reset')) }}
{{ Form::close() }}
</div>
<table class="table table-condensed">
<thead>
<tr>
<th class="text-center">{{ trans('app.table_no') }}</th>
<th>{{ trans('master.name') }}</th>
<th>{{ trans('master.description') }}</th>
<th class="text-center">{{ trans('app.action') }}</th>
<th class="text-center">{{ __('app.table_no') }}</th>
<th>{{ __('master.name') }}</th>
<th>{{ __('master.description') }}</th>
<th class="text-center">{{ __('app.action') }}</th>
</tr>
</thead>
<tbody>
@ -41,7 +41,7 @@
@can('update', $singleMstr)
{!! link_to_route(
'masters.index',
trans('app.edit'),
__('app.edit'),
['action' => 'edit', 'id' => $singleMstr->id] + Request::only('page', 'q'),
['id' => 'edit-master-'.$singleMstr->id]
) !!}

12
src/stubs/view-show.stub

@ -1,23 +1,23 @@
@extends('layouts.app')
@section('title', trans('master.detail'))
@section('title', __('master.detail'))
@section('content')
<div class="row">
<div class="col-md-6 col-md-offset-3">
<div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title">{{ trans('master.detail') }}</h3></div>
<div class="panel-heading"><h3 class="panel-title">{{ __('master.detail') }}</h3></div>
<table class="table table-condensed">
<tbody>
<tr><td>{{ trans('master.name') }}</td><td>{{ $singleMstr->name }}</td></tr>
<tr><td>{{ trans('master.description') }}</td><td>{{ $singleMstr->description }}</td></tr>
<tr><td>{{ __('master.name') }}</td><td>{{ $singleMstr->name }}</td></tr>
<tr><td>{{ __('master.description') }}</td><td>{{ $singleMstr->description }}</td></tr>
</tbody>
</table>
<div class="panel-footer">
@can('update', $singleMstr)
{{ link_to_route('masters.edit', trans('master.edit'), [$singleMstr], ['class' => 'btn btn-warning', 'id' => 'edit-master-'.$singleMstr->id]) }}
{{ link_to_route('masters.edit', __('master.edit'), [$singleMstr], ['class' => 'btn btn-warning', 'id' => 'edit-master-'.$singleMstr->id]) }}
@endcan
{{ link_to_route('masters.index', trans('master.back_to_index'), [], ['class' => 'btn btn-default']) }}
{{ link_to_route('masters.index', __('master.back_to_index'), [], ['class' => 'btn btn-default']) }}
</div>
</div>
</div>

8
tests/Generators/ModelGeneratorTest.php

@ -27,9 +27,9 @@ class {$this->model_name} extends Model
public function getNameLinkAttribute()
{
return link_to_route('{$this->table_name}.show', \$this->name, [\$this], [
'title' => trans(
'title' => __(
'app.show_detail_title',
['name' => \$this->name, 'type' => trans('{$this->lang_name}.{$this->lang_name}')]
['name' => \$this->name, 'type' => __('{$this->lang_name}.{$this->lang_name}')]
),
]);
}
@ -64,9 +64,9 @@ class Category extends Model
public function getNameLinkAttribute()
{
return link_to_route('categories.show', \$this->name, [\$this], [
'title' => trans(
'title' => __(
'app.show_detail_title',
['name' => \$this->name, 'type' => trans('category.category')]
['name' => \$this->name, 'type' => __('category.category')]
),
]);
}

8
tests/Generators/ModelTestGeneratorTest.php

@ -33,9 +33,9 @@ class {$this->model_name}Test extends TestCase
\$this->assertEquals(
link_to_route('{$this->table_name}.show', \${$this->single_model_var_name}->name, [\${$this->single_model_var_name}], [
'title' => trans(
'title' => __(
'app.show_detail_title',
['name' => \${$this->single_model_var_name}->name, 'type' => trans('{$this->lang_name}.{$this->lang_name}')]
['name' => \${$this->single_model_var_name}->name, 'type' => __('{$this->lang_name}.{$this->lang_name}')]
),
]), \${$this->single_model_var_name}->name_link
);
@ -84,9 +84,9 @@ class {$this->model_name}Test extends TestCase
\$this->assertEquals(
link_to_route('{$this->table_name}.show', \${$this->single_model_var_name}->name, [\${$this->single_model_var_name}], [
'title' => trans(
'title' => __(
'app.show_detail_title',
['name' => \${$this->single_model_var_name}->name, 'type' => trans('{$this->lang_name}.{$this->lang_name}')]
['name' => \${$this->single_model_var_name}->name, 'type' => __('{$this->lang_name}.{$this->lang_name}')]
),
]), \${$this->single_model_var_name}->name_link
);

58
tests/Generators/Simple/ViewsGeneratorTest.php

@ -16,35 +16,35 @@ class ViewsGeneratorTest extends TestCase
$this->assertFileExists($indexViewPath);
$indexViewContent = "@extends('layouts.app')
@section('title', trans('{$this->lang_name}.list'))
@section('title', __('{$this->lang_name}.list'))
@section('content')
<h1 class=\"page-header\">
<div class=\"pull-right\">
@can('create', new {$this->full_model_name})
{{ link_to_route('{$this->table_name}.index', trans('{$this->lang_name}.create'), ['action' => 'create'], ['class' => 'btn btn-success']) }}
@endcan
@can('create', new {$this->full_model_name})
{{ link_to_route('{$this->table_name}.index', __('{$this->lang_name}.create'), ['action' => 'create'], ['class' => 'btn btn-success']) }}
@endcan
</div>
{{ trans('{$this->lang_name}.list') }}
<small>{{ trans('app.total') }} : {{ \${$this->collection_model_var_name}->total() }} {{ trans('{$this->lang_name}.{$this->lang_name}') }}</small>
{{ __('{$this->lang_name}.list') }}
<small>{{ __('app.total') }} : {{ \${$this->collection_model_var_name}->total() }} {{ __('{$this->lang_name}.{$this->lang_name}') }}</small>
</h1>
<div class=\"row\">
<div class=\"col-md-8\">
<div class=\"panel panel-default table-responsive\">
<div class=\"panel-heading\">
{{ Form::open(['method' => 'get', 'class' => 'form-inline']) }}
{!! FormField::text('q', ['value' => request('q'), 'label' => trans('{$this->lang_name}.search'), 'class' => 'input-sm']) !!}
{{ Form::submit(trans('{$this->lang_name}.search'), ['class' => 'btn btn-sm']) }}
{{ link_to_route('{$this->table_name}.index', trans('app.reset')) }}
{!! FormField::text('q', ['value' => request('q'), 'label' => __('{$this->lang_name}.search'), 'class' => 'input-sm']) !!}
{{ Form::submit(__('{$this->lang_name}.search'), ['class' => 'btn btn-sm']) }}
{{ link_to_route('{$this->table_name}.index', __('app.reset')) }}
{{ Form::close() }}
</div>
<table class=\"table table-condensed\">
<thead>
<tr>
<th class=\"text-center\">{{ trans('app.table_no') }}</th>
<th>{{ trans('{$this->lang_name}.name') }}</th>
<th>{{ trans('{$this->lang_name}.description') }}</th>
<th class=\"text-center\">{{ trans('app.action') }}</th>
<th class=\"text-center\">{{ __('app.table_no') }}</th>
<th>{{ __('{$this->lang_name}.name') }}</th>
<th>{{ __('{$this->lang_name}.description') }}</th>
<th class=\"text-center\">{{ __('app.action') }}</th>
</tr>
</thead>
<tbody>
@ -57,7 +57,7 @@ class ViewsGeneratorTest extends TestCase
@can('update', \${$this->single_model_var_name})
{!! link_to_route(
'{$this->table_name}.index',
trans('app.edit'),
__('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]
) !!}
@ -91,30 +91,30 @@ class ViewsGeneratorTest extends TestCase
$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' => trans('{$this->lang_name}.name')]) !!}
{!! FormField::textarea('description', ['label' => trans('{$this->lang_name}.description')]) !!}
{!! Form::submit(trans('{$this->lang_name}.create'), ['class' => 'btn btn-success']) !!}
{{ link_to_route('{$this->table_name}.index', trans('app.cancel'), [], ['class' => 'btn btn-default']) }}
{!! 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' => trans('{$this->lang_name}.name')]) !!}
{!! FormField::textarea('description', ['label' => trans('{$this->lang_name}.description')]) !!}
{!! 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(trans('{$this->lang_name}.update'), ['class' => 'btn btn-success']) !!}
{{ link_to_route('{$this->table_name}.index', trans('app.cancel'), Request::only('page', 'q'), ['class' => 'btn btn-default']) }}
{!! 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', \${$this->single_model_var_name})
{!! link_to_route(
'{$this->table_name}.index',
trans('app.delete'),
__('app.delete'),
['action' => 'delete', 'id' => \${$this->single_model_var_name}->id] + Request::only('page', 'q'),
['id' => 'del-{$this->lang_name}-'.\${$this->single_model_var_name}->id, 'class' => 'btn btn-danger pull-right']
) !!}
@ -125,20 +125,20 @@ class ViewsGeneratorTest extends TestCase
@if (Request::get('action') == 'delete' && \$editable{$this->model_name})
@can('delete', \$editable{$this->model_name})
<div class=\"panel panel-default\">
<div class=\"panel-heading\"><h3 class=\"panel-title\">{{ trans('{$this->lang_name}.delete') }}</h3></div>
<div class=\"panel-heading\"><h3 class=\"panel-title\">{{ __('{$this->lang_name}.delete') }}</h3></div>
<div class=\"panel-body\">
<label class=\"control-label\">{{ trans('{$this->lang_name}.name') }}</label>
<label class=\"control-label\">{{ __('{$this->lang_name}.name') }}</label>
<p>{{ \$editable{$this->model_name}->name }}</p>
<label class=\"control-label\">{{ trans('{$this->lang_name}.description') }}</label>
<label class=\"control-label\">{{ __('{$this->lang_name}.description') }}</label>
<p>{{ \$editable{$this->model_name}->description }}</p>
{!! \$errors->first('{$this->lang_name}_id', '<span class=\"form-error small\">:message</span>') !!}
</div>
<hr style=\"margin:0\">
<div class=\"panel-body\">{{ trans('app.delete_confirm') }}</div>
<div class=\"panel-body\">{{ __('app.delete_confirm') }}</div>
<div class=\"panel-footer\">
{!! FormField::delete(
['route' => ['{$this->table_name}.destroy', \$editable{$this->model_name}]],
trans('app.delete_confirm_button'),
__('app.delete_confirm_button'),
['class'=>'btn btn-danger'],
[
'{$this->lang_name}_id' => \$editable{$this->model_name}->id,
@ -146,7 +146,7 @@ class ViewsGeneratorTest extends TestCase
'q' => request('q'),
]
) !!}
{{ link_to_route('{$this->table_name}.index', trans('app.cancel'), Request::only('page', 'q'), ['class' => 'btn btn-default']) }}
{{ link_to_route('{$this->table_name}.index', __('app.cancel'), Request::only('page', 'q'), ['class' => 'btn btn-default']) }}
</div>
</div>
@endcan

78
tests/Generators/ViewsGeneratorTest.php

@ -16,35 +16,35 @@ class ViewsGeneratorTest extends TestCase
$this->assertFileExists($indexViewPath);
$indexViewContent = "@extends('layouts.app')
@section('title', trans('{$this->lang_name}.list'))
@section('title', __('{$this->lang_name}.list'))
@section('content')
<h1 class=\"page-header\">
<div class=\"pull-right\">
@can('create', new {$this->full_model_name})
{{ link_to_route('{$this->table_name}.create', trans('{$this->lang_name}.create'), [], ['class' => 'btn btn-success']) }}
@endcan
@can('create', new {$this->full_model_name})
{{ link_to_route('{$this->table_name}.create', __('{$this->lang_name}.create'), [], ['class' => 'btn btn-success']) }}
@endcan
</div>
{{ trans('{$this->lang_name}.list') }}
<small>{{ trans('app.total') }} : {{ \${$this->collection_model_var_name}->total() }} {{ trans('{$this->lang_name}.{$this->lang_name}') }}</small>
{{ __('{$this->lang_name}.list') }}
<small>{{ __('app.total') }} : {{ \${$this->collection_model_var_name}->total() }} {{ __('{$this->lang_name}.{$this->lang_name}') }}</small>
</h1>
<div class=\"row\">
<div class=\"col-md-12\">
<div class=\"panel panel-default table-responsive\">
<div class=\"panel-heading\">
{{ Form::open(['method' => 'get','class' => 'form-inline']) }}
{!! FormField::text('q', ['value' => request('q'), 'label' => trans('{$this->lang_name}.search'), 'class' => 'input-sm']) !!}
{{ Form::submit(trans('{$this->lang_name}.search'), ['class' => 'btn btn-sm']) }}
{{ link_to_route('{$this->table_name}.index', trans('app.reset')) }}
{!! FormField::text('q', ['value' => request('q'), 'label' => __('{$this->lang_name}.search'), 'class' => 'input-sm']) !!}
{{ Form::submit(__('{$this->lang_name}.search'), ['class' => 'btn btn-sm']) }}
{{ link_to_route('{$this->table_name}.index', __('app.reset')) }}
{{ Form::close() }}
</div>
<table class=\"table table-condensed\">
<thead>
<tr>
<th class=\"text-center\">{{ trans('app.table_no') }}</th>
<th>{{ trans('{$this->lang_name}.name') }}</th>
<th>{{ trans('{$this->lang_name}.description') }}</th>
<th class=\"text-center\">{{ trans('app.action') }}</th>
<th class=\"text-center\">{{ __('app.table_no') }}</th>
<th>{{ __('{$this->lang_name}.name') }}</th>
<th>{{ __('{$this->lang_name}.description') }}</th>
<th class=\"text-center\">{{ __('app.action') }}</th>
</tr>
</thead>
<tbody>
@ -57,7 +57,7 @@ class ViewsGeneratorTest extends TestCase
@can('view', \${$this->single_model_var_name})
{!! link_to_route(
'{$this->table_name}.show',
trans('app.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]
) !!}
@ -85,24 +85,24 @@ class ViewsGeneratorTest extends TestCase
$this->assertFileExists($showFormViewPath);
$showFormViewContent = "@extends('layouts.app')
@section('title', trans('{$this->lang_name}.detail'))
@section('title', __('{$this->lang_name}.detail'))
@section('content')
<div class=\"row\">
<div class=\"col-md-6 col-md-offset-3\">
<div class=\"panel panel-default\">
<div class=\"panel-heading\"><h3 class=\"panel-title\">{{ trans('{$this->lang_name}.detail') }}</h3></div>
<div class=\"panel-heading\"><h3 class=\"panel-title\">{{ __('{$this->lang_name}.detail') }}</h3></div>
<table class=\"table table-condensed\">
<tbody>
<tr><td>{{ trans('{$this->lang_name}.name') }}</td><td>{{ \${$this->single_model_var_name}->name }}</td></tr>
<tr><td>{{ trans('{$this->lang_name}.description') }}</td><td>{{ \${$this->single_model_var_name}->description }}</td></tr>
<tr><td>{{ __('{$this->lang_name}.name') }}</td><td>{{ \${$this->single_model_var_name}->name }}</td></tr>
<tr><td>{{ __('{$this->lang_name}.description') }}</td><td>{{ \${$this->single_model_var_name}->description }}</td></tr>
</tbody>
</table>
<div class=\"panel-footer\">
@can('update', \${$this->single_model_var_name})
{{ link_to_route('{$this->table_name}.edit', trans('{$this->lang_name}.edit'), [\${$this->single_model_var_name}], ['class' => 'btn btn-warning', 'id' => 'edit-{$this->lang_name}-'.\${$this->single_model_var_name}->id]) }}
{{ link_to_route('{$this->table_name}.edit', __('{$this->lang_name}.edit'), [\${$this->single_model_var_name}], ['class' => 'btn btn-warning', 'id' => 'edit-{$this->lang_name}-'.\${$this->single_model_var_name}->id]) }}
@endcan
{{ link_to_route('{$this->table_name}.index', trans('{$this->lang_name}.back_to_index'), [], ['class' => 'btn btn-default']) }}
{{ link_to_route('{$this->table_name}.index', __('{$this->lang_name}.back_to_index'), [], ['class' => 'btn btn-default']) }}
</div>
</div>
</div>
@ -121,21 +121,21 @@ class ViewsGeneratorTest extends TestCase
$this->assertFileExists($createFormViewPath);
$createFormViewContent = "@extends('layouts.app')
@section('title', trans('{$this->lang_name}.create'))
@section('title', __('{$this->lang_name}.create'))
@section('content')
<div class=\"row\">
<div class=\"col-md-6 col-md-offset-3\">
<div class=\"panel panel-default\">
<div class=\"panel-heading\"><h3 class=\"panel-title\">{{ trans('{$this->lang_name}.create') }}</h3></div>
<div class=\"panel-heading\"><h3 class=\"panel-title\">{{ __('{$this->lang_name}.create') }}</h3></div>
{!! Form::open(['route' => '{$this->table_name}.store']) !!}
<div class=\"panel-body\">
{!! FormField::text('name', ['required' => true, 'label' => trans('{$this->lang_name}.name')]) !!}
{!! FormField::textarea('description', ['label' => trans('{$this->lang_name}.description')]) !!}
{!! FormField::text('name', ['required' => true, 'label' => __('{$this->lang_name}.name')]) !!}
{!! FormField::textarea('description', ['label' => __('{$this->lang_name}.description')]) !!}
</div>
<div class=\"panel-footer\">
{!! Form::submit(trans('{$this->lang_name}.create'), ['class' => 'btn btn-success']) !!}
{{ link_to_route('{$this->table_name}.index', trans('app.cancel'), [], ['class' => 'btn btn-default']) }}
{!! Form::submit(__('{$this->lang_name}.create'), ['class' => 'btn btn-success']) !!}
{{ link_to_route('{$this->table_name}.index', __('app.cancel'), [], ['class' => 'btn btn-default']) }}
</div>
{!! Form::close() !!}
</div>
@ -155,7 +155,7 @@ class ViewsGeneratorTest extends TestCase
$this->assertFileExists($editFormViewPath);
$editFormViewContent = "@extends('layouts.app')
@section('title', trans('{$this->lang_name}.edit'))
@section('title', __('{$this->lang_name}.edit'))
@section('content')
<div class=\"row\">
@ -163,20 +163,20 @@ class ViewsGeneratorTest extends TestCase
@if (request('action') == 'delete' && \${$this->single_model_var_name})
@can('delete', \${$this->single_model_var_name})
<div class=\"panel panel-default\">
<div class=\"panel-heading\"><h3 class=\"panel-title\">{{ trans('{$this->lang_name}.delete') }}</h3></div>
<div class=\"panel-heading\"><h3 class=\"panel-title\">{{ __('{$this->lang_name}.delete') }}</h3></div>
<div class=\"panel-body\">
<label class=\"control-label\">{{ trans('{$this->lang_name}.name') }}</label>
<label class=\"control-label\">{{ __('{$this->lang_name}.name') }}</label>
<p>{{ \${$this->single_model_var_name}->name }}</p>
<label class=\"control-label\">{{ trans('{$this->lang_name}.description') }}</label>
<label class=\"control-label\">{{ __('{$this->lang_name}.description') }}</label>
<p>{{ \${$this->single_model_var_name}->description }}</p>
{!! \$errors->first('{$this->lang_name}_id', '<span class=\"form-error small\">:message</span>') !!}
</div>
<hr style=\"margin:0\">
<div class=\"panel-body\">{{ trans('app.delete_confirm') }}</div>
<div class=\"panel-body\">{{ __('app.delete_confirm') }}</div>
<div class=\"panel-footer\">
{!! FormField::delete(
['route' => ['{$this->table_name}.destroy', \${$this->single_model_var_name}]],
trans('app.delete_confirm_button'),
__('app.delete_confirm_button'),
['class'=>'btn btn-danger'],
[
'{$this->lang_name}_id' => \${$this->single_model_var_name}->id,
@ -184,23 +184,23 @@ class ViewsGeneratorTest extends TestCase
'q' => request('q'),
]
) !!}
{{ link_to_route('{$this->table_name}.edit', trans('app.cancel'), [\${$this->single_model_var_name}], ['class' => 'btn btn-default']) }}
{{ link_to_route('{$this->table_name}.edit', __('app.cancel'), [\${$this->single_model_var_name}], ['class' => 'btn btn-default']) }}
</div>
</div>
@endcan
@else
<div class=\"panel panel-default\">
<div class=\"panel-heading\"><h3 class=\"panel-title\">{{ trans('{$this->lang_name}.edit') }}</h3></div>
<div class=\"panel-heading\"><h3 class=\"panel-title\">{{ __('{$this->lang_name}.edit') }}</h3></div>
{!! Form::model(\${$this->single_model_var_name}, ['route' => ['{$this->table_name}.update', \${$this->single_model_var_name}],'method' => 'patch']) !!}
<div class=\"panel-body\">
{!! FormField::text('name', ['required' => true, 'label' => trans('{$this->lang_name}.name')]) !!}
{!! FormField::textarea('description', ['label' => trans('{$this->lang_name}.description')]) !!}
{!! FormField::text('name', ['required' => true, 'label' => __('{$this->lang_name}.name')]) !!}
{!! FormField::textarea('description', ['label' => __('{$this->lang_name}.description')]) !!}
</div>
<div class=\"panel-footer\">
{!! Form::submit(trans('{$this->lang_name}.update'), ['class' => 'btn btn-success']) !!}
{{ link_to_route('{$this->table_name}.show', trans('app.cancel'), [\${$this->single_model_var_name}], ['class' => 'btn btn-default']) }}
{!! Form::submit(__('{$this->lang_name}.update'), ['class' => 'btn btn-success']) !!}
{{ link_to_route('{$this->table_name}.show', __('app.cancel'), [\${$this->single_model_var_name}], ['class' => 'btn btn-default']) }}
@can('delete', \${$this->single_model_var_name})
{{ link_to_route('{$this->table_name}.edit', trans('app.delete'), [\${$this->single_model_var_name}, 'action' => 'delete'], ['class' => 'btn btn-danger pull-right', 'id' => 'del-{$this->lang_name}-'.\${$this->single_model_var_name}->id]) }}
{{ link_to_route('{$this->table_name}.edit', __('app.delete'), [\${$this->single_model_var_name}, 'action' => 'delete'], ['class' => 'btn btn-danger pull-right', 'id' => 'del-{$this->lang_name}-'.\${$this->single_model_var_name}->id]) }}
@endcan
</div>
{!! Form::close() !!}

Loading…
Cancel
Save