Browse Source

Merge branch 'formfield-bootstrap4'

tags/1.2.2
Nafies Luthfi 7 years ago
parent
commit
02d5ddead3
  1. 23
      src/stubs/resources/views/full/create-formfield-bs3.stub
  2. 14
      src/stubs/resources/views/full/create-formfield.stub
  3. 6
      src/stubs/resources/views/full/edit-bs3.stub
  4. 56
      src/stubs/resources/views/full/edit-formfield-bs3.stub
  5. 34
      src/stubs/resources/views/full/edit-formfield.stub
  6. 58
      src/stubs/resources/views/full/index-formfield-bs3.stub
  7. 18
      src/stubs/resources/views/full/index-formfield.stub
  8. 25
      src/stubs/resources/views/full/show-formfield-bs3.stub
  9. 14
      src/stubs/resources/views/full/show-formfield.stub
  10. 6
      src/stubs/resources/views/simple/forms-bs3.stub
  11. 63
      src/stubs/resources/views/simple/forms-formfield-bs3.stub
  12. 22
      src/stubs/resources/views/simple/forms-formfield.stub
  13. 63
      src/stubs/resources/views/simple/index-formfield-bs3.stub
  14. 12
      src/stubs/resources/views/simple/index-formfield.stub
  15. 6
      tests/CommandOptions/FullCrudBs3OptionsTest.php
  16. 245
      tests/CommandOptions/FullCrudFormfieldBs3OptionsTest.php
  17. 80
      tests/CommandOptions/FullCrudFormfieldOptionsTest.php
  18. 6
      tests/CommandOptions/SimpleCrudBs3OptionsTest.php
  19. 183
      tests/CommandOptions/SimpleCrudFormfieldBs3OptionsTest.php
  20. 34
      tests/CommandOptions/SimpleCrudFormfieldOptionsTest.php

23
src/stubs/resources/views/full/create-formfield-bs3.stub

@ -0,0 +1,23 @@
@extends('layouts.app')
@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">{{ __('master.create') }}</h3></div>
{{ Form::open(['route' => 'masters.store']) }}
<div class="panel-body">
{!! FormField::text('name', ['required' => true, 'label' => __('master.name')]) !!}
{!! FormField::textarea('description', ['label' => __('master.description')]) !!}
</div>
<div class="panel-footer">
{{ Form::submit(__('master.create'), ['class' => 'btn btn-success']) }}
{{ link_to_route('masters.index', __('app.cancel'), [], ['class' => 'btn btn-default']) }}
</div>
{{ Form::close() }}
</div>
</div>
</div>
@endsection

14
src/stubs/resources/views/full/create-formfield.stub

@ -3,18 +3,18 @@
@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">{{ __('master.create') }}</h3></div>
<div class="row justify-content-center">
<div class="col-md-6">
<div class="card">
<div class="card-header">{{ __('master.create') }}</div>
{{ Form::open(['route' => 'masters.store']) }}
<div class="panel-body">
<div class="card-body">
{!! FormField::text('name', ['required' => true, 'label' => __('master.name')]) !!}
{!! FormField::textarea('description', ['label' => __('master.description')]) !!}
</div>
<div class="panel-footer">
<div class="card-footer">
{{ Form::submit(__('master.create'), ['class' => 'btn btn-success']) }}
{{ link_to_route('masters.index', __('app.cancel'), [], ['class' => 'btn btn-default']) }}
{{ link_to_route('masters.index', __('app.cancel'), [], ['class' => 'btn btn-link']) }}
</div>
{{ Form::close() }}
</div>

6
src/stubs/resources/views/full/edit-bs3.stub

@ -10,14 +10,14 @@
<div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title">{{ __('master.delete') }}</h3></div>
<div class="panel-body">
<label class="control-label">{{ __('master.name') }}</label>
<label class="control-label text-primary">{{ __('master.name') }}</label>
<p>{{ $singleMstr->name }}</p>
<label class="control-label">{{ __('master.description') }}</label>
<label class="control-label text-primary">{{ __('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">{{ __('master.delete_confirm') }}</div>
<div class="panel-body text-danger">{{ __('master.delete_confirm') }}</div>
<div class="panel-footer">
<form method="POST" action="{{ route('masters.destroy', $singleMstr) }}" accept-charset="UTF-8" onsubmit="return confirm(&quot;Are you sure to delete this?&quot;)" class="del-form pull-right" style="display: inline;">
{{ csrf_field() }} {{ method_field('delete') }}

56
src/stubs/resources/views/full/edit-formfield-bs3.stub

@ -0,0 +1,56 @@
@extends('layouts.app')
@section('title', __('master.edit'))
@section('content')
<div class="row">
<div class="col-md-6 col-md-offset-3">
@if (request('action') == 'delete' && $singleMstr)
@can('delete', $singleMstr)
<div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title">{{ __('master.delete') }}</h3></div>
<div class="panel-body">
<label class="control-label text-primary">{{ __('master.name') }}</label>
<p>{{ $singleMstr->name }}</p>
<label class="control-label text-primary">{{ __('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 text-danger">{{ __('master.delete_confirm') }}</div>
<div class="panel-footer">
{!! FormField::delete(
['route' => ['masters.destroy', $singleMstr]],
__('app.delete_confirm_button'),
['class'=>'btn btn-danger'],
[
'master_id' => $singleMstr->id,
'page' => request('page'),
'q' => request('q'),
]
) !!}
{{ 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">{{ __('master.edit') }}</h3></div>
{{ Form::model($singleMstr, ['route' => ['masters.update', $singleMstr], 'method' => 'patch']) }}
<div class="panel-body">
{!! FormField::text('name', ['required' => true, 'label' => __('master.name')]) !!}
{!! FormField::textarea('description', ['label' => __('master.description')]) !!}
</div>
<div class="panel-footer">
{{ 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', __('app.delete'), [$singleMstr, 'action' => 'delete'], ['class' => 'btn btn-danger pull-right', 'id' => 'del-master-'.$singleMstr->id]) }}
@endcan
</div>
{{ Form::close() }}
</div>
</div>
</div>
@endif
@endsection

34
src/stubs/resources/views/full/edit-formfield.stub

@ -3,22 +3,22 @@
@section('title', __('master.edit'))
@section('content')
<div class="row">
<div class="col-md-6 col-md-offset-3">
<div class="row justify-content-center">
<div class="col-md-6">
@if (request('action') == 'delete' && $singleMstr)
@can('delete', $singleMstr)
<div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title">{{ __('master.delete') }}</h3></div>
<div class="panel-body">
<label class="control-label">{{ __('master.name') }}</label>
<div class="card">
<div class="card-header">{{ __('master.delete') }}</div>
<div class="card-body">
<label class="control-label text-primary">{{ __('master.name') }}</label>
<p>{{ $singleMstr->name }}</p>
<label class="control-label">{{ __('master.description') }}</label>
<label class="control-label text-primary">{{ __('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">{{ __('master.delete_confirm') }}</div>
<div class="panel-footer">
<div class="card-body text-danger">{{ __('master.delete_confirm') }}</div>
<div class="card-footer">
{!! FormField::delete(
['route' => ['masters.destroy', $singleMstr]],
__('app.delete_confirm_button'),
@ -29,23 +29,23 @@
'q' => request('q'),
]
) !!}
{{ link_to_route('masters.edit', __('app.cancel'), [$singleMstr], ['class' => 'btn btn-default']) }}
{{ link_to_route('masters.edit', __('app.cancel'), [$singleMstr], ['class' => 'btn btn-link']) }}
</div>
</div>
@endcan
@else
<div class="panel panel-default">
<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">
<div class="card">
<div class="card-header">{{ __('master.edit') }}</div>
{{ Form::model($singleMstr, ['route' => ['masters.update', $singleMstr], 'method' => 'patch']) }}
<div class="card-body">
{!! FormField::text('name', ['required' => true, 'label' => __('master.name')]) !!}
{!! FormField::textarea('description', ['label' => __('master.description')]) !!}
</div>
<div class="panel-footer">
<div class="card-footer">
{{ Form::submit(__('master.update'), ['class' => 'btn btn-success']) }}
{{ link_to_route('masters.show', __('app.cancel'), [$singleMstr], ['class' => 'btn btn-default']) }}
{{ link_to_route('masters.show', __('app.cancel'), [$singleMstr], ['class' => 'btn btn-link']) }}
@can('delete', $singleMstr)
{{ link_to_route('masters.edit', __('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 float-right', 'id' => 'del-master-'.$singleMstr->id]) }}
@endcan
</div>
{{ Form::close() }}

58
src/stubs/resources/views/full/index-formfield-bs3.stub

@ -0,0 +1,58 @@
@extends('layouts.app')
@section('title', __('master.list'))
@section('content')
<h1 class="page-header">
<div class="pull-right">
@can('create', new fullMstr)
{{ link_to_route('masters.create', __('master.create'), [], ['class' => 'btn btn-success']) }}
@endcan
</div>
{{ __('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', ['label' => __('master.search'), 'placeholder' => __('master.search_text'), '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">{{ __('app.table_no') }}</th>
<th>{{ __('master.name') }}</th>
<th>{{ __('master.description') }}</th>
<th class="text-center">{{ __('app.action') }}</th>
</tr>
</thead>
<tbody>
@foreach($mstrCollections as $key => $singleMstr)
<tr>
<td class="text-center">{{ $mstrCollections->firstItem() + $key }}</td>
<td>{{ $singleMstr->name_link }}</td>
<td>{{ $singleMstr->description }}</td>
<td class="text-center">
@can('view', $singleMstr)
{{ link_to_route(
'masters.show',
__('app.show'),
[$singleMstr],
['class' => 'btn btn-default btn-xs', 'id' => 'show-master-' . $singleMstr->id]
) }}
@endcan
</td>
</tr>
@endforeach
</tbody>
</table>
<div class="panel-body">{{ $mstrCollections->appends(Request::except('page'))->render() }}</div>
</div>
</div>
</div>
@endsection

18
src/stubs/resources/views/full/index-formfield.stub

@ -3,8 +3,8 @@
@section('title', __('master.list'))
@section('content')
<h1 class="page-header">
<div class="pull-right">
<h1>
<div class="float-right">
@can('create', new fullMstr)
{{ link_to_route('masters.create', __('master.create'), [], ['class' => 'btn btn-success']) }}
@endcan
@ -14,15 +14,15 @@
</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', ['label' => __('master.search'), 'placeholder' => __('master.search_text'), 'class' => 'input-sm']) !!}
<div class="card table-responsive">
<div class="card-header">
{{ Form::open(['method' => 'get', 'class' => 'form-inline']) }}
{!! FormField::text('q', ['label' => __('master.search'), 'placeholder' => __('master.search_text'), 'class' => 'form-control-sm']) !!}
{{ Form::submit(__('master.search'), ['class' => 'btn btn-sm']) }}
{{ link_to_route('masters.index', __('app.reset')) }}
{{ Form::close() }}
</div>
<table class="table table-condensed">
<table class="table table-sm">
<thead>
<tr>
<th class="text-center">{{ __('app.table_no') }}</th>
@ -43,7 +43,7 @@
'masters.show',
__('app.show'),
[$singleMstr],
['class' => 'btn btn-default btn-xs', 'id' => 'show-master-' . $singleMstr->id]
['id' => 'show-master-' . $singleMstr->id]
) }}
@endcan
</td>
@ -51,7 +51,7 @@
@endforeach
</tbody>
</table>
<div class="panel-body">{{ $mstrCollections->appends(Request::except('page'))->render() }}</div>
<div class="card-body">{{ $mstrCollections->appends(Request::except('page'))->render() }}</div>
</div>
</div>
</div>

25
src/stubs/resources/views/full/show-formfield-bs3.stub

@ -0,0 +1,25 @@
@extends('layouts.app')
@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">{{ __('master.detail') }}</h3></div>
<table class="table table-condensed">
<tbody>
<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', __('master.edit'), [$singleMstr], ['class' => 'btn btn-warning', 'id' => 'edit-master-'.$singleMstr->id]) }}
@endcan
{{ link_to_route('masters.index', __('master.back_to_index'), [], ['class' => 'btn btn-default']) }}
</div>
</div>
</div>
</div>
@endsection

14
src/stubs/resources/views/full/show-formfield.stub

@ -3,21 +3,21 @@
@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">{{ __('master.detail') }}</h3></div>
<table class="table table-condensed">
<div class="row justify-content-center">
<div class="col-md-6">
<div class="card">
<div class="card-header">{{ __('master.detail') }}</div>
<table class="table table-sm">
<tbody>
<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">
<div class="card-footer">
@can('update', $singleMstr)
{{ link_to_route('masters.edit', __('master.edit'), [$singleMstr], ['class' => 'btn btn-warning', 'id' => 'edit-master-'.$singleMstr->id]) }}
@endcan
{{ link_to_route('masters.index', __('master.back_to_index'), [], ['class' => 'btn btn-default']) }}
{{ link_to_route('masters.index', __('master.back_to_index'), [], ['class' => 'btn btn-link']) }}
</div>
</div>
</div>

6
src/stubs/resources/views/simple/forms-bs3.stub

@ -46,14 +46,14 @@
<div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title">{{ __('master.delete') }}</h3></div>
<div class="panel-body">
<label class="control-label">{{ __('master.name') }}</label>
<label class="control-label text-primary">{{ __('master.name') }}</label>
<p>{{ $editableMaster->name }}</p>
<label class="control-label">{{ __('master.description') }}</label>
<label class="control-label text-primary">{{ __('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">{{ __('master.delete_confirm') }}</div>
<div class="panel-body text-danger">{{ __('master.delete_confirm') }}</div>
<div class="panel-footer">
<form method="POST" action="{{ route('masters.destroy', $editableMaster) }}" accept-charset="UTF-8" onsubmit="return confirm(&quot;Are you sure to delete this?&quot;)" class="del-form pull-right" style="display: inline;">
{{ csrf_field() }} {{ method_field('delete') }}

63
src/stubs/resources/views/simple/forms-formfield-bs3.stub

@ -0,0 +1,63 @@
@if (Request::get('action') == 'create')
@can('create', new fullMstr)
{{ Form::open(['route' => 'masters.store']) }}
{!! 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' => __('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(__('master.update'), ['class' => 'btn btn-success']) }}
{{ link_to_route('masters.index', __('app.cancel'), Request::only('page', 'q'), ['class' => 'btn btn-default']) }}
@can('delete', $editableMaster)
{{ link_to_route(
'masters.index',
__('app.delete'),
['action' => 'delete', 'id' => $editableMaster->id] + Request::only('page', 'q'),
['id' => 'del-master-'.$editableMaster->id, 'class' => 'btn btn-danger pull-right']
) }}
@endcan
{{ Form::close() }}
@endcan
@endif
@if (Request::get('action') == 'delete' && $editableMaster)
@can('delete', $editableMaster)
<div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title">{{ __('master.delete') }}</h3></div>
<div class="panel-body">
<label class="control-label text-primary">{{ __('master.name') }}</label>
<p>{{ $editableMaster->name }}</p>
<label class="control-label text-primary">{{ __('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 text-danger">{{ __('master.delete_confirm') }}</div>
<div class="panel-footer">
{!! FormField::delete(
['route' => ['masters.destroy', $editableMaster]],
__('app.delete_confirm_button'),
['class'=>'btn btn-danger'],
[
'master_id' => $editableMaster->id,
'page' => request('page'),
'q' => request('q'),
]
) !!}
{{ link_to_route('masters.index', __('app.cancel'), Request::only('page', 'q'), ['class' => 'btn btn-default']) }}
</div>
</div>
@endcan
@endif

22
src/stubs/resources/views/simple/forms-formfield.stub

@ -4,7 +4,7 @@
{!! 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']) }}
{{ link_to_route('masters.index', __('app.cancel'), [], ['class' => 'btn btn-link']) }}
{{ Form::close() }}
@endcan
@endif
@ -20,13 +20,13 @@
{{ Form::hidden('page', request('page')) }}
@endif
{{ Form::submit(__('master.update'), ['class' => 'btn btn-success']) }}
{{ link_to_route('masters.index', __('app.cancel'), Request::only('page', 'q'), ['class' => 'btn btn-default']) }}
{{ link_to_route('masters.index', __('app.cancel'), Request::only('page', 'q'), ['class' => 'btn btn-link']) }}
@can('delete', $editableMaster)
{{ link_to_route(
'masters.index',
__('app.delete'),
['action' => 'delete', 'id' => $editableMaster->id] + Request::only('page', 'q'),
['id' => 'del-master-'.$editableMaster->id, 'class' => 'btn btn-danger pull-right']
['id' => 'del-master-'.$editableMaster->id, 'class' => 'btn btn-danger float-right']
) }}
@endcan
{{ Form::close() }}
@ -34,18 +34,18 @@
@endif
@if (Request::get('action') == 'delete' && $editableMaster)
@can('delete', $editableMaster)
<div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title">{{ __('master.delete') }}</h3></div>
<div class="panel-body">
<label class="control-label">{{ __('master.name') }}</label>
<div class="card">
<div class="card-header">{{ __('master.delete') }}</div>
<div class="card-body">
<label class="control-label text-primary">{{ __('master.name') }}</label>
<p>{{ $editableMaster->name }}</p>
<label class="control-label">{{ __('master.description') }}</label>
<label class="control-label text-primary">{{ __('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">{{ __('master.delete_confirm') }}</div>
<div class="panel-footer">
<div class="card-body text-danger">{{ __('master.delete_confirm') }}</div>
<div class="card-footer">
{!! FormField::delete(
['route' => ['masters.destroy', $editableMaster]],
__('app.delete_confirm_button'),
@ -56,7 +56,7 @@
'q' => request('q'),
]
) !!}
{{ link_to_route('masters.index', __('app.cancel'), Request::only('page', 'q'), ['class' => 'btn btn-default']) }}
{{ link_to_route('masters.index', __('app.cancel'), Request::only('page', 'q'), ['class' => 'btn btn-link']) }}
</div>
</div>
@endcan

63
src/stubs/resources/views/simple/index-formfield-bs3.stub

@ -0,0 +1,63 @@
@extends('layouts.app')
@section('title', __('master.list'))
@section('content')
<h1 class="page-header">
<div class="pull-right">
@can('create', new fullMstr)
{{ link_to_route('masters.index', __('master.create'), ['action' => 'create'], ['class' => 'btn btn-success']) }}
@endcan
</div>
{{ __('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', ['label' => __('master.search'), 'placeholder' => __('master.search_text'), '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">{{ __('app.table_no') }}</th>
<th>{{ __('master.name') }}</th>
<th>{{ __('master.description') }}</th>
<th class="text-center">{{ __('app.action') }}</th>
</tr>
</thead>
<tbody>
@foreach($mstrCollections as $key => $singleMstr)
<tr>
<td class="text-center">{{ $mstrCollections->firstItem() + $key }}</td>
<td>{{ $singleMstr->name }}</td>
<td>{{ $singleMstr->description }}</td>
<td class="text-center">
@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
</td>
</tr>
@endforeach
</tbody>
</table>
<div class="panel-body">{{ $mstrCollections->appends(Request::except('page'))->render() }}</div>
</div>
</div>
<div class="col-md-4">
@if(Request::has('action'))
@include('masters.forms')
@endif
</div>
</div>
@endsection

12
src/stubs/resources/views/simple/index-formfield.stub

@ -3,8 +3,8 @@
@section('title', __('master.list'))
@section('content')
<h1 class="page-header">
<div class="pull-right">
<h1>
<div class="float-right">
@can('create', new fullMstr)
{{ link_to_route('masters.index', __('master.create'), ['action' => 'create'], ['class' => 'btn btn-success']) }}
@endcan
@ -14,15 +14,15 @@
</h1>
<div class="row">
<div class="col-md-8">
<div class="panel panel-default table-responsive">
<div class="panel-heading">
<div class="card table-responsive">
<div class="card-header">
{{ Form::open(['method' => 'get', 'class' => 'form-inline']) }}
{!! FormField::text('q', ['label' => __('master.search'), 'placeholder' => __('master.search_text'), '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">
<table class="table table-sm">
<thead>
<tr>
<th class="text-center">{{ __('app.table_no') }}</th>
@ -51,7 +51,7 @@
@endforeach
</tbody>
</table>
<div class="panel-body">{{ $mstrCollections->appends(Request::except('page'))->render() }}</div>
<div class="card-body">{{ $mstrCollections->appends(Request::except('page'))->render() }}</div>
</div>
</div>
<div class="col-md-4">

6
tests/CommandOptions/FullCrudBs3OptionsTest.php

@ -201,14 +201,14 @@ class FullCrudBs3OptionsTest extends TestCase
<div class=\"panel panel-default\">
<div class=\"panel-heading\"><h3 class=\"panel-title\">{{ __('{$this->lang_name}.delete') }}</h3></div>
<div class=\"panel-body\">
<label class=\"control-label\">{{ __('{$this->lang_name}.name') }}</label>
<label class=\"control-label text-primary\">{{ __('{$this->lang_name}.name') }}</label>
<p>{{ \${$this->single_model_var_name}->name }}</p>
<label class=\"control-label\">{{ __('{$this->lang_name}.description') }}</label>
<label class=\"control-label text-primary\">{{ __('{$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\">{{ __('{$this->lang_name}.delete_confirm') }}</div>
<div class=\"panel-body text-danger\">{{ __('{$this->lang_name}.delete_confirm') }}</div>
<div class=\"panel-footer\">
<form method=\"POST\" action=\"{{ route('{$this->table_name}.destroy', \${$this->single_model_var_name}) }}\" accept-charset=\"UTF-8\" onsubmit=\"return confirm(&quot;Are you sure to delete this?&quot;)\" class=\"del-form pull-right\" style=\"display: inline;\">
{{ csrf_field() }} {{ method_field('delete') }}

245
tests/CommandOptions/FullCrudFormfieldBs3OptionsTest.php

@ -0,0 +1,245 @@
<?php
namespace Tests\CommandOptions;
use Tests\TestCase;
use Illuminate\Contracts\Console\Kernel;
class FullCrudFormfieldBs3OptionsTest extends TestCase
{
/** @test */
public function it_can_generate_views_with_formfield_and_bootstrap3_for_full_crud()
{
$this->artisan('make:crud', ['name' => $this->model_name, '--formfield' => true, '--bs3' => true]);
$this->assertNotContains("{$this->model_name} model already exists.", app(Kernel::class)->output());
$this->assertFileExists(app_path($this->model_name.'.php'));
$this->assertFileExists(app_path("Http/Controllers/{$this->model_name}Controller.php"));
$migrationFilePath = database_path('migrations/'.date('Y_m_d_His').'_create_'.$this->table_name.'_table.php');
$this->assertFileExists($migrationFilePath);
$this->assertFileExists(resource_path("views/{$this->table_name}/index.blade.php"));
$this->assertFileExists(resource_path("views/{$this->table_name}/create.blade.php"));
$this->assertFileExists(resource_path("views/{$this->table_name}/edit.blade.php"));
$this->assertFileNotExists(resource_path("views/{$this->table_name}/forms.blade.php"));
$localeConfig = config('app.locale');
$this->assertFileExists(resource_path("lang/{$localeConfig}/{$this->lang_name}.php"));
$this->assertFileExists(base_path("routes/web.php"));
$this->assertFileExists(app_path("Policies/{$this->model_name}Policy.php"));
$this->assertFileExists(database_path("factories/{$this->model_name}Factory.php"));
$this->assertFileExists(base_path("tests/Unit/Models/{$this->model_name}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$this->model_name}Test.php"));
}
/** @test */
public function it_creates_correct_index_view_content_with_formfield_and_bootstrap3()
{
$this->artisan('make:crud', ['name' => $this->model_name, '--formfield' => true, '--bs3' => true]);
$indexViewPath = resource_path("views/{$this->table_name}/index.blade.php");
$this->assertFileExists($indexViewPath);
$indexViewContent = "@extends('layouts.app')
@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', __('{$this->lang_name}.create'), [], ['class' => 'btn btn-success']) }}
@endcan
</div>
{{ __('{$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', ['label' => __('{$this->lang_name}.search'), 'placeholder' => __('{$this->lang_name}.search_text'), '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\">{{ __('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>
@foreach(\${$this->collection_model_var_name} as \$key => \${$this->single_model_var_name})
<tr>
<td class=\"text-center\">{{ \${$this->collection_model_var_name}->firstItem() + \$key }}</td>
<td>{{ \${$this->single_model_var_name}->name_link }}</td>
<td>{{ \${$this->single_model_var_name}->description }}</td>
<td class=\"text-center\">
@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]
) }}
@endcan
</td>
</tr>
@endforeach
</tbody>
</table>
<div class=\"panel-body\">{{ \${$this->collection_model_var_name}->appends(Request::except('page'))->render() }}</div>
</div>
</div>
</div>
@endsection
";
$this->assertEquals($indexViewContent, file_get_contents($indexViewPath));
}
/** @test */
public function it_creates_correct_show_view_content_with_formfield_and_bootstrap3()
{
$this->artisan('make:crud', ['name' => $this->model_name, '--formfield' => true, '--bs3' => true]);
$showFormViewPath = resource_path("views/{$this->table_name}/show.blade.php");
$this->assertFileExists($showFormViewPath);
$showFormViewContent = "@extends('layouts.app')
@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\">{{ __('{$this->lang_name}.detail') }}</h3></div>
<table class=\"table table-condensed\">
<tbody>
<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', __('{$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', __('{$this->lang_name}.back_to_index'), [], ['class' => 'btn btn-default']) }}
</div>
</div>
</div>
</div>
@endsection
";
$this->assertEquals($showFormViewContent, file_get_contents($showFormViewPath));
}
/** @test */
public function it_creates_correct_create_view_content_with_formfield_and_bootstrap3()
{
$this->artisan('make:crud', ['name' => $this->model_name, '--formfield' => true, '--bs3' => true]);
$createFormViewPath = resource_path("views/{$this->table_name}/create.blade.php");
$this->assertFileExists($createFormViewPath);
$createFormViewContent = "@extends('layouts.app')
@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\">{{ __('{$this->lang_name}.create') }}</h3></div>
{{ Form::open(['route' => '{$this->table_name}.store']) }}
<div class=\"panel-body\">
{!! 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(__('{$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>
</div>
</div>
@endsection
";
$this->assertEquals($createFormViewContent, file_get_contents($createFormViewPath));
}
/** @test */
public function it_creates_correct_edit_view_content_with_formfield_and_bootstrap3()
{
$this->artisan('make:crud', ['name' => $this->model_name, '--formfield' => true, '--bs3' => true]);
$editFormViewPath = resource_path("views/{$this->table_name}/edit.blade.php");
$this->assertFileExists($editFormViewPath);
$editFormViewContent = "@extends('layouts.app')
@section('title', __('{$this->lang_name}.edit'))
@section('content')
<div class=\"row\">
<div class=\"col-md-6 col-md-offset-3\">
@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\">{{ __('{$this->lang_name}.delete') }}</h3></div>
<div class=\"panel-body\">
<label class=\"control-label text-primary\">{{ __('{$this->lang_name}.name') }}</label>
<p>{{ \${$this->single_model_var_name}->name }}</p>
<label class=\"control-label text-primary\">{{ __('{$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 text-danger\">{{ __('{$this->lang_name}.delete_confirm') }}</div>
<div class=\"panel-footer\">
{!! FormField::delete(
['route' => ['{$this->table_name}.destroy', \${$this->single_model_var_name}]],
__('app.delete_confirm_button'),
['class'=>'btn btn-danger'],
[
'{$this->lang_name}_id' => \${$this->single_model_var_name}->id,
'page' => request('page'),
'q' => request('q'),
]
) !!}
{{ 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\">{{ __('{$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' => __('{$this->lang_name}.name')]) !!}
{!! FormField::textarea('description', ['label' => __('{$this->lang_name}.description')]) !!}
</div>
<div class=\"panel-footer\">
{{ 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', __('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() }}
</div>
</div>
</div>
@endif
@endsection
";
$this->assertEquals($editFormViewContent, file_get_contents($editFormViewPath));
}
}

80
tests/CommandOptions/FullCrudFormfieldOptionsTest.php

@ -47,8 +47,8 @@ class FullCrudFormfieldOptionsTest extends TestCase
@section('title', __('{$this->lang_name}.list'))
@section('content')
<h1 class=\"page-header\">
<div class=\"pull-right\">
<h1>
<div class=\"float-right\">
@can('create', new {$this->full_model_name})
{{ link_to_route('{$this->table_name}.create', __('{$this->lang_name}.create'), [], ['class' => 'btn btn-success']) }}
@endcan
@ -58,15 +58,15 @@ class FullCrudFormfieldOptionsTest extends TestCase
</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', ['label' => __('{$this->lang_name}.search'), 'placeholder' => __('{$this->lang_name}.search_text'), 'class' => 'input-sm']) !!}
<div class=\"card table-responsive\">
<div class=\"card-header\">
{{ Form::open(['method' => 'get', 'class' => 'form-inline']) }}
{!! FormField::text('q', ['label' => __('{$this->lang_name}.search'), 'placeholder' => __('{$this->lang_name}.search_text'), 'class' => 'form-control-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\">
<table class=\"table table-sm\">
<thead>
<tr>
<th class=\"text-center\">{{ __('app.table_no') }}</th>
@ -87,7 +87,7 @@ class FullCrudFormfieldOptionsTest extends TestCase
'{$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]
['id' => 'show-{$this->lang_name}-' . \${$this->single_model_var_name}->id]
) }}
@endcan
</td>
@ -95,7 +95,7 @@ class FullCrudFormfieldOptionsTest extends TestCase
@endforeach
</tbody>
</table>
<div class=\"panel-body\">{{ \${$this->collection_model_var_name}->appends(Request::except('page'))->render() }}</div>
<div class=\"card-body\">{{ \${$this->collection_model_var_name}->appends(Request::except('page'))->render() }}</div>
</div>
</div>
</div>
@ -117,21 +117,21 @@ class FullCrudFormfieldOptionsTest extends TestCase
@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\">{{ __('{$this->lang_name}.detail') }}</h3></div>
<table class=\"table table-condensed\">
<div class=\"row justify-content-center\">
<div class=\"col-md-6\">
<div class=\"card\">
<div class=\"card-header\">{{ __('{$this->lang_name}.detail') }}</div>
<table class=\"table table-sm\">
<tbody>
<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\">
<div class=\"card-footer\">
@can('update', \${$this->single_model_var_name})
{{ 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', __('{$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-link']) }}
</div>
</div>
</div>
@ -153,18 +153,18 @@ class FullCrudFormfieldOptionsTest extends TestCase
@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\">{{ __('{$this->lang_name}.create') }}</h3></div>
<div class=\"row justify-content-center\">
<div class=\"col-md-6\">
<div class=\"card\">
<div class=\"card-header\">{{ __('{$this->lang_name}.create') }}</div>
{{ Form::open(['route' => '{$this->table_name}.store']) }}
<div class=\"panel-body\">
<div class=\"card-body\">
{!! FormField::text('name', ['required' => true, 'label' => __('{$this->lang_name}.name')]) !!}
{!! FormField::textarea('description', ['label' => __('{$this->lang_name}.description')]) !!}
</div>
<div class=\"panel-footer\">
<div class=\"card-footer\">
{{ Form::submit(__('{$this->lang_name}.create'), ['class' => 'btn btn-success']) }}
{{ link_to_route('{$this->table_name}.index', __('app.cancel'), [], ['class' => 'btn btn-default']) }}
{{ link_to_route('{$this->table_name}.index', __('app.cancel'), [], ['class' => 'btn btn-link']) }}
</div>
{{ Form::close() }}
</div>
@ -187,22 +187,22 @@ class FullCrudFormfieldOptionsTest extends TestCase
@section('title', __('{$this->lang_name}.edit'))
@section('content')
<div class=\"row\">
<div class=\"col-md-6 col-md-offset-3\">
<div class=\"row justify-content-center\">
<div class=\"col-md-6\">
@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\">{{ __('{$this->lang_name}.delete') }}</h3></div>
<div class=\"panel-body\">
<label class=\"control-label\">{{ __('{$this->lang_name}.name') }}</label>
<div class=\"card\">
<div class=\"card-header\">{{ __('{$this->lang_name}.delete') }}</div>
<div class=\"card-body\">
<label class=\"control-label text-primary\">{{ __('{$this->lang_name}.name') }}</label>
<p>{{ \${$this->single_model_var_name}->name }}</p>
<label class=\"control-label\">{{ __('{$this->lang_name}.description') }}</label>
<label class=\"control-label text-primary\">{{ __('{$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\">{{ __('{$this->lang_name}.delete_confirm') }}</div>
<div class=\"panel-footer\">
<div class=\"card-body text-danger\">{{ __('{$this->lang_name}.delete_confirm') }}</div>
<div class=\"card-footer\">
{!! FormField::delete(
['route' => ['{$this->table_name}.destroy', \${$this->single_model_var_name}]],
__('app.delete_confirm_button'),
@ -213,23 +213,23 @@ class FullCrudFormfieldOptionsTest extends TestCase
'q' => request('q'),
]
) !!}
{{ link_to_route('{$this->table_name}.edit', __('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-link']) }}
</div>
</div>
@endcan
@else
<div class=\"panel panel-default\">
<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\">
<div class=\"card\">
<div class=\"card-header\">{{ __('{$this->lang_name}.edit') }}</div>
{{ Form::model(\${$this->single_model_var_name}, ['route' => ['{$this->table_name}.update', \${$this->single_model_var_name}], 'method' => 'patch']) }}
<div class=\"card-body\">
{!! FormField::text('name', ['required' => true, 'label' => __('{$this->lang_name}.name')]) !!}
{!! FormField::textarea('description', ['label' => __('{$this->lang_name}.description')]) !!}
</div>
<div class=\"panel-footer\">
<div class=\"card-footer\">
{{ 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']) }}
{{ link_to_route('{$this->table_name}.show', __('app.cancel'), [\${$this->single_model_var_name}], ['class' => 'btn btn-link']) }}
@can('delete', \${$this->single_model_var_name})
{{ 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]) }}
{{ link_to_route('{$this->table_name}.edit', __('app.delete'), [\${$this->single_model_var_name}, 'action' => 'delete'], ['class' => 'btn btn-danger float-right', 'id' => 'del-{$this->lang_name}-'.\${$this->single_model_var_name}->id]) }}
@endcan
</div>
{{ Form::close() }}

6
tests/CommandOptions/SimpleCrudBs3OptionsTest.php

@ -160,14 +160,14 @@ class SimpleCrudBs3OptionsTest extends TestCase
<div class=\"panel panel-default\">
<div class=\"panel-heading\"><h3 class=\"panel-title\">{{ __('{$this->lang_name}.delete') }}</h3></div>
<div class=\"panel-body\">
<label class=\"control-label\">{{ __('{$this->lang_name}.name') }}</label>
<label class=\"control-label text-primary\">{{ __('{$this->lang_name}.name') }}</label>
<p>{{ \$editable{$this->model_name}->name }}</p>
<label class=\"control-label\">{{ __('{$this->lang_name}.description') }}</label>
<label class=\"control-label text-primary\">{{ __('{$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\">{{ __('{$this->lang_name}.delete_confirm') }}</div>
<div class=\"panel-body text-danger\">{{ __('{$this->lang_name}.delete_confirm') }}</div>
<div class=\"panel-footer\">
<form method=\"POST\" action=\"{{ route('{$this->table_name}.destroy', \$editable{$this->model_name}) }}\" accept-charset=\"UTF-8\" onsubmit=\"return confirm(&quot;Are you sure to delete this?&quot;)\" class=\"del-form pull-right\" style=\"display: inline;\">
{{ csrf_field() }} {{ method_field('delete') }}

183
tests/CommandOptions/SimpleCrudFormfieldBs3OptionsTest.php

@ -0,0 +1,183 @@
<?php
namespace Tests\CommandOptions;
use Tests\TestCase;
use Illuminate\Contracts\Console\Kernel;
class SimpleCrudFormfieldBs3OptionsTest extends TestCase
{
/** @test */
public function it_can_generate_views_with_formfield_for_simple_crud()
{
$this->artisan('make:crud-simple', ['name' => $this->model_name, '--formfield' => true, '--bs3' => true]);
$this->assertNotContains("{$this->model_name} model already exists.", app(Kernel::class)->output());
$this->assertFileExists(app_path($this->model_name.'.php'));
$this->assertFileExists(app_path("Http/Controllers/{$this->model_name}Controller.php"));
$migrationFilePath = database_path('migrations/'.date('Y_m_d_His').'_create_'.$this->table_name.'_table.php');
$this->assertFileExists($migrationFilePath);
$this->assertFileExists(resource_path("views/{$this->table_name}/index.blade.php"));
$this->assertFileExists(resource_path("views/{$this->table_name}/forms.blade.php"));
$localeConfig = config('app.locale');
$this->assertFileExists(resource_path("lang/{$localeConfig}/{$this->lang_name}.php"));
$this->assertFileExists(base_path("routes/web.php"));
$this->assertFileExists(app_path("Policies/{$this->model_name}Policy.php"));
$this->assertFileExists(database_path("factories/{$this->model_name}Factory.php"));
$this->assertFileExists(base_path("tests/Unit/Models/{$this->model_name}Test.php"));
$this->assertFileExists(base_path("tests/Feature/Manage{$this->model_name}Test.php"));
}
/** @test */
public function it_creates_correct_index_view_content_with_formfield()
{
$this->artisan('make:crud-simple', ['name' => $this->model_name, '--formfield' => true, '--bs3' => true]);
$indexViewPath = resource_path("views/{$this->table_name}/index.blade.php");
$this->assertFileExists($indexViewPath);
$indexViewContent = "@extends('layouts.app')
@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', __('{$this->lang_name}.create'), ['action' => 'create'], ['class' => 'btn btn-success']) }}
@endcan
</div>
{{ __('{$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', ['label' => __('{$this->lang_name}.search'), 'placeholder' => __('{$this->lang_name}.search_text'), '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\">{{ __('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>
@foreach(\${$this->collection_model_var_name} as \$key => \${$this->single_model_var_name})
<tr>
<td class=\"text-center\">{{ \${$this->collection_model_var_name}->firstItem() + \$key }}</td>
<td>{{ \${$this->single_model_var_name}->name }}</td>
<td>{{ \${$this->single_model_var_name}->description }}</td>
<td class=\"text-center\">
@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]
) }}
@endcan
</td>
</tr>
@endforeach
</tbody>
</table>
<div class=\"panel-body\">{{ \${$this->collection_model_var_name}->appends(Request::except('page'))->render() }}</div>
</div>
</div>
<div class=\"col-md-4\">
@if(Request::has('action'))
@include('{$this->table_name}.forms')
@endif
</div>
</div>
@endsection
";
$this->assertEquals($indexViewContent, file_get_contents($indexViewPath));
}
/** @test */
public function it_creates_correct_forms_view_content_with_formfield()
{
$this->artisan('make:crud-simple', ['name' => $this->model_name, '--formfield' => true, '--bs3' => true]);
$formViewPath = resource_path("views/{$this->table_name}/forms.blade.php");
$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})
@can('delete', \$editable{$this->model_name})
<div class=\"panel panel-default\">
<div class=\"panel-heading\"><h3 class=\"panel-title\">{{ __('{$this->lang_name}.delete') }}</h3></div>
<div class=\"panel-body\">
<label class=\"control-label text-primary\">{{ __('{$this->lang_name}.name') }}</label>
<p>{{ \$editable{$this->model_name}->name }}</p>
<label class=\"control-label text-primary\">{{ __('{$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 text-danger\">{{ __('{$this->lang_name}.delete_confirm') }}</div>
<div class=\"panel-footer\">
{!! FormField::delete(
['route' => ['{$this->table_name}.destroy', \$editable{$this->model_name}]],
__('app.delete_confirm_button'),
['class'=>'btn btn-danger'],
[
'{$this->lang_name}_id' => \$editable{$this->model_name}->id,
'page' => request('page'),
'q' => request('q'),
]
) !!}
{{ link_to_route('{$this->table_name}.index', __('app.cancel'), Request::only('page', 'q'), ['class' => 'btn btn-default']) }}
</div>
</div>
@endcan
@endif
";
$this->assertEquals($formViewContent, file_get_contents($formViewPath));
}
}

34
tests/CommandOptions/SimpleCrudFormfieldOptionsTest.php

@ -45,8 +45,8 @@ class SimpleCrudFormfieldOptionsTest extends TestCase
@section('title', __('{$this->lang_name}.list'))
@section('content')
<h1 class=\"page-header\">
<div class=\"pull-right\">
<h1>
<div class=\"float-right\">
@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
@ -56,15 +56,15 @@ class SimpleCrudFormfieldOptionsTest extends TestCase
</h1>
<div class=\"row\">
<div class=\"col-md-8\">
<div class=\"panel panel-default table-responsive\">
<div class=\"panel-heading\">
<div class=\"card table-responsive\">
<div class=\"card-header\">
{{ Form::open(['method' => 'get', 'class' => 'form-inline']) }}
{!! FormField::text('q', ['label' => __('{$this->lang_name}.search'), 'placeholder' => __('{$this->lang_name}.search_text'), '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\">
<table class=\"table table-sm\">
<thead>
<tr>
<th class=\"text-center\">{{ __('app.table_no') }}</th>
@ -93,7 +93,7 @@ class SimpleCrudFormfieldOptionsTest extends TestCase
@endforeach
</tbody>
</table>
<div class=\"panel-body\">{{ \${$this->collection_model_var_name}->appends(Request::except('page'))->render() }}</div>
<div class=\"card-body\">{{ \${$this->collection_model_var_name}->appends(Request::except('page'))->render() }}</div>
</div>
</div>
<div class=\"col-md-4\">
@ -120,7 +120,7 @@ class SimpleCrudFormfieldOptionsTest extends TestCase
{!! 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']) }}
{{ link_to_route('{$this->table_name}.index', __('app.cancel'), [], ['class' => 'btn btn-link']) }}
{{ Form::close() }}
@endcan
@endif
@ -136,13 +136,13 @@ class SimpleCrudFormfieldOptionsTest extends TestCase
{{ 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']) }}
{{ link_to_route('{$this->table_name}.index', __('app.cancel'), Request::only('page', 'q'), ['class' => 'btn btn-link']) }}
@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']
['id' => 'del-{$this->lang_name}-'.\$editable{$this->model_name}->id, 'class' => 'btn btn-danger float-right']
) }}
@endcan
{{ Form::close() }}
@ -150,18 +150,18 @@ class SimpleCrudFormfieldOptionsTest extends TestCase
@endif
@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\">{{ __('{$this->lang_name}.delete') }}</h3></div>
<div class=\"panel-body\">
<label class=\"control-label\">{{ __('{$this->lang_name}.name') }}</label>
<div class=\"card\">
<div class=\"card-header\">{{ __('{$this->lang_name}.delete') }}</div>
<div class=\"card-body\">
<label class=\"control-label text-primary\">{{ __('{$this->lang_name}.name') }}</label>
<p>{{ \$editable{$this->model_name}->name }}</p>
<label class=\"control-label\">{{ __('{$this->lang_name}.description') }}</label>
<label class=\"control-label text-primary\">{{ __('{$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\">{{ __('{$this->lang_name}.delete_confirm') }}</div>
<div class=\"panel-footer\">
<div class=\"card-body text-danger\">{{ __('{$this->lang_name}.delete_confirm') }}</div>
<div class=\"card-footer\">
{!! FormField::delete(
['route' => ['{$this->table_name}.destroy', \$editable{$this->model_name}]],
__('app.delete_confirm_button'),
@ -172,7 +172,7 @@ class SimpleCrudFormfieldOptionsTest extends TestCase
'q' => request('q'),
]
) !!}
{{ link_to_route('{$this->table_name}.index', __('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-link']) }}
</div>
</div>
@endcan

Loading…
Cancel
Save