Browse Source

Merge pull request #29 from nafiesl/change_name_to_title

Change "name" attribute to "title"
tags/2.1.0 2.1.0
Nafies Luthfi 5 years ago
committed by GitHub
parent
commit
c93c79034b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      readme.md
  2. 9
      src/stubs/controllers/api.stub
  3. 5
      src/stubs/controllers/full-formrequests.stub
  4. 9
      src/stubs/controllers/full.stub
  5. 9
      src/stubs/controllers/simple.stub
  6. 2
      src/stubs/database/factories/model-factory.stub
  7. 6
      src/stubs/database/migrations/migration-create.stub
  8. 8
      src/stubs/models/model-formfield.stub
  9. 8
      src/stubs/models/model.stub
  10. 2
      src/stubs/requests/create-request.stub
  11. 2
      src/stubs/requests/update-request.stub
  12. 24
      src/stubs/resources/lang/en/master.stub
  13. 24
      src/stubs/resources/lang/id/master.stub
  14. 8
      src/stubs/resources/views/full/create-bs3.stub
  15. 2
      src/stubs/resources/views/full/create-formfield-bs3.stub
  16. 2
      src/stubs/resources/views/full/create-formfield.stub
  17. 6
      src/stubs/resources/views/full/create.stub
  18. 12
      src/stubs/resources/views/full/edit-bs3.stub
  19. 6
      src/stubs/resources/views/full/edit-formfield-bs3.stub
  20. 6
      src/stubs/resources/views/full/edit-formfield.stub
  21. 10
      src/stubs/resources/views/full/edit.stub
  22. 4
      src/stubs/resources/views/full/index-bs3.stub
  23. 4
      src/stubs/resources/views/full/index-formfield-bs3.stub
  24. 4
      src/stubs/resources/views/full/index-formfield.stub
  25. 4
      src/stubs/resources/views/full/index.stub
  26. 2
      src/stubs/resources/views/full/show-bs3.stub
  27. 2
      src/stubs/resources/views/full/show-formfield-bs3.stub
  28. 2
      src/stubs/resources/views/full/show-formfield.stub
  29. 2
      src/stubs/resources/views/full/show.stub
  30. 20
      src/stubs/resources/views/simple/forms-bs3.stub
  31. 8
      src/stubs/resources/views/simple/forms-formfield-bs3.stub
  32. 8
      src/stubs/resources/views/simple/forms-formfield.stub
  33. 16
      src/stubs/resources/views/simple/forms.stub
  34. 4
      src/stubs/resources/views/simple/index-bs3.stub
  35. 4
      src/stubs/resources/views/simple/index-formfield-bs3.stub
  36. 4
      src/stubs/resources/views/simple/index-formfield.stub
  37. 4
      src/stubs/resources/views/simple/index.stub
  38. 58
      src/stubs/testcases/feature/api.stub
  39. 46
      src/stubs/testcases/feature/full.stub
  40. 54
      src/stubs/testcases/feature/simple.stub
  41. 8
      src/stubs/testcases/unit/model-formfield.stub
  42. 8
      src/stubs/testcases/unit/model.stub
  43. 26
      tests/CommandOptions/FullCrudBs3OptionsTest.php
  44. 9
      tests/CommandOptions/FullCrudFormRequestOptionsTest.php
  45. 14
      tests/CommandOptions/FullCrudFormfieldBs3OptionsTest.php
  46. 30
      tests/CommandOptions/FullCrudFormfieldOptionsTest.php
  47. 24
      tests/CommandOptions/SimpleCrudBs3OptionsTest.php
  48. 12
      tests/CommandOptions/SimpleCrudFormfieldBs3OptionsTest.php
  49. 12
      tests/CommandOptions/SimpleCrudFormfieldOptionsTest.php
  50. 2
      tests/CrudMakeClassPropertiesTest.php
  51. 9
      tests/Generators/Api/ApiControllerGeneratorTest.php
  52. 116
      tests/Generators/Api/ApiFeatureTestGeneratorTest.php
  53. 140
      tests/Generators/FeatureTestGeneratorTest.php
  54. 27
      tests/Generators/FullControllerGeneratorTest.php
  55. 50
      tests/Generators/LangGeneratorTest.php
  56. 6
      tests/Generators/MigrationGeneratorTest.php
  57. 2
      tests/Generators/ModelFactoryGeneratorTest.php
  58. 16
      tests/Generators/ModelGeneratorTest.php
  59. 2
      tests/Generators/ModelPolicyTestGeneratorTest.php
  60. 26
      tests/Generators/ModelTestGeneratorTest.php
  61. 108
      tests/Generators/Simple/FeatureTestGeneratorTest.php
  62. 27
      tests/Generators/Simple/SimpleControllerGeneratorTest.php
  63. 22
      tests/Generators/Simple/ViewsGeneratorTest.php
  64. 24
      tests/Generators/ViewsGeneratorTest.php

8
readme.md

@ -164,7 +164,7 @@ $ php artisan make:crud-api ModelName
#### Model Attribute/column
The Model and table will **only have 2 pre-definded** attributes or columns : **name** and **description** on each generated model and database table. You can continue working on other column on the table.
The Model and table will **only have 2 pre-definded** attributes or columns : **title** and **description** on each generated model and database table. You can continue working on other column on the table.
<br>
@ -214,7 +214,7 @@ Example code for calling the generated API, using Guzzle:
$uri = 'http://your-domain.com/api/vehicles';
$headers = ['Authorization' => 'Bearer '.$apiToken];
$payload = json_encode([
'name' => 'Vehicle Name 1',
'title' => 'Vehicle Name 1',
'description' => 'Vehicle Description 1',
]);
@ -278,8 +278,8 @@ Next, let us try the generated testing suite. To use the generated testing class
<!-- ..... -->
<php>
<!-- ..... -->
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
<server name="DB_CONNECTION" value="sqlite"/>
<server name="DB_DATABASE" value=":memory:"/>
</php>
</phpunit>
```

9
src/stubs/controllers/api.stub

@ -13,10 +13,11 @@ class MasterController extends Controller
*
* @return \Illuminate\Http\JsonResponse
*/
public function index()
public function index(Request $request)
{
$singleMstrQuery = Master::query();
$singleMstrQuery->where('name', 'like', '%'.request('q').'%');
$singleMstrQuery->where('title', 'like', '%'.$request->get('q').'%');
$singleMstrQuery->orderBy('title');
$mstrCollections = $singleMstrQuery->paginate(25);
return $mstrCollections;
@ -33,7 +34,7 @@ class MasterController extends Controller
$this->authorize('create', new Master);
$newMaster = $request->validate([
'name' => 'required|max:60',
'title' => 'required|max:60',
'description' => 'nullable|max:255',
]);
$newMaster['creator_id'] = auth()->id();
@ -69,7 +70,7 @@ class MasterController extends Controller
$this->authorize('update', $singleMstr);
$singleMstrData = $request->validate([
'name' => 'required|max:60',
'title' => 'required|max:60',
'description' => 'nullable|max:255',
]);
$singleMstr->update($singleMstrData);

5
src/stubs/controllers/full-formrequests.stub

@ -14,10 +14,11 @@ class MasterController extends Controller
*
* @return \Illuminate\View\View
*/
public function index()
public function index(Request $request)
{
$singleMstrQuery = Master::query();
$singleMstrQuery->where('name', 'like', '%'.request('q').'%');
$singleMstrQuery->where('title', 'like', '%'.$request->get('q').'%');
$singleMstrQuery->orderBy('title');
$mstrCollections = $singleMstrQuery->paginate(25);
return view('masters.index', compact('mstrCollections'));

9
src/stubs/controllers/full.stub

@ -12,10 +12,11 @@ class MasterController extends Controller
*
* @return \Illuminate\View\View
*/
public function index()
public function index(Request $request)
{
$singleMstrQuery = Master::query();
$singleMstrQuery->where('name', 'like', '%'.request('q').'%');
$singleMstrQuery->where('title', 'like', '%'.$request->get('q').'%');
$singleMstrQuery->orderBy('title');
$mstrCollections = $singleMstrQuery->paginate(25);
return view('masters.index', compact('mstrCollections'));
@ -44,7 +45,7 @@ class MasterController extends Controller
$this->authorize('create', new Master);
$newMaster = $request->validate([
'name' => 'required|max:60',
'title' => 'required|max:60',
'description' => 'nullable|max:255',
]);
$newMaster['creator_id'] = auth()->id();
@ -90,7 +91,7 @@ class MasterController extends Controller
$this->authorize('update', $singleMstr);
$singleMstrData = $request->validate([
'name' => 'required|max:60',
'title' => 'required|max:60',
'description' => 'nullable|max:255',
]);
$singleMstr->update($singleMstrData);

9
src/stubs/controllers/simple.stub

@ -12,11 +12,12 @@ class MasterController extends Controller
*
* @return \Illuminate\View\View
*/
public function index()
public function index(Request $request)
{
$editableMaster = null;
$singleMstrQuery = Master::query();
$singleMstrQuery->where('name', 'like', '%'.request('q').'%');
$singleMstrQuery->where('title', 'like', '%'.$request->get('q').'%');
$singleMstrQuery->orderBy('title');
$mstrCollections = $singleMstrQuery->paginate(25);
if (in_array(request('action'), ['edit', 'delete']) && request('id') != null) {
@ -37,7 +38,7 @@ class MasterController extends Controller
$this->authorize('create', new Master);
$newMaster = $request->validate([
'name' => 'required|max:60',
'title' => 'required|max:60',
'description' => 'nullable|max:255',
]);
$newMaster['creator_id'] = auth()->id();
@ -59,7 +60,7 @@ class MasterController extends Controller
$this->authorize('update', $singleMstr);
$singleMstrData = $request->validate([
'name' => 'required|max:60',
'title' => 'required|max:60',
'description' => 'nullable|max:255',
]);
$singleMstr->update($singleMstrData);

2
src/stubs/database/factories/model-factory.stub

@ -13,7 +13,7 @@ class MasterFactory extends Factory
public function definition()
{
return [
'name' => $this->faker->word,
'title' => $this->faker->word,
'description' => $this->faker->sentence,
'creator_id' => function () {
return User::factory()->create()->id;

6
src/stubs/database/migrations/migration-create.stub

@ -15,12 +15,10 @@ class CreateMastersTable extends Migration
{
Schema::create('masters', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name', 60);
$table->string('title', 60);
$table->string('description')->nullable();
$table->unsignedBigInteger('creator_id');
$table->foreignId('creator_id')->constrained('users')->onDelete('restrict');
$table->timestamps();
$table->foreign('creator_id')->references('id')->on('users')->onDelete('restrict');
});
}

8
src/stubs/models/model-formfield.stub

@ -10,14 +10,14 @@ class Master extends Model
{
use HasFactory;
protected $fillable = ['name', 'description', 'creator_id'];
protected $fillable = ['title', 'description', 'creator_id'];
public function getNameLinkAttribute()
public function getTitleLinkAttribute()
{
return link_to_route('masters.show', $this->name, [$this], [
return link_to_route('masters.show', $this->title, [$this], [
'title' => __(
'app.show_detail_title',
['name' => $this->name, 'type' => __('master.master')]
['title' => $this->title, 'type' => __('master.master')]
),
]);
}

8
src/stubs/models/model.stub

@ -10,16 +10,16 @@ class Master extends Model
{
use HasFactory;
protected $fillable = ['name', 'description', 'creator_id'];
protected $fillable = ['title', 'description', 'creator_id'];
public function getNameLinkAttribute()
public function getTitleLinkAttribute()
{
$title = __('app.show_detail_title', [
'name' => $this->name, 'type' => __('master.master'),
'title' => $this->title, 'type' => __('master.master'),
]);
$link = '<a href="'.route('masters.show', $this).'"';
$link .= ' title="'.$title.'">';
$link .= $this->name;
$link .= $this->title;
$link .= '</a>';
return $link;

2
src/stubs/requests/create-request.stub

@ -25,7 +25,7 @@ class CreateRequest extends FormRequest
public function rules()
{
return [
'name' => 'required|max:60',
'title' => 'required|max:60',
'description' => 'nullable|max:255',
];
}

2
src/stubs/requests/update-request.stub

@ -24,7 +24,7 @@ class UpdateRequest extends FormRequest
public function rules()
{
return [
'name' => 'required|max:60',
'title' => 'required|max:60',
'description' => 'nullable|max:255',
];
}

24
src/stubs/resources/lang/en/master.stub

@ -2,17 +2,17 @@
return [
// Labels
'master' => 'Master',
'list' => 'Master List',
'search' => 'Search Master',
'search_text' => 'Name ...',
'all' => 'All Master',
'select' => 'Select Master',
'detail' => 'Master Detail',
'not_found' => 'Master not found.',
'empty' => 'Master is empty.',
'back_to_show' => 'Back to Master Detail',
'back_to_index' => 'Back to Master List',
'master' => 'Master',
'list' => 'Master List',
'search' => 'Search Master',
'search_text' => 'Title ...',
'all' => 'All Master',
'select' => 'Select Master',
'detail' => 'Master Detail',
'not_found' => 'Master not found.',
'empty' => 'Master is empty.',
'back_to_show' => 'Back to Master Detail',
'back_to_index' => 'Back to Master List',
// Actions
'create' => 'Create new Master',
@ -28,6 +28,6 @@ return [
'undeleteable' => 'Master data cannot be deleted.',
// Attributes
'name' => 'Master Name',
'title' => 'Master Title',
'description' => 'Master Description',
];

24
src/stubs/resources/lang/id/master.stub

@ -2,17 +2,17 @@
return [
// Labels
'master' => 'Master',
'list' => 'Daftar Master',
'search' => 'Cari Master',
'search_text' => 'Nama ...',
'all' => 'Semua Master',
'select' => 'Pilih Master',
'detail' => 'Detail Master',
'not_found' => 'Master tidak ditemukan',
'empty' => 'Belum ada Master',
'back_to_show' => 'Kembali ke detail Master',
'back_to_index' => 'Kembali ke daftar Master',
'master' => 'Master',
'list' => 'Daftar Master',
'search' => 'Cari Master',
'search_text' => 'Judul ...',
'all' => 'Semua Master',
'select' => 'Pilih Master',
'detail' => 'Detail Master',
'not_found' => 'Master tidak ditemukan',
'empty' => 'Belum ada Master',
'back_to_show' => 'Kembali ke detail Master',
'back_to_index' => 'Kembali ke daftar Master',
// Actions
'create' => 'Input Master Baru',
@ -28,6 +28,6 @@ return [
'undeleteable' => 'Data Master tidak dapat dihapus.',
// Attributes
'name' => 'Nama Master',
'title' => 'Judul Master',
'description' => 'Deskripsi Master',
];

8
src/stubs/resources/views/full/create-bs3.stub

@ -10,10 +10,10 @@
<form method="POST" action="{{ route('masters.store') }}" accept-charset="UTF-8">
{{ csrf_field() }}
<div class="panel-body">
<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
<label for="name" class="control-label">{{ __('master.name') }}</label>
<input id="name" type="text" class="form-control" name="name" value="{{ old('name') }}" required>
{!! $errors->first('name', '<span class="help-block small">:message</span>') !!}
<div class="form-group{{ $errors->has('title') ? ' has-error' : '' }}">
<label for="title" class="control-label">{{ __('master.title') }}</label>
<input id="title" type="text" class="form-control" name="title" value="{{ old('title') }}" required>
{!! $errors->first('title', '<span class="help-block small">:message</span>') !!}
</div>
<div class="form-group{{ $errors->has('description') ? ' has-error' : '' }}">
<label for="description" class="control-label">{{ __('master.description') }}</label>

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

@ -9,7 +9,7 @@
<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::text('title', ['required' => true, 'label' => __('master.title')]) !!}
{!! FormField::textarea('description', ['label' => __('master.description')]) !!}
</div>
<div class="panel-footer">

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

@ -9,7 +9,7 @@
<div class="card-header">{{ __('master.create') }}</div>
{{ Form::open(['route' => 'masters.store']) }}
<div class="card-body">
{!! FormField::text('name', ['required' => true, 'label' => __('master.name')]) !!}
{!! FormField::text('title', ['required' => true, 'label' => __('master.title')]) !!}
{!! FormField::textarea('description', ['label' => __('master.description')]) !!}
</div>
<div class="card-footer">

6
src/stubs/resources/views/full/create.stub

@ -11,9 +11,9 @@
{{ csrf_field() }}
<div class="card-body">
<div class="form-group">
<label for="name" class="form-label">{{ __('master.name') }} <span class="form-required">*</span></label>
<input id="name" type="text" class="form-control{{ $errors->has('name') ? ' is-invalid' : '' }}" name="name" value="{{ old('name') }}" required>
{!! $errors->first('name', '<span class="invalid-feedback" role="alert">:message</span>') !!}
<label for="title" class="form-label">{{ __('master.title') }} <span class="form-required">*</span></label>
<input id="title" type="text" class="form-control{{ $errors->has('title') ? ' is-invalid' : '' }}" name="title" value="{{ old('title') }}" required>
{!! $errors->first('title', '<span class="invalid-feedback" role="alert">:message</span>') !!}
</div>
<div class="form-group">
<label for="description" class="form-label">{{ __('master.description') }}</label>

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

@ -10,8 +10,8 @@
<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.title') }}</label>
<p>{{ $singleMstr->title }}</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>') !!}
@ -34,10 +34,10 @@
<form method="POST" action="{{ route('masters.update', $singleMstr) }}" accept-charset="UTF-8">
{{ csrf_field() }} {{ method_field('patch') }}
<div class="panel-body">
<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
<label for="name" class="control-label">{{ __('master.name') }}</label>
<input id="name" type="text" class="form-control" name="name" value="{{ old('name', $singleMstr->name) }}" required>
{!! $errors->first('name', '<span class="help-block small">:message</span>') !!}
<div class="form-group{{ $errors->has('title') ? ' has-error' : '' }}">
<label for="title" class="control-label">{{ __('master.title') }}</label>
<input id="title" type="text" class="form-control" name="title" value="{{ old('title', $singleMstr->title) }}" required>
{!! $errors->first('title', '<span class="help-block small">:message</span>') !!}
</div>
<div class="form-group{{ $errors->has('description') ? ' has-error' : '' }}">
<label for="description" class="control-label">{{ __('master.description') }}</label>

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

@ -10,8 +10,8 @@
<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.title') }}</label>
<p>{{ $singleMstr->title }}</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>') !!}
@ -34,7 +34,7 @@
<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::text('title', ['required' => true, 'label' => __('master.title')]) !!}
{!! FormField::textarea('description', ['label' => __('master.description')]) !!}
</div>
<div class="panel-footer">

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

@ -10,8 +10,8 @@
<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 text-primary">{{ __('master.title') }}</label>
<p>{{ $singleMstr->title }}</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>') !!}
@ -34,7 +34,7 @@
<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::text('title', ['required' => true, 'label' => __('master.title')]) !!}
{!! FormField::textarea('description', ['label' => __('master.description')]) !!}
</div>
<div class="card-footer">

10
src/stubs/resources/views/full/edit.stub

@ -10,8 +10,8 @@
<div class="card">
<div class="card-header">{{ __('master.delete') }}</div>
<div class="card-body">
<label class="form-label text-primary">{{ __('master.name') }}</label>
<p>{{ $singleMstr->name }}</p>
<label class="form-label text-primary">{{ __('master.title') }}</label>
<p>{{ $singleMstr->title }}</p>
<label class="form-label text-primary">{{ __('master.description') }}</label>
<p>{{ $singleMstr->description }}</p>
{!! $errors->first('master_id', '<span class="invalid-feedback" role="alert">:message</span>') !!}
@ -35,9 +35,9 @@
{{ csrf_field() }} {{ method_field('patch') }}
<div class="card-body">
<div class="form-group">
<label for="name" class="form-label">{{ __('master.name') }} <span class="form-required">*</span></label>
<input id="name" type="text" class="form-control{{ $errors->has('name') ? ' is-invalid' : '' }}" name="name" value="{{ old('name', $singleMstr->name) }}" required>
{!! $errors->first('name', '<span class="invalid-feedback" role="alert">:message</span>') !!}
<label for="title" class="form-label">{{ __('master.title') }} <span class="form-required">*</span></label>
<input id="title" type="text" class="form-control{{ $errors->has('title') ? ' is-invalid' : '' }}" name="title" value="{{ old('title', $singleMstr->title) }}" required>
{!! $errors->first('title', '<span class="invalid-feedback" role="alert">:message</span>') !!}
</div>
<div class="form-group">
<label for="description" class="form-label">{{ __('master.description') }}</label>

4
src/stubs/resources/views/full/index-bs3.stub

@ -29,7 +29,7 @@
<thead>
<tr>
<th class="text-center">{{ __('app.table_no') }}</th>
<th>{{ __('master.name') }}</th>
<th>{{ __('master.title') }}</th>
<th>{{ __('master.description') }}</th>
<th class="text-center">{{ __('app.action') }}</th>
</tr>
@ -38,7 +38,7 @@
@foreach($mstrCollections as $key => $singleMstr)
<tr>
<td class="text-center">{{ $mstrCollections->firstItem() + $key }}</td>
<td>{!! $singleMstr->name_link !!}</td>
<td>{!! $singleMstr->title_link !!}</td>
<td>{{ $singleMstr->description }}</td>
<td class="text-center">
@can('view', $singleMstr)

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

@ -26,7 +26,7 @@
<thead>
<tr>
<th class="text-center">{{ __('app.table_no') }}</th>
<th>{{ __('master.name') }}</th>
<th>{{ __('master.title') }}</th>
<th>{{ __('master.description') }}</th>
<th class="text-center">{{ __('app.action') }}</th>
</tr>
@ -35,7 +35,7 @@
@foreach($mstrCollections as $key => $singleMstr)
<tr>
<td class="text-center">{{ $mstrCollections->firstItem() + $key }}</td>
<td>{{ $singleMstr->name_link }}</td>
<td>{{ $singleMstr->title_link }}</td>
<td>{{ $singleMstr->description }}</td>
<td class="text-center">
@can('view', $singleMstr)

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

@ -26,7 +26,7 @@
<thead>
<tr>
<th class="text-center">{{ __('app.table_no') }}</th>
<th>{{ __('master.name') }}</th>
<th>{{ __('master.title') }}</th>
<th>{{ __('master.description') }}</th>
<th class="text-center">{{ __('app.action') }}</th>
</tr>
@ -35,7 +35,7 @@
@foreach($mstrCollections as $key => $singleMstr)
<tr>
<td class="text-center">{{ $mstrCollections->firstItem() + $key }}</td>
<td>{{ $singleMstr->name_link }}</td>
<td>{{ $singleMstr->title_link }}</td>
<td>{{ $singleMstr->description }}</td>
<td class="text-center">
@can('view', $singleMstr)

4
src/stubs/resources/views/full/index.stub

@ -29,7 +29,7 @@
<thead>
<tr>
<th class="text-center">{{ __('app.table_no') }}</th>
<th>{{ __('master.name') }}</th>
<th>{{ __('master.title') }}</th>
<th>{{ __('master.description') }}</th>
<th class="text-center">{{ __('app.action') }}</th>
</tr>
@ -38,7 +38,7 @@
@foreach($mstrCollections as $key => $singleMstr)
<tr>
<td class="text-center">{{ $mstrCollections->firstItem() + $key }}</td>
<td>{!! $singleMstr->name_link !!}</td>
<td>{!! $singleMstr->title_link !!}</td>
<td>{{ $singleMstr->description }}</td>
<td class="text-center">
@can('view', $singleMstr)

2
src/stubs/resources/views/full/show-bs3.stub

@ -9,7 +9,7 @@
<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.title') }}</td><td>{{ $singleMstr->title }}</td></tr>
<tr><td>{{ __('master.description') }}</td><td>{{ $singleMstr->description }}</td></tr>
</tbody>
</table>

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

@ -9,7 +9,7 @@
<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.title') }}</td><td>{{ $singleMstr->title }}</td></tr>
<tr><td>{{ __('master.description') }}</td><td>{{ $singleMstr->description }}</td></tr>
</tbody>
</table>

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

@ -10,7 +10,7 @@
<div class="card-body">
<table class="table table-sm">
<tbody>
<tr><td>{{ __('master.name') }}</td><td>{{ $singleMstr->name }}</td></tr>
<tr><td>{{ __('master.title') }}</td><td>{{ $singleMstr->title }}</td></tr>
<tr><td>{{ __('master.description') }}</td><td>{{ $singleMstr->description }}</td></tr>
</tbody>
</table>

2
src/stubs/resources/views/full/show.stub

@ -10,7 +10,7 @@
<div class="card-body">
<table class="table table-sm">
<tbody>
<tr><td>{{ __('master.name') }}</td><td>{{ $singleMstr->name }}</td></tr>
<tr><td>{{ __('master.title') }}</td><td>{{ $singleMstr->title }}</td></tr>
<tr><td>{{ __('master.description') }}</td><td>{{ $singleMstr->description }}</td></tr>
</tbody>
</table>

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

@ -2,10 +2,10 @@
@can('create', new fullMstr)
<form method="POST" action="{{ route('masters.store') }}" accept-charset="UTF-8">
{{ csrf_field() }}
<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
<label for="name" class="control-label">{{ __('master.name') }}</label>
<input id="name" type="text" class="form-control" name="name" value="{{ old('name') }}" required>
{!! $errors->first('name', '<span class="help-block small">:message</span>') !!}
<div class="form-group{{ $errors->has('title') ? ' has-error' : '' }}">
<label for="title" class="control-label">{{ __('master.title') }}</label>
<input id="title" type="text" class="form-control" name="title" value="{{ old('title') }}" required>
{!! $errors->first('title', '<span class="help-block small">:message</span>') !!}
</div>
<div class="form-group{{ $errors->has('description') ? ' has-error' : '' }}">
<label for="description" class="control-label">{{ __('master.description') }}</label>
@ -21,10 +21,10 @@
@can('update', $editableMaster)
<form method="POST" action="{{ route('masters.update', $editableMaster) }}" accept-charset="UTF-8">
{{ csrf_field() }} {{ method_field('patch') }}
<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
<label for="name" class="control-label">{{ __('master.name') }}</label>
<input id="name" type="text" class="form-control" name="name" value="{{ old('name', $editableMaster->name) }}" required>
{!! $errors->first('name', '<span class="help-block small">:message</span>') !!}
<div class="form-group{{ $errors->has('title') ? ' has-error' : '' }}">
<label for="title" class="control-label">{{ __('master.title') }}</label>
<input id="title" type="text" class="form-control" name="title" value="{{ old('title', $editableMaster->title) }}" required>
{!! $errors->first('title', '<span class="help-block small">:message</span>') !!}
</div>
<div class="form-group{{ $errors->has('description') ? ' has-error' : '' }}">
<label for="description" class="control-label">{{ __('master.description') }}</label>
@ -46,8 +46,8 @@
<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.title') }}</label>
<p>{{ $editableMaster->title }}</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>') !!}

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

@ -1,7 +1,7 @@
@if (Request::get('action') == 'create')
@can('create', new fullMstr)
{{ Form::open(['route' => 'masters.store']) }}
{!! FormField::text('name', ['required' => true, 'label' => __('master.name')]) !!}
{!! FormField::text('title', ['required' => true, 'label' => __('master.title')]) !!}
{!! 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']) }}
@ -11,7 +11,7 @@
@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::text('title', ['required' => true, 'label' => __('master.title')]) !!}
{!! FormField::textarea('description', ['label' => __('master.description')]) !!}
@if (request('q'))
{{ Form::hidden('q', request('q')) }}
@ -37,8 +37,8 @@
<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.title') }}</label>
<p>{{ $editableMaster->title }}</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>') !!}

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

@ -1,7 +1,7 @@
@if (Request::get('action') == 'create')
@can('create', new fullMstr)
{{ Form::open(['route' => 'masters.store']) }}
{!! FormField::text('name', ['required' => true, 'label' => __('master.name')]) !!}
{!! FormField::text('title', ['required' => true, 'label' => __('master.title')]) !!}
{!! FormField::textarea('description', ['label' => __('master.description')]) !!}
{{ Form::submit(__('master.create'), ['class' => 'btn btn-success']) }}
{{ link_to_route('masters.index', __('app.cancel'), [], ['class' => 'btn btn-link']) }}
@ -11,7 +11,7 @@
@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::text('title', ['required' => true, 'label' => __('master.title')]) !!}
{!! FormField::textarea('description', ['label' => __('master.description')]) !!}
@if (request('q'))
{{ Form::hidden('q', request('q')) }}
@ -37,8 +37,8 @@
<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 text-primary">{{ __('master.title') }}</label>
<p>{{ $editableMaster->title }}</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>') !!}

16
src/stubs/resources/views/simple/forms.stub

@ -3,9 +3,9 @@
<form method="POST" action="{{ route('masters.store') }}" accept-charset="UTF-8">
{{ csrf_field() }}
<div class="form-group">
<label for="name" class="form-label">{{ __('master.name') }} <span class="form-required">*</span></label>
<input id="name" type="text" class="form-control{{ $errors->has('name') ? ' is-invalid' : '' }}" name="name" value="{{ old('name') }}" required>
{!! $errors->first('name', '<span class="invalid-feedback" role="alert">:message</span>') !!}
<label for="title" class="form-label">{{ __('master.title') }} <span class="form-required">*</span></label>
<input id="title" type="text" class="form-control{{ $errors->has('title') ? ' is-invalid' : '' }}" name="title" value="{{ old('title') }}" required>
{!! $errors->first('title', '<span class="invalid-feedback" role="alert">:message</span>') !!}
</div>
<div class="form-group">
<label for="description" class="form-label">{{ __('master.description') }}</label>
@ -22,9 +22,9 @@
<form method="POST" action="{{ route('masters.update', $editableMaster) }}" accept-charset="UTF-8">
{{ csrf_field() }} {{ method_field('patch') }}
<div class="form-group">
<label for="name" class="form-label">{{ __('master.name') }} <span class="form-required">*</span></label>
<input id="name" type="text" class="form-control{{ $errors->has('name') ? ' is-invalid' : '' }}" name="name" value="{{ old('name', $editableMaster->name) }}" required>
{!! $errors->first('name', '<span class="invalid-feedback" role="alert">:message</span>') !!}
<label for="title" class="form-label">{{ __('master.title') }} <span class="form-required">*</span></label>
<input id="title" type="text" class="form-control{{ $errors->has('title') ? ' is-invalid' : '' }}" name="title" value="{{ old('title', $editableMaster->title) }}" required>
{!! $errors->first('title', '<span class="invalid-feedback" role="alert">:message</span>') !!}
</div>
<div class="form-group">
<label for="description" class="form-label">{{ __('master.description') }}</label>
@ -46,8 +46,8 @@
<div class="card">
<div class="card-header">{{ __('master.delete') }}</div>
<div class="card-body">
<label class="form-label text-primary">{{ __('master.name') }}</label>
<p>{{ $editableMaster->name }}</p>
<label class="form-label text-primary">{{ __('master.title') }}</label>
<p>{{ $editableMaster->title }}</p>
<label class="form-label text-primary">{{ __('master.description') }}</label>
<p>{{ $editableMaster->description }}</p>
{!! $errors->first('master_id', '<span class="invalid-feedback" role="alert">:message</span>') !!}

4
src/stubs/resources/views/simple/index-bs3.stub

@ -29,7 +29,7 @@
<thead>
<tr>
<th class="text-center">{{ __('app.table_no') }}</th>
<th>{{ __('master.name') }}</th>
<th>{{ __('master.title') }}</th>
<th>{{ __('master.description') }}</th>
<th class="text-center">{{ __('app.action') }}</th>
</tr>
@ -38,7 +38,7 @@
@foreach($mstrCollections as $key => $singleMstr)
<tr>
<td class="text-center">{{ $mstrCollections->firstItem() + $key }}</td>
<td>{{ $singleMstr->name }}</td>
<td>{{ $singleMstr->title }}</td>
<td>{{ $singleMstr->description }}</td>
<td class="text-center">
@can('update', $singleMstr)

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

@ -26,7 +26,7 @@
<thead>
<tr>
<th class="text-center">{{ __('app.table_no') }}</th>
<th>{{ __('master.name') }}</th>
<th>{{ __('master.title') }}</th>
<th>{{ __('master.description') }}</th>
<th class="text-center">{{ __('app.action') }}</th>
</tr>
@ -35,7 +35,7 @@
@foreach($mstrCollections as $key => $singleMstr)
<tr>
<td class="text-center">{{ $mstrCollections->firstItem() + $key }}</td>
<td>{{ $singleMstr->name }}</td>
<td>{{ $singleMstr->title }}</td>
<td>{{ $singleMstr->description }}</td>
<td class="text-center">
@can('update', $singleMstr)

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

@ -26,7 +26,7 @@
<thead>
<tr>
<th class="text-center">{{ __('app.table_no') }}</th>
<th>{{ __('master.name') }}</th>
<th>{{ __('master.title') }}</th>
<th>{{ __('master.description') }}</th>
<th class="text-center">{{ __('app.action') }}</th>
</tr>
@ -35,7 +35,7 @@
@foreach($mstrCollections as $key => $singleMstr)
<tr>
<td class="text-center">{{ $mstrCollections->firstItem() + $key }}</td>
<td>{{ $singleMstr->name }}</td>
<td>{{ $singleMstr->title }}</td>
<td>{{ $singleMstr->description }}</td>
<td class="text-center">
@can('update', $singleMstr)

4
src/stubs/resources/views/simple/index.stub

@ -29,7 +29,7 @@
<thead>
<tr>
<th class="text-center">{{ __('app.table_no') }}</th>
<th>{{ __('master.name') }}</th>
<th>{{ __('master.title') }}</th>
<th>{{ __('master.description') }}</th>
<th class="text-center">{{ __('app.action') }}</th>
</tr>
@ -38,7 +38,7 @@
@foreach($mstrCollections as $key => $singleMstr)
<tr>
<td class="text-center">{{ $mstrCollections->firstItem() + $key }}</td>
<td>{{ $singleMstr->name }}</td>
<td>{{ $singleMstr->title }}</td>
<td>{{ $singleMstr->description }}</td>
<td class="text-center">
@can('update', $singleMstr)

58
src/stubs/testcases/feature/api.stub

@ -20,7 +20,7 @@ class ManageMasterTest extends TestCase
'Authorization' => 'Bearer '.$user->api_token
]);
$this->seeJson(['name' => $singleMstr->name]);
$this->seeJson(['title' => $singleMstr->title]);
}
/** @test */
@ -29,21 +29,21 @@ class ManageMasterTest extends TestCase
$user = $this->createUser();
$this->postJson(route('api.masters.store'), [
'name' => 'Master 1 name',
'title' => 'Master 1 title',
'description' => 'Master 1 description',
], [
'Authorization' => 'Bearer '.$user->api_token
]);
$this->seeInDatabase('masters', [
'name' => 'Master 1 name',
'title' => 'Master 1 title',
'description' => 'Master 1 description',
]);
$this->seeStatusCode(201);
$this->seeJson([
'message' => __('master.created'),
'name' => 'Master 1 name',
'title' => 'Master 1 title',
'description' => 'Master 1 description',
]);
}
@ -51,18 +51,18 @@ class ManageMasterTest extends TestCase
private function getCreateFields(array $overrides = [])
{
return array_merge([
'name' => 'Master 1 name',
'title' => 'Master 1 title',
'description' => 'Master 1 description',
], $overrides);
}
/** @test */
public function validate_master_name_is_required()
public function validate_master_title_is_required()
{
$user = $this->createUser();
// name empty
$requestBody = $this->getCreateFields(['name' => '']);
// title empty
$requestBody = $this->getCreateFields(['title' => '']);
$this->postJson(
route('api.masters.store'),
$requestBody,
@ -70,16 +70,16 @@ class ManageMasterTest extends TestCase
);
$this->seeStatusCode(422);
$this->seeJsonStructure(['errors' => ['name']]);
$this->seeJsonStructure(['errors' => ['title']]);
}
/** @test */
public function validate_master_name_is_not_more_than_60_characters()
public function validate_master_title_is_not_more_than_60_characters()
{
$user = $this->createUser();
// name 70 characters
$requestBody = $this->getCreateFields(['name' => str_repeat('Test Title', 7)]);
// title 70 characters
$requestBody = $this->getCreateFields(['title' => str_repeat('Test Title', 7)]);
$this->postJson(
route('api.masters.store'),
$requestBody,
@ -87,7 +87,7 @@ class ManageMasterTest extends TestCase
);
$this->seeStatusCode(422);
$this->seeJsonStructure(['errors' => ['name']]);
$this->seeJsonStructure(['errors' => ['title']]);
}
/** @test */
@ -111,37 +111,37 @@ class ManageMasterTest extends TestCase
public function user_can_get_a_master_detail()
{
$user = $this->createUser();
$singleMstr = Master::factory()->create(['name' => 'Testing 123']);
$singleMstr = Master::factory()->create(['title' => 'Testing 123']);
$this->getJson(route('api.masters.show', $singleMstr), [
'Authorization' => 'Bearer '.$user->api_token
]);
$this->seeJson(['name' => 'Testing 123']);
$this->seeJson(['title' => 'Testing 123']);
}
/** @test */
public function user_can_update_a_master()
{
$user = $this->createUser();
$singleMstr = Master::factory()->create(['name' => 'Testing 123']);
$singleMstr = Master::factory()->create(['title' => 'Testing 123']);
$this->patchJson(route('api.masters.update', $singleMstr), [
'name' => 'Master 1 name',
'title' => 'Master 1 title',
'description' => 'Master 1 description',
], [
'Authorization' => 'Bearer '.$user->api_token
]);
$this->seeInDatabase('masters', [
'name' => 'Master 1 name',
'title' => 'Master 1 title',
'description' => 'Master 1 description',
]);
$this->seeStatusCode(200);
$this->seeJson([
'message' => __('master.updated'),
'name' => 'Master 1 name',
'title' => 'Master 1 title',
'description' => 'Master 1 description',
]);
}
@ -149,19 +149,19 @@ class ManageMasterTest extends TestCase
private function getEditFields(array $overrides = [])
{
return array_merge([
'name' => 'Master 1 name',
'title' => 'Master 1 title',
'description' => 'Master 1 description',
], $overrides);
}
/** @test */
public function validate_master_name_update_is_required()
public function validate_master_title_update_is_required()
{
$user = $this->createUser();
$singleMstr = Master::factory()->create();
// name empty
$requestBody = $this->getEditFields(['name' => '']);
// title empty
$requestBody = $this->getEditFields(['title' => '']);
$this->patchJson(
route('api.masters.update', $singleMstr),
$requestBody,
@ -169,17 +169,17 @@ class ManageMasterTest extends TestCase
);
$this->seeStatusCode(422);
$this->seeJsonStructure(['errors' => ['name']]);
$this->seeJsonStructure(['errors' => ['title']]);
}
/** @test */
public function validate_master_name_update_is_not_more_than_60_characters()
public function validate_master_title_update_is_not_more_than_60_characters()
{
$user = $this->createUser();
$singleMstr = Master::factory()->create();
// name 70 characters
$requestBody = $this->getEditFields(['name' => str_repeat('Test Title', 7)]);
// title 70 characters
$requestBody = $this->getEditFields(['title' => str_repeat('Test Title', 7)]);
$this->patchJson(
route('api.masters.update', $singleMstr),
$requestBody,
@ -187,14 +187,14 @@ class ManageMasterTest extends TestCase
);
$this->seeStatusCode(422);
$this->seeJsonStructure(['errors' => ['name']]);
$this->seeJsonStructure(['errors' => ['title']]);
}
/** @test */
public function validate_master_description_update_is_not_more_than_255_characters()
{
$user = $this->createUser();
$singleMstr = Master::factory()->create(['name' => 'Testing 123']);
$singleMstr = Master::factory()->create(['title' => 'Testing 123']);
// description 256 characters
$requestBody = $this->getEditFields(['description' => str_repeat('Long description', 16)]);

46
src/stubs/testcases/feature/full.stub

@ -17,13 +17,13 @@ class ManageMasterTest extends TestCase
$this->loginAsUser();
$this->visitRoute('masters.index');
$this->see($singleMstr->name);
$this->see($singleMstr->title);
}
private function getCreateFields(array $overrides = [])
{
return array_merge([
'name' => 'Master 1 name',
'title' => 'Master 1 title',
'description' => 'Master 1 description',
], $overrides);
}
@ -45,25 +45,25 @@ class ManageMasterTest extends TestCase
}
/** @test */
public function validate_master_name_is_required()
public function validate_master_title_is_required()
{
$this->loginAsUser();
// name empty
$this->post(route('masters.store'), $this->getCreateFields(['name' => '']));
$this->assertSessionHasErrors('name');
// title empty
$this->post(route('masters.store'), $this->getCreateFields(['title' => '']));
$this->assertSessionHasErrors('title');
}
/** @test */
public function validate_master_name_is_not_more_than_60_characters()
public function validate_master_title_is_not_more_than_60_characters()
{
$this->loginAsUser();
// name 70 characters
// title 70 characters
$this->post(route('masters.store'), $this->getCreateFields([
'name' => str_repeat('Test Title', 7),
'title' => str_repeat('Test Title', 7),
]));
$this->assertSessionHasErrors('name');
$this->assertSessionHasErrors('title');
}
/** @test */
@ -81,7 +81,7 @@ class ManageMasterTest extends TestCase
private function getEditFields(array $overrides = [])
{
return array_merge([
'name' => 'Master 1 name',
'title' => 'Master 1 title',
'description' => 'Master 1 description',
], $overrides);
}
@ -90,7 +90,7 @@ class ManageMasterTest extends TestCase
public function user_can_edit_a_master()
{
$this->loginAsUser();
$singleMstr = Master::factory()->create(['name' => 'Testing 123']);
$singleMstr = Master::factory()->create(['title' => 'Testing 123']);
$this->visitRoute('masters.show', $singleMstr);
$this->click('edit-master-'.$singleMstr->id);
@ -106,34 +106,34 @@ class ManageMasterTest extends TestCase
}
/** @test */
public function validate_master_name_update_is_required()
public function validate_master_title_update_is_required()
{
$this->loginAsUser();
$master = Master::factory()->create(['name' => 'Testing 123']);
$master = Master::factory()->create(['title' => 'Testing 123']);
// name empty
$this->patch(route('masters.update', $master), $this->getEditFields(['name' => '']));
$this->assertSessionHasErrors('name');
// title empty
$this->patch(route('masters.update', $master), $this->getEditFields(['title' => '']));
$this->assertSessionHasErrors('title');
}
/** @test */
public function validate_master_name_update_is_not_more_than_60_characters()
public function validate_master_title_update_is_not_more_than_60_characters()
{
$this->loginAsUser();
$master = Master::factory()->create(['name' => 'Testing 123']);
$master = Master::factory()->create(['title' => 'Testing 123']);
// name 70 characters
// title 70 characters
$this->patch(route('masters.update', $master), $this->getEditFields([
'name' => str_repeat('Test Title', 7),
'title' => str_repeat('Test Title', 7),
]));
$this->assertSessionHasErrors('name');
$this->assertSessionHasErrors('title');
}
/** @test */
public function validate_master_description_update_is_not_more_than_255_characters()
{
$this->loginAsUser();
$master = Master::factory()->create(['name' => 'Testing 123']);
$master = Master::factory()->create(['title' => 'Testing 123']);
// description 256 characters
$this->patch(route('masters.update', $master), $this->getEditFields([

54
src/stubs/testcases/feature/simple.stub

@ -17,7 +17,7 @@ class ManageMasterTest extends TestCase
$this->loginAsUser();
$this->visitRoute('masters.index');
$this->see($singleMstr->name);
$this->see($singleMstr->title);
}
/** @test */
@ -30,14 +30,14 @@ class ManageMasterTest extends TestCase
$this->seeRouteIs('masters.index', ['action' => 'create']);
$this->submitForm(__('master.create'), [
'name' => 'Master 1 name',
'title' => 'Master 1 title',
'description' => 'Master 1 description',
]);
$this->seeRouteIs('masters.index');
$this->seeInDatabase('masters', [
'name' => 'Master 1 name',
'title' => 'Master 1 title',
'description' => 'Master 1 description',
]);
}
@ -45,31 +45,31 @@ class ManageMasterTest extends TestCase
private function getCreateFields(array $overrides = [])
{
return array_merge([
'name' => 'Master 1 name',
'title' => 'Master 1 title',
'description' => 'Master 1 description',
], $overrides);
}
/** @test */
public function validate_master_name_is_required()
public function validate_master_title_is_required()
{
$this->loginAsUser();
// name empty
$this->post(route('masters.store'), $this->getCreateFields(['name' => '']));
$this->assertSessionHasErrors('name');
// title empty
$this->post(route('masters.store'), $this->getCreateFields(['title' => '']));
$this->assertSessionHasErrors('title');
}
/** @test */
public function validate_master_name_is_not_more_than_60_characters()
public function validate_master_title_is_not_more_than_60_characters()
{
$this->loginAsUser();
// name 70 characters
// title 70 characters
$this->post(route('masters.store'), $this->getCreateFields([
'name' => str_repeat('Test Title', 7),
'title' => str_repeat('Test Title', 7),
]));
$this->assertSessionHasErrors('name');
$this->assertSessionHasErrors('title');
}
/** @test */
@ -88,21 +88,21 @@ class ManageMasterTest extends TestCase
public function user_can_edit_a_master_within_search_query()
{
$this->loginAsUser();
$singleMstr = Master::factory()->create(['name' => 'Testing 123']);
$singleMstr = Master::factory()->create(['title' => 'Testing 123']);
$this->visitRoute('masters.index', ['q' => '123']);
$this->click('edit-master-'.$singleMstr->id);
$this->seeRouteIs('masters.index', ['action' => 'edit', 'id' => $singleMstr->id, 'q' => '123']);
$this->submitForm(__('master.update'), [
'name' => 'Master 1 name',
'title' => 'Master 1 title',
'description' => 'Master 1 description',
]);
$this->seeRouteIs('masters.index', ['q' => '123']);
$this->seeInDatabase('masters', [
'name' => 'Master 1 name',
'title' => 'Master 1 title',
'description' => 'Master 1 description',
]);
}
@ -110,40 +110,40 @@ class ManageMasterTest extends TestCase
private function getEditFields(array $overrides = [])
{
return array_merge([
'name' => 'Master 1 name',
'title' => 'Master 1 title',
'description' => 'Master 1 description',
], $overrides);
}
/** @test */
public function validate_master_name_update_is_required()
public function validate_master_title_update_is_required()
{
$this->loginAsUser();
$master = Master::factory()->create(['name' => 'Testing 123']);
$master = Master::factory()->create(['title' => 'Testing 123']);
// name empty
$this->patch(route('masters.update', $master), $this->getEditFields(['name' => '']));
$this->assertSessionHasErrors('name');
// title empty
$this->patch(route('masters.update', $master), $this->getEditFields(['title' => '']));
$this->assertSessionHasErrors('title');
}
/** @test */
public function validate_master_name_update_is_not_more_than_60_characters()
public function validate_master_title_update_is_not_more_than_60_characters()
{
$this->loginAsUser();
$master = Master::factory()->create(['name' => 'Testing 123']);
$master = Master::factory()->create(['title' => 'Testing 123']);
// name 70 characters
// title 70 characters
$this->patch(route('masters.update', $master), $this->getEditFields([
'name' => str_repeat('Test Title', 7),
'title' => str_repeat('Test Title', 7),
]));
$this->assertSessionHasErrors('name');
$this->assertSessionHasErrors('title');
}
/** @test */
public function validate_master_description_update_is_not_more_than_255_characters()
{
$this->loginAsUser();
$master = Master::factory()->create(['name' => 'Testing 123']);
$master = Master::factory()->create(['title' => 'Testing 123']);
// description 256 characters
$this->patch(route('masters.update', $master), $this->getEditFields([

8
src/stubs/testcases/unit/model-formfield.stub

@ -12,17 +12,17 @@ class MasterTest extends TestCase
use RefreshDatabase;
/** @test */
public function a_master_has_name_link_attribute()
public function a_master_has_title_link_attribute()
{
$singleMstr = Master::factory()->create();
$this->assertEquals(
link_to_route('masters.show', $singleMstr->name, [$singleMstr], [
link_to_route('masters.show', $singleMstr->title, [$singleMstr], [
'title' => __(
'app.show_detail_title',
['name' => $singleMstr->name, 'type' => __('master.master')]
['title' => $singleMstr->title, 'type' => __('master.master')]
),
]), $singleMstr->name_link
]), $singleMstr->title_link
);
}

8
src/stubs/testcases/unit/model.stub

@ -12,19 +12,19 @@ class MasterTest extends TestCase
use RefreshDatabase;
/** @test */
public function a_master_has_name_link_attribute()
public function a_master_has_title_link_attribute()
{
$singleMstr = Master::factory()->create();
$title = __('app.show_detail_title', [
'name' => $singleMstr->name, 'type' => __('master.master'),
'title' => $singleMstr->title, 'type' => __('master.master'),
]);
$link = '<a href="'.route('masters.show', $singleMstr).'"';
$link .= ' title="'.$title.'">';
$link .= $singleMstr->name;
$link .= $singleMstr->title;
$link .= '</a>';
$this->assertEquals($link, $singleMstr->name_link);
$this->assertEquals($link, $singleMstr->title_link);
}
/** @test */

26
tests/CommandOptions/FullCrudBs3OptionsTest.php

@ -73,7 +73,7 @@ class FullCrudBs3OptionsTest extends TestCase
<thead>
<tr>
<th class=\"text-center\">{{ __('app.table_no') }}</th>
<th>{{ __('{$this->lang_name}.name') }}</th>
<th>{{ __('{$this->lang_name}.title') }}</th>
<th>{{ __('{$this->lang_name}.description') }}</th>
<th class=\"text-center\">{{ __('app.action') }}</th>
</tr>
@ -82,7 +82,7 @@ class FullCrudBs3OptionsTest extends TestCase
@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}->title_link !!}</td>
<td>{{ \${$this->single_model_var_name}->description }}</td>
<td class=\"text-center\">
@can('view', \${$this->single_model_var_name})
@ -121,7 +121,7 @@ class FullCrudBs3OptionsTest extends TestCase
<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}.title') }}</td><td>{{ \${$this->single_model_var_name}->title }}</td></tr>
<tr><td>{{ __('{$this->lang_name}.description') }}</td><td>{{ \${$this->single_model_var_name}->description }}</td></tr>
</tbody>
</table>
@ -158,10 +158,10 @@ class FullCrudBs3OptionsTest extends TestCase
<form method=\"POST\" action=\"{{ route('{$this->table_name}.store') }}\" accept-charset=\"UTF-8\">
{{ csrf_field() }}
<div class=\"panel-body\">
<div class=\"form-group{{ \$errors->has('name') ? ' has-error' : '' }}\">
<label for=\"name\" class=\"control-label\">{{ __('{$this->lang_name}.name') }}</label>
<input id=\"name\" type=\"text\" class=\"form-control\" name=\"name\" value=\"{{ old('name') }}\" required>
{!! \$errors->first('name', '<span class=\"help-block small\">:message</span>') !!}
<div class=\"form-group{{ \$errors->has('title') ? ' has-error' : '' }}\">
<label for=\"title\" class=\"control-label\">{{ __('{$this->lang_name}.title') }}</label>
<input id=\"title\" type=\"text\" class=\"form-control\" name=\"title\" value=\"{{ old('title') }}\" required>
{!! \$errors->first('title', '<span class=\"help-block small\">:message</span>') !!}
</div>
<div class=\"form-group{{ \$errors->has('description') ? ' has-error' : '' }}\">
<label for=\"description\" class=\"control-label\">{{ __('{$this->lang_name}.description') }}</label>
@ -201,8 +201,8 @@ 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 text-primary\">{{ __('{$this->lang_name}.name') }}</label>
<p>{{ \${$this->single_model_var_name}->name }}</p>
<label class=\"control-label text-primary\">{{ __('{$this->lang_name}.title') }}</label>
<p>{{ \${$this->single_model_var_name}->title }}</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>') !!}
@ -225,10 +225,10 @@ class FullCrudBs3OptionsTest extends TestCase
<form method=\"POST\" action=\"{{ route('{$this->table_name}.update', \${$this->single_model_var_name}) }}\" accept-charset=\"UTF-8\">
{{ csrf_field() }} {{ method_field('patch') }}
<div class=\"panel-body\">
<div class=\"form-group{{ \$errors->has('name') ? ' has-error' : '' }}\">
<label for=\"name\" class=\"control-label\">{{ __('{$this->lang_name}.name') }}</label>
<input id=\"name\" type=\"text\" class=\"form-control\" name=\"name\" value=\"{{ old('name', \${$this->single_model_var_name}->name) }}\" required>
{!! \$errors->first('name', '<span class=\"help-block small\">:message</span>') !!}
<div class=\"form-group{{ \$errors->has('title') ? ' has-error' : '' }}\">
<label for=\"title\" class=\"control-label\">{{ __('{$this->lang_name}.title') }}</label>
<input id=\"title\" type=\"text\" class=\"form-control\" name=\"title\" value=\"{{ old('title', \${$this->single_model_var_name}->title) }}\" required>
{!! \$errors->first('title', '<span class=\"help-block small\">:message</span>') !!}
</div>
<div class=\"form-group{{ \$errors->has('description') ? ' has-error' : '' }}\">
<label for=\"description\" class=\"control-label\">{{ __('{$this->lang_name}.description') }}</label>

9
tests/CommandOptions/FullCrudFormRequestOptionsTest.php

@ -59,10 +59,11 @@ class {$this->model_name}Controller extends Controller
*
* @return \Illuminate\View\View
*/
public function index()
public function index(Request \$request)
{
\${$this->single_model_var_name}Query = {$this->model_name}::query();
\${$this->single_model_var_name}Query->where('name', 'like', '%'.request('q').'%');
\${$this->single_model_var_name}Query->where('title', 'like', '%'.\$request->get('q').'%');
\${$this->single_model_var_name}Query->orderBy('title');
\${$this->collection_model_var_name} = \${$this->single_model_var_name}Query->paginate(25);
return view('{$this->table_name}.index', compact('{$this->collection_model_var_name}'));
@ -190,7 +191,7 @@ class CreateRequest extends FormRequest
public function rules()
{
return [
'name' => 'required|max:60',
'title' => 'required|max:60',
'description' => 'nullable|max:255',
];
}
@ -246,7 +247,7 @@ class UpdateRequest extends FormRequest
public function rules()
{
return [
'name' => 'required|max:60',
'title' => 'required|max:60',
'description' => 'nullable|max:255',
];
}

14
tests/CommandOptions/FullCrudFormfieldBs3OptionsTest.php

@ -70,7 +70,7 @@ class FullCrudFormfieldBs3OptionsTest extends TestCase
<thead>
<tr>
<th class=\"text-center\">{{ __('app.table_no') }}</th>
<th>{{ __('{$this->lang_name}.name') }}</th>
<th>{{ __('{$this->lang_name}.title') }}</th>
<th>{{ __('{$this->lang_name}.description') }}</th>
<th class=\"text-center\">{{ __('app.action') }}</th>
</tr>
@ -79,7 +79,7 @@ class FullCrudFormfieldBs3OptionsTest extends TestCase
@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}->title_link }}</td>
<td>{{ \${$this->single_model_var_name}->description }}</td>
<td class=\"text-center\">
@can('view', \${$this->single_model_var_name})
@ -123,7 +123,7 @@ class FullCrudFormfieldBs3OptionsTest extends TestCase
<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}.title') }}</td><td>{{ \${$this->single_model_var_name}->title }}</td></tr>
<tr><td>{{ __('{$this->lang_name}.description') }}</td><td>{{ \${$this->single_model_var_name}->description }}</td></tr>
</tbody>
</table>
@ -159,7 +159,7 @@ class FullCrudFormfieldBs3OptionsTest extends TestCase
<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::text('title', ['required' => true, 'label' => __('{$this->lang_name}.title')]) !!}
{!! FormField::textarea('description', ['label' => __('{$this->lang_name}.description')]) !!}
</div>
<div class=\"panel-footer\">
@ -194,8 +194,8 @@ class FullCrudFormfieldBs3OptionsTest 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 text-primary\">{{ __('{$this->lang_name}.name') }}</label>
<p>{{ \${$this->single_model_var_name}->name }}</p>
<label class=\"control-label text-primary\">{{ __('{$this->lang_name}.title') }}</label>
<p>{{ \${$this->single_model_var_name}->title }}</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>') !!}
@ -218,7 +218,7 @@ class FullCrudFormfieldBs3OptionsTest extends TestCase
<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::text('title', ['required' => true, 'label' => __('{$this->lang_name}.title')]) !!}
{!! FormField::textarea('description', ['label' => __('{$this->lang_name}.description')]) !!}
</div>
<div class=\"panel-footer\">

30
tests/CommandOptions/FullCrudFormfieldOptionsTest.php

@ -70,7 +70,7 @@ class FullCrudFormfieldOptionsTest extends TestCase
<thead>
<tr>
<th class=\"text-center\">{{ __('app.table_no') }}</th>
<th>{{ __('{$this->lang_name}.name') }}</th>
<th>{{ __('{$this->lang_name}.title') }}</th>
<th>{{ __('{$this->lang_name}.description') }}</th>
<th class=\"text-center\">{{ __('app.action') }}</th>
</tr>
@ -79,7 +79,7 @@ class FullCrudFormfieldOptionsTest extends TestCase
@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}->title_link }}</td>
<td>{{ \${$this->single_model_var_name}->description }}</td>
<td class=\"text-center\">
@can('view', \${$this->single_model_var_name})
@ -124,7 +124,7 @@ class FullCrudFormfieldOptionsTest extends TestCase
<div class=\"card-body\">
<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}.title') }}</td><td>{{ \${$this->single_model_var_name}->title }}</td></tr>
<tr><td>{{ __('{$this->lang_name}.description') }}</td><td>{{ \${$this->single_model_var_name}->description }}</td></tr>
</tbody>
</table>
@ -161,7 +161,7 @@ class FullCrudFormfieldOptionsTest extends TestCase
<div class=\"card-header\">{{ __('{$this->lang_name}.create') }}</div>
{{ Form::open(['route' => '{$this->table_name}.store']) }}
<div class=\"card-body\">
{!! FormField::text('name', ['required' => true, 'label' => __('{$this->lang_name}.name')]) !!}
{!! FormField::text('title', ['required' => true, 'label' => __('{$this->lang_name}.title')]) !!}
{!! FormField::textarea('description', ['label' => __('{$this->lang_name}.description')]) !!}
</div>
<div class=\"card-footer\">
@ -196,8 +196,8 @@ class FullCrudFormfieldOptionsTest extends TestCase
<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 text-primary\">{{ __('{$this->lang_name}.title') }}</label>
<p>{{ \${$this->single_model_var_name}->title }}</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>') !!}
@ -220,7 +220,7 @@ class FullCrudFormfieldOptionsTest extends TestCase
<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::text('title', ['required' => true, 'label' => __('{$this->lang_name}.title')]) !!}
{!! FormField::textarea('description', ['label' => __('{$this->lang_name}.description')]) !!}
</div>
<div class=\"card-footer\">
@ -260,14 +260,14 @@ class {$this->model_name} extends Model
{
use HasFactory;
protected \$fillable = ['name', 'description', 'creator_id'];
protected \$fillable = ['title', 'description', 'creator_id'];
public function getNameLinkAttribute()
public function getTitleLinkAttribute()
{
return link_to_route('{$this->table_name}.show', \$this->name, [\$this], [
return link_to_route('{$this->table_name}.show', \$this->title, [\$this], [
'title' => __(
'app.show_detail_title',
['name' => \$this->name, 'type' => __('{$this->lang_name}.{$this->lang_name}')]
['title' => \$this->title, 'type' => __('{$this->lang_name}.{$this->lang_name}')]
),
]);
}
@ -303,17 +303,17 @@ class {$this->model_name}Test extends TestCase
use RefreshDatabase;
/** @test */
public function a_{$this->lang_name}_has_name_link_attribute()
public function a_{$this->lang_name}_has_title_link_attribute()
{
\${$this->single_model_var_name} = {$this->model_name}::factory()->create();
\$this->assertEquals(
link_to_route('{$this->table_name}.show', \${$this->single_model_var_name}->name, [\${$this->single_model_var_name}], [
link_to_route('{$this->table_name}.show', \${$this->single_model_var_name}->title, [\${$this->single_model_var_name}], [
'title' => __(
'app.show_detail_title',
['name' => \${$this->single_model_var_name}->name, 'type' => __('{$this->lang_name}.{$this->lang_name}')]
['title' => \${$this->single_model_var_name}->title, 'type' => __('{$this->lang_name}.{$this->lang_name}')]
),
]), \${$this->single_model_var_name}->name_link
]), \${$this->single_model_var_name}->title_link
);
}

24
tests/CommandOptions/SimpleCrudBs3OptionsTest.php

@ -71,7 +71,7 @@ class SimpleCrudBs3OptionsTest extends TestCase
<thead>
<tr>
<th class=\"text-center\">{{ __('app.table_no') }}</th>
<th>{{ __('{$this->lang_name}.name') }}</th>
<th>{{ __('{$this->lang_name}.title') }}</th>
<th>{{ __('{$this->lang_name}.description') }}</th>
<th class=\"text-center\">{{ __('app.action') }}</th>
</tr>
@ -80,7 +80,7 @@ class SimpleCrudBs3OptionsTest extends TestCase
@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}->title }}</td>
<td>{{ \${$this->single_model_var_name}->description }}</td>
<td class=\"text-center\">
@can('update', \${$this->single_model_var_name})
@ -116,10 +116,10 @@ class SimpleCrudBs3OptionsTest extends TestCase
@can('create', new {$this->full_model_name})
<form method=\"POST\" action=\"{{ route('{$this->table_name}.store') }}\" accept-charset=\"UTF-8\">
{{ csrf_field() }}
<div class=\"form-group{{ \$errors->has('name') ? ' has-error' : '' }}\">
<label for=\"name\" class=\"control-label\">{{ __('{$this->lang_name}.name') }}</label>
<input id=\"name\" type=\"text\" class=\"form-control\" name=\"name\" value=\"{{ old('name') }}\" required>
{!! \$errors->first('name', '<span class=\"help-block small\">:message</span>') !!}
<div class=\"form-group{{ \$errors->has('title') ? ' has-error' : '' }}\">
<label for=\"title\" class=\"control-label\">{{ __('{$this->lang_name}.title') }}</label>
<input id=\"title\" type=\"text\" class=\"form-control\" name=\"title\" value=\"{{ old('title') }}\" required>
{!! \$errors->first('title', '<span class=\"help-block small\">:message</span>') !!}
</div>
<div class=\"form-group{{ \$errors->has('description') ? ' has-error' : '' }}\">
<label for=\"description\" class=\"control-label\">{{ __('{$this->lang_name}.description') }}</label>
@ -135,10 +135,10 @@ class SimpleCrudBs3OptionsTest extends TestCase
@can('update', \$editable{$this->model_name})
<form method=\"POST\" action=\"{{ route('{$this->table_name}.update', \$editable{$this->model_name}) }}\" accept-charset=\"UTF-8\">
{{ csrf_field() }} {{ method_field('patch') }}
<div class=\"form-group{{ \$errors->has('name') ? ' has-error' : '' }}\">
<label for=\"name\" class=\"control-label\">{{ __('{$this->lang_name}.name') }}</label>
<input id=\"name\" type=\"text\" class=\"form-control\" name=\"name\" value=\"{{ old('name', \$editable{$this->model_name}->name) }}\" required>
{!! \$errors->first('name', '<span class=\"help-block small\">:message</span>') !!}
<div class=\"form-group{{ \$errors->has('title') ? ' has-error' : '' }}\">
<label for=\"title\" class=\"control-label\">{{ __('{$this->lang_name}.title') }}</label>
<input id=\"title\" type=\"text\" class=\"form-control\" name=\"title\" value=\"{{ old('title', \$editable{$this->model_name}->title) }}\" required>
{!! \$errors->first('title', '<span class=\"help-block small\">:message</span>') !!}
</div>
<div class=\"form-group{{ \$errors->has('description') ? ' has-error' : '' }}\">
<label for=\"description\" class=\"control-label\">{{ __('{$this->lang_name}.description') }}</label>
@ -160,8 +160,8 @@ 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 text-primary\">{{ __('{$this->lang_name}.name') }}</label>
<p>{{ \$editable{$this->model_name}->name }}</p>
<label class=\"control-label text-primary\">{{ __('{$this->lang_name}.title') }}</label>
<p>{{ \$editable{$this->model_name}->title }}</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>') !!}

12
tests/CommandOptions/SimpleCrudFormfieldBs3OptionsTest.php

@ -68,7 +68,7 @@ class SimpleCrudFormfieldBs3OptionsTest extends TestCase
<thead>
<tr>
<th class=\"text-center\">{{ __('app.table_no') }}</th>
<th>{{ __('{$this->lang_name}.name') }}</th>
<th>{{ __('{$this->lang_name}.title') }}</th>
<th>{{ __('{$this->lang_name}.description') }}</th>
<th class=\"text-center\">{{ __('app.action') }}</th>
</tr>
@ -77,7 +77,7 @@ class SimpleCrudFormfieldBs3OptionsTest extends TestCase
@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}->title }}</td>
<td>{{ \${$this->single_model_var_name}->description }}</td>
<td class=\"text-center\">
@can('update', \${$this->single_model_var_name})
@ -117,7 +117,7 @@ class SimpleCrudFormfieldBs3OptionsTest 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' => __('{$this->lang_name}.name')]) !!}
{!! FormField::text('title', ['required' => true, 'label' => __('{$this->lang_name}.title')]) !!}
{!! 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']) }}
@ -127,7 +127,7 @@ class SimpleCrudFormfieldBs3OptionsTest extends TestCase
@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::text('title', ['required' => true, 'label' => __('{$this->lang_name}.title')]) !!}
{!! FormField::textarea('description', ['label' => __('{$this->lang_name}.description')]) !!}
@if (request('q'))
{{ Form::hidden('q', request('q')) }}
@ -153,8 +153,8 @@ class SimpleCrudFormfieldBs3OptionsTest 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 text-primary\">{{ __('{$this->lang_name}.name') }}</label>
<p>{{ \$editable{$this->model_name}->name }}</p>
<label class=\"control-label text-primary\">{{ __('{$this->lang_name}.title') }}</label>
<p>{{ \$editable{$this->model_name}->title }}</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>') !!}

12
tests/CommandOptions/SimpleCrudFormfieldOptionsTest.php

@ -68,7 +68,7 @@ class SimpleCrudFormfieldOptionsTest extends TestCase
<thead>
<tr>
<th class=\"text-center\">{{ __('app.table_no') }}</th>
<th>{{ __('{$this->lang_name}.name') }}</th>
<th>{{ __('{$this->lang_name}.title') }}</th>
<th>{{ __('{$this->lang_name}.description') }}</th>
<th class=\"text-center\">{{ __('app.action') }}</th>
</tr>
@ -77,7 +77,7 @@ class SimpleCrudFormfieldOptionsTest extends TestCase
@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}->title }}</td>
<td>{{ \${$this->single_model_var_name}->description }}</td>
<td class=\"text-center\">
@can('update', \${$this->single_model_var_name})
@ -117,7 +117,7 @@ class SimpleCrudFormfieldOptionsTest 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' => __('{$this->lang_name}.name')]) !!}
{!! FormField::text('title', ['required' => true, 'label' => __('{$this->lang_name}.title')]) !!}
{!! 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-link']) }}
@ -127,7 +127,7 @@ class SimpleCrudFormfieldOptionsTest extends TestCase
@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::text('title', ['required' => true, 'label' => __('{$this->lang_name}.title')]) !!}
{!! FormField::textarea('description', ['label' => __('{$this->lang_name}.description')]) !!}
@if (request('q'))
{{ Form::hidden('q', request('q')) }}
@ -153,8 +153,8 @@ class SimpleCrudFormfieldOptionsTest extends TestCase
<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 text-primary\">{{ __('{$this->lang_name}.title') }}</label>
<p>{{ \$editable{$this->model_name}->title }}</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>') !!}

2
tests/CrudMakeClassPropertiesTest.php

@ -56,7 +56,7 @@ class CrudMakeClassPropertiesTest extends TestCase
}
/** @test */
public function it_set_proper_model_names_property_for_namespaced_model_name_entry()
public function it_set_proper_model_names_property_for_namespaced_model_title_entry()
{
$this->assertEquals([
'model_namespace' => 'App\Entities\References',

9
tests/Generators/Api/ApiControllerGeneratorTest.php

@ -27,10 +27,11 @@ class {$this->model_name}Controller extends Controller
*
* @return \Illuminate\Http\JsonResponse
*/
public function index()
public function index(Request \$request)
{
\${$this->single_model_var_name}Query = {$this->model_name}::query();
\${$this->single_model_var_name}Query->where('name', 'like', '%'.request('q').'%');
\${$this->single_model_var_name}Query->where('title', 'like', '%'.\$request->get('q').'%');
\${$this->single_model_var_name}Query->orderBy('title');
\${$this->collection_model_var_name} = \${$this->single_model_var_name}Query->paginate(25);
return \${$this->collection_model_var_name};
@ -47,7 +48,7 @@ class {$this->model_name}Controller extends Controller
\$this->authorize('create', new {$this->model_name});
\$new{$this->model_name} = \$request->validate([
'name' => 'required|max:60',
'title' => 'required|max:60',
'description' => 'nullable|max:255',
]);
\$new{$this->model_name}['creator_id'] = auth()->id();
@ -83,7 +84,7 @@ class {$this->model_name}Controller extends Controller
\$this->authorize('update', \${$this->single_model_var_name});
\${$this->single_model_var_name}Data = \$request->validate([
'name' => 'required|max:60',
'title' => 'required|max:60',
'description' => 'nullable|max:255',
]);
\${$this->single_model_var_name}->update(\${$this->single_model_var_name}Data);

116
tests/Generators/Api/ApiFeatureTestGeneratorTest.php

@ -34,7 +34,7 @@ class Manage{$this->model_name}Test extends TestCase
'Authorization' => 'Bearer '.\$user->api_token
]);
\$this->seeJson(['name' => \${$this->single_model_var_name}->name]);
\$this->seeJson(['title' => \${$this->single_model_var_name}->title]);
}
/** @test */
@ -43,21 +43,21 @@ class Manage{$this->model_name}Test extends TestCase
\$user = \$this->createUser();
\$this->postJson(route('api.{$this->table_name}.store'), [
'name' => '{$this->model_name} 1 name',
'title' => '{$this->model_name} 1 title',
'description' => '{$this->model_name} 1 description',
], [
'Authorization' => 'Bearer '.\$user->api_token
]);
\$this->seeInDatabase('{$this->table_name}', [
'name' => '{$this->model_name} 1 name',
'title' => '{$this->model_name} 1 title',
'description' => '{$this->model_name} 1 description',
]);
\$this->seeStatusCode(201);
\$this->seeJson([
'message' => __('{$this->lang_name}.created'),
'name' => '{$this->model_name} 1 name',
'title' => '{$this->model_name} 1 title',
'description' => '{$this->model_name} 1 description',
]);
}
@ -65,18 +65,18 @@ class Manage{$this->model_name}Test extends TestCase
private function getCreateFields(array \$overrides = [])
{
return array_merge([
'name' => '{$this->model_name} 1 name',
'title' => '{$this->model_name} 1 title',
'description' => '{$this->model_name} 1 description',
], \$overrides);
}
/** @test */
public function validate_{$this->lang_name}_name_is_required()
public function validate_{$this->lang_name}_title_is_required()
{
\$user = \$this->createUser();
// name empty
\$requestBody = \$this->getCreateFields(['name' => '']);
// title empty
\$requestBody = \$this->getCreateFields(['title' => '']);
\$this->postJson(
route('api.{$this->table_name}.store'),
\$requestBody,
@ -84,16 +84,16 @@ class Manage{$this->model_name}Test extends TestCase
);
\$this->seeStatusCode(422);
\$this->seeJsonStructure(['errors' => ['name']]);
\$this->seeJsonStructure(['errors' => ['title']]);
}
/** @test */
public function validate_{$this->lang_name}_name_is_not_more_than_60_characters()
public function validate_{$this->lang_name}_title_is_not_more_than_60_characters()
{
\$user = \$this->createUser();
// name 70 characters
\$requestBody = \$this->getCreateFields(['name' => str_repeat('Test Title', 7)]);
// title 70 characters
\$requestBody = \$this->getCreateFields(['title' => str_repeat('Test Title', 7)]);
\$this->postJson(
route('api.{$this->table_name}.store'),
\$requestBody,
@ -101,7 +101,7 @@ class Manage{$this->model_name}Test extends TestCase
);
\$this->seeStatusCode(422);
\$this->seeJsonStructure(['errors' => ['name']]);
\$this->seeJsonStructure(['errors' => ['title']]);
}
/** @test */
@ -125,37 +125,37 @@ class Manage{$this->model_name}Test extends TestCase
public function user_can_get_a_{$this->lang_name}_detail()
{
\$user = \$this->createUser();
\${$this->single_model_var_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']);
\${$this->single_model_var_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']);
\$this->getJson(route('api.{$this->table_name}.show', \${$this->single_model_var_name}), [
'Authorization' => 'Bearer '.\$user->api_token
]);
\$this->seeJson(['name' => 'Testing 123']);
\$this->seeJson(['title' => 'Testing 123']);
}
/** @test */
public function user_can_update_a_{$this->lang_name}()
{
\$user = \$this->createUser();
\${$this->single_model_var_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']);
\${$this->single_model_var_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']);
\$this->patchJson(route('api.{$this->table_name}.update', \${$this->single_model_var_name}), [
'name' => '{$this->model_name} 1 name',
'title' => '{$this->model_name} 1 title',
'description' => '{$this->model_name} 1 description',
], [
'Authorization' => 'Bearer '.\$user->api_token
]);
\$this->seeInDatabase('{$this->table_name}', [
'name' => '{$this->model_name} 1 name',
'title' => '{$this->model_name} 1 title',
'description' => '{$this->model_name} 1 description',
]);
\$this->seeStatusCode(200);
\$this->seeJson([
'message' => __('{$this->lang_name}.updated'),
'name' => '{$this->model_name} 1 name',
'title' => '{$this->model_name} 1 title',
'description' => '{$this->model_name} 1 description',
]);
}
@ -163,19 +163,19 @@ class Manage{$this->model_name}Test extends TestCase
private function getEditFields(array \$overrides = [])
{
return array_merge([
'name' => '{$this->model_name} 1 name',
'title' => '{$this->model_name} 1 title',
'description' => '{$this->model_name} 1 description',
], \$overrides);
}
/** @test */
public function validate_{$this->lang_name}_name_update_is_required()
public function validate_{$this->lang_name}_title_update_is_required()
{
\$user = \$this->createUser();
\${$this->single_model_var_name} = {$this->model_name}::factory()->create();
// name empty
\$requestBody = \$this->getEditFields(['name' => '']);
// title empty
\$requestBody = \$this->getEditFields(['title' => '']);
\$this->patchJson(
route('api.{$this->table_name}.update', \${$this->single_model_var_name}),
\$requestBody,
@ -183,17 +183,17 @@ class Manage{$this->model_name}Test extends TestCase
);
\$this->seeStatusCode(422);
\$this->seeJsonStructure(['errors' => ['name']]);
\$this->seeJsonStructure(['errors' => ['title']]);
}
/** @test */
public function validate_{$this->lang_name}_name_update_is_not_more_than_60_characters()
public function validate_{$this->lang_name}_title_update_is_not_more_than_60_characters()
{
\$user = \$this->createUser();
\${$this->single_model_var_name} = {$this->model_name}::factory()->create();
// name 70 characters
\$requestBody = \$this->getEditFields(['name' => str_repeat('Test Title', 7)]);
// title 70 characters
\$requestBody = \$this->getEditFields(['title' => str_repeat('Test Title', 7)]);
\$this->patchJson(
route('api.{$this->table_name}.update', \${$this->single_model_var_name}),
\$requestBody,
@ -201,14 +201,14 @@ class Manage{$this->model_name}Test extends TestCase
);
\$this->seeStatusCode(422);
\$this->seeJsonStructure(['errors' => ['name']]);
\$this->seeJsonStructure(['errors' => ['title']]);
}
/** @test */
public function validate_{$this->lang_name}_description_update_is_not_more_than_255_characters()
{
\$user = \$this->createUser();
\${$this->single_model_var_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']);
\${$this->single_model_var_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']);
// description 256 characters
\$requestBody = \$this->getEditFields(['description' => str_repeat('Long description', 16)]);
@ -279,7 +279,7 @@ class Manage{$this->model_name}Test extends TestCase
'Authorization' => 'Bearer '.\$user->api_token
]);
\$this->seeJson(['name' => \${$this->single_model_var_name}->name]);
\$this->seeJson(['title' => \${$this->single_model_var_name}->title]);
}
/** @test */
@ -288,21 +288,21 @@ class Manage{$this->model_name}Test extends TestCase
\$user = \$this->createUser();
\$this->postJson(route('api.{$this->table_name}.store'), [
'name' => '{$this->model_name} 1 name',
'title' => '{$this->model_name} 1 title',
'description' => '{$this->model_name} 1 description',
], [
'Authorization' => 'Bearer '.\$user->api_token
]);
\$this->seeInDatabase('{$this->table_name}', [
'name' => '{$this->model_name} 1 name',
'title' => '{$this->model_name} 1 title',
'description' => '{$this->model_name} 1 description',
]);
\$this->seeStatusCode(201);
\$this->seeJson([
'message' => __('{$this->lang_name}.created'),
'name' => '{$this->model_name} 1 name',
'title' => '{$this->model_name} 1 title',
'description' => '{$this->model_name} 1 description',
]);
}
@ -310,18 +310,18 @@ class Manage{$this->model_name}Test extends TestCase
private function getCreateFields(array \$overrides = [])
{
return array_merge([
'name' => '{$this->model_name} 1 name',
'title' => '{$this->model_name} 1 title',
'description' => '{$this->model_name} 1 description',
], \$overrides);
}
/** @test */
public function validate_{$this->lang_name}_name_is_required()
public function validate_{$this->lang_name}_title_is_required()
{
\$user = \$this->createUser();
// name empty
\$requestBody = \$this->getCreateFields(['name' => '']);
// title empty
\$requestBody = \$this->getCreateFields(['title' => '']);
\$this->postJson(
route('api.{$this->table_name}.store'),
\$requestBody,
@ -329,16 +329,16 @@ class Manage{$this->model_name}Test extends TestCase
);
\$this->seeStatusCode(422);
\$this->seeJsonStructure(['errors' => ['name']]);
\$this->seeJsonStructure(['errors' => ['title']]);
}
/** @test */
public function validate_{$this->lang_name}_name_is_not_more_than_60_characters()
public function validate_{$this->lang_name}_title_is_not_more_than_60_characters()
{
\$user = \$this->createUser();
// name 70 characters
\$requestBody = \$this->getCreateFields(['name' => str_repeat('Test Title', 7)]);
// title 70 characters
\$requestBody = \$this->getCreateFields(['title' => str_repeat('Test Title', 7)]);
\$this->postJson(
route('api.{$this->table_name}.store'),
\$requestBody,
@ -346,7 +346,7 @@ class Manage{$this->model_name}Test extends TestCase
);
\$this->seeStatusCode(422);
\$this->seeJsonStructure(['errors' => ['name']]);
\$this->seeJsonStructure(['errors' => ['title']]);
}
/** @test */
@ -370,37 +370,37 @@ class Manage{$this->model_name}Test extends TestCase
public function user_can_get_a_{$this->lang_name}_detail()
{
\$user = \$this->createUser();
\${$this->single_model_var_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']);
\${$this->single_model_var_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']);
\$this->getJson(route('api.{$this->table_name}.show', \${$this->single_model_var_name}), [
'Authorization' => 'Bearer '.\$user->api_token
]);
\$this->seeJson(['name' => 'Testing 123']);
\$this->seeJson(['title' => 'Testing 123']);
}
/** @test */
public function user_can_update_a_{$this->lang_name}()
{
\$user = \$this->createUser();
\${$this->single_model_var_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']);
\${$this->single_model_var_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']);
\$this->patchJson(route('api.{$this->table_name}.update', \${$this->single_model_var_name}), [
'name' => '{$this->model_name} 1 name',
'title' => '{$this->model_name} 1 title',
'description' => '{$this->model_name} 1 description',
], [
'Authorization' => 'Bearer '.\$user->api_token
]);
\$this->seeInDatabase('{$this->table_name}', [
'name' => '{$this->model_name} 1 name',
'title' => '{$this->model_name} 1 title',
'description' => '{$this->model_name} 1 description',
]);
\$this->seeStatusCode(200);
\$this->seeJson([
'message' => __('{$this->lang_name}.updated'),
'name' => '{$this->model_name} 1 name',
'title' => '{$this->model_name} 1 title',
'description' => '{$this->model_name} 1 description',
]);
}
@ -408,19 +408,19 @@ class Manage{$this->model_name}Test extends TestCase
private function getEditFields(array \$overrides = [])
{
return array_merge([
'name' => '{$this->model_name} 1 name',
'title' => '{$this->model_name} 1 title',
'description' => '{$this->model_name} 1 description',
], \$overrides);
}
/** @test */
public function validate_{$this->lang_name}_name_update_is_required()
public function validate_{$this->lang_name}_title_update_is_required()
{
\$user = \$this->createUser();
\${$this->single_model_var_name} = {$this->model_name}::factory()->create();
// name empty
\$requestBody = \$this->getEditFields(['name' => '']);
// title empty
\$requestBody = \$this->getEditFields(['title' => '']);
\$this->patchJson(
route('api.{$this->table_name}.update', \${$this->single_model_var_name}),
\$requestBody,
@ -428,17 +428,17 @@ class Manage{$this->model_name}Test extends TestCase
);
\$this->seeStatusCode(422);
\$this->seeJsonStructure(['errors' => ['name']]);
\$this->seeJsonStructure(['errors' => ['title']]);
}
/** @test */
public function validate_{$this->lang_name}_name_update_is_not_more_than_60_characters()
public function validate_{$this->lang_name}_title_update_is_not_more_than_60_characters()
{
\$user = \$this->createUser();
\${$this->single_model_var_name} = {$this->model_name}::factory()->create();
// name 70 characters
\$requestBody = \$this->getEditFields(['name' => str_repeat('Test Title', 7)]);
// title 70 characters
\$requestBody = \$this->getEditFields(['title' => str_repeat('Test Title', 7)]);
\$this->patchJson(
route('api.{$this->table_name}.update', \${$this->single_model_var_name}),
\$requestBody,
@ -446,14 +446,14 @@ class Manage{$this->model_name}Test extends TestCase
);
\$this->seeStatusCode(422);
\$this->seeJsonStructure(['errors' => ['name']]);
\$this->seeJsonStructure(['errors' => ['title']]);
}
/** @test */
public function validate_{$this->lang_name}_description_update_is_not_more_than_255_characters()
{
\$user = \$this->createUser();
\${$this->single_model_var_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']);
\${$this->single_model_var_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']);
// description 256 characters
\$requestBody = \$this->getEditFields(['description' => str_repeat('Long description', 16)]);

140
tests/Generators/FeatureTestGeneratorTest.php

@ -67,13 +67,13 @@ class Manage{$this->model_name}Test extends TestCase
\$this->loginAsUser();
\$this->visitRoute('{$this->table_name}.index');
\$this->see(\${$this->single_model_var_name}->name);
\$this->see(\${$this->single_model_var_name}->title);
}
private function getCreateFields(array \$overrides = [])
{
return array_merge([
'name' => '{$this->model_name} 1 name',
'title' => '{$this->model_name} 1 title',
'description' => '{$this->model_name} 1 description',
], \$overrides);
}
@ -95,25 +95,25 @@ class Manage{$this->model_name}Test extends TestCase
}
/** @test */
public function validate_{$this->lang_name}_name_is_required()
public function validate_{$this->lang_name}_title_is_required()
{
\$this->loginAsUser();
// name empty
\$this->post(route('{$this->table_name}.store'), \$this->getCreateFields(['name' => '']));
\$this->assertSessionHasErrors('name');
// title empty
\$this->post(route('{$this->table_name}.store'), \$this->getCreateFields(['title' => '']));
\$this->assertSessionHasErrors('title');
}
/** @test */
public function validate_{$this->lang_name}_name_is_not_more_than_60_characters()
public function validate_{$this->lang_name}_title_is_not_more_than_60_characters()
{
\$this->loginAsUser();
// name 70 characters
// title 70 characters
\$this->post(route('{$this->table_name}.store'), \$this->getCreateFields([
'name' => str_repeat('Test Title', 7),
'title' => str_repeat('Test Title', 7),
]));
\$this->assertSessionHasErrors('name');
\$this->assertSessionHasErrors('title');
}
/** @test */
@ -131,7 +131,7 @@ class Manage{$this->model_name}Test extends TestCase
private function getEditFields(array \$overrides = [])
{
return array_merge([
'name' => '{$this->model_name} 1 name',
'title' => '{$this->model_name} 1 title',
'description' => '{$this->model_name} 1 description',
], \$overrides);
}
@ -140,7 +140,7 @@ class Manage{$this->model_name}Test extends TestCase
public function user_can_edit_a_{$this->lang_name}()
{
\$this->loginAsUser();
\${$this->single_model_var_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']);
\${$this->single_model_var_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']);
\$this->visitRoute('{$this->table_name}.show', \${$this->single_model_var_name});
\$this->click('edit-{$this->lang_name}-'.\${$this->single_model_var_name}->id);
@ -156,34 +156,34 @@ class Manage{$this->model_name}Test extends TestCase
}
/** @test */
public function validate_{$this->lang_name}_name_update_is_required()
public function validate_{$this->lang_name}_title_update_is_required()
{
\$this->loginAsUser();
\${$this->lang_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']);
\${$this->lang_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']);
// name empty
\$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields(['name' => '']));
\$this->assertSessionHasErrors('name');
// title empty
\$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields(['title' => '']));
\$this->assertSessionHasErrors('title');
}
/** @test */
public function validate_{$this->lang_name}_name_update_is_not_more_than_60_characters()
public function validate_{$this->lang_name}_title_update_is_not_more_than_60_characters()
{
\$this->loginAsUser();
\${$this->lang_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']);
\${$this->lang_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']);
// name 70 characters
// title 70 characters
\$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields([
'name' => str_repeat('Test Title', 7),
'title' => str_repeat('Test Title', 7),
]));
\$this->assertSessionHasErrors('name');
\$this->assertSessionHasErrors('title');
}
/** @test */
public function validate_{$this->lang_name}_description_update_is_not_more_than_255_characters()
{
\$this->loginAsUser();
\${$this->lang_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']);
\${$this->lang_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']);
// description 256 characters
\$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields([
@ -284,13 +284,13 @@ class Manage{$this->model_name}Test extends TestCase
\$this->loginAsUser();
\$this->visitRoute('{$this->table_name}.index');
\$this->see(\${$this->single_model_var_name}->name);
\$this->see(\${$this->single_model_var_name}->title);
}
private function getCreateFields(array \$overrides = [])
{
return array_merge([
'name' => '{$this->model_name} 1 name',
'title' => '{$this->model_name} 1 title',
'description' => '{$this->model_name} 1 description',
], \$overrides);
}
@ -312,25 +312,25 @@ class Manage{$this->model_name}Test extends TestCase
}
/** @test */
public function validate_{$this->lang_name}_name_is_required()
public function validate_{$this->lang_name}_title_is_required()
{
\$this->loginAsUser();
// name empty
\$this->post(route('{$this->table_name}.store'), \$this->getCreateFields(['name' => '']));
\$this->assertSessionHasErrors('name');
// title empty
\$this->post(route('{$this->table_name}.store'), \$this->getCreateFields(['title' => '']));
\$this->assertSessionHasErrors('title');
}
/** @test */
public function validate_{$this->lang_name}_name_is_not_more_than_60_characters()
public function validate_{$this->lang_name}_title_is_not_more_than_60_characters()
{
\$this->loginAsUser();
// name 70 characters
// title 70 characters
\$this->post(route('{$this->table_name}.store'), \$this->getCreateFields([
'name' => str_repeat('Test Title', 7),
'title' => str_repeat('Test Title', 7),
]));
\$this->assertSessionHasErrors('name');
\$this->assertSessionHasErrors('title');
}
/** @test */
@ -348,7 +348,7 @@ class Manage{$this->model_name}Test extends TestCase
private function getEditFields(array \$overrides = [])
{
return array_merge([
'name' => '{$this->model_name} 1 name',
'title' => '{$this->model_name} 1 title',
'description' => '{$this->model_name} 1 description',
], \$overrides);
}
@ -357,7 +357,7 @@ class Manage{$this->model_name}Test extends TestCase
public function user_can_edit_a_{$this->lang_name}()
{
\$this->loginAsUser();
\${$this->single_model_var_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']);
\${$this->single_model_var_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']);
\$this->visitRoute('{$this->table_name}.show', \${$this->single_model_var_name});
\$this->click('edit-{$this->lang_name}-'.\${$this->single_model_var_name}->id);
@ -373,34 +373,34 @@ class Manage{$this->model_name}Test extends TestCase
}
/** @test */
public function validate_{$this->lang_name}_name_update_is_required()
public function validate_{$this->lang_name}_title_update_is_required()
{
\$this->loginAsUser();
\${$this->lang_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']);
\${$this->lang_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']);
// name empty
\$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields(['name' => '']));
\$this->assertSessionHasErrors('name');
// title empty
\$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields(['title' => '']));
\$this->assertSessionHasErrors('title');
}
/** @test */
public function validate_{$this->lang_name}_name_update_is_not_more_than_60_characters()
public function validate_{$this->lang_name}_title_update_is_not_more_than_60_characters()
{
\$this->loginAsUser();
\${$this->lang_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']);
\${$this->lang_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']);
// name 70 characters
// title 70 characters
\$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields([
'name' => str_repeat('Test Title', 7),
'title' => str_repeat('Test Title', 7),
]));
\$this->assertSessionHasErrors('name');
\$this->assertSessionHasErrors('title');
}
/** @test */
public function validate_{$this->lang_name}_description_update_is_not_more_than_255_characters()
{
\$this->loginAsUser();
\${$this->lang_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']);
\${$this->lang_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']);
// description 256 characters
\$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields([
@ -432,7 +432,7 @@ class Manage{$this->model_name}Test extends TestCase
}
/** @test */
public function same_base_test_case_class_name_dont_use_alias()
public function same_base_test_case_class_title_dont_use_alias()
{
config(['simple-crud.base_test_path' => 'tests/TestCase.php']);
config(['simple-crud.base_test_class' => 'Tests\TestCase']);
@ -459,13 +459,13 @@ class Manage{$this->model_name}Test extends TestCase
\$this->loginAsUser();
\$this->visitRoute('{$this->table_name}.index');
\$this->see(\${$this->single_model_var_name}->name);
\$this->see(\${$this->single_model_var_name}->title);
}
private function getCreateFields(array \$overrides = [])
{
return array_merge([
'name' => '{$this->model_name} 1 name',
'title' => '{$this->model_name} 1 title',
'description' => '{$this->model_name} 1 description',
], \$overrides);
}
@ -487,25 +487,25 @@ class Manage{$this->model_name}Test extends TestCase
}
/** @test */
public function validate_{$this->lang_name}_name_is_required()
public function validate_{$this->lang_name}_title_is_required()
{
\$this->loginAsUser();
// name empty
\$this->post(route('{$this->table_name}.store'), \$this->getCreateFields(['name' => '']));
\$this->assertSessionHasErrors('name');
// title empty
\$this->post(route('{$this->table_name}.store'), \$this->getCreateFields(['title' => '']));
\$this->assertSessionHasErrors('title');
}
/** @test */
public function validate_{$this->lang_name}_name_is_not_more_than_60_characters()
public function validate_{$this->lang_name}_title_is_not_more_than_60_characters()
{
\$this->loginAsUser();
// name 70 characters
// title 70 characters
\$this->post(route('{$this->table_name}.store'), \$this->getCreateFields([
'name' => str_repeat('Test Title', 7),
'title' => str_repeat('Test Title', 7),
]));
\$this->assertSessionHasErrors('name');
\$this->assertSessionHasErrors('title');
}
/** @test */
@ -523,7 +523,7 @@ class Manage{$this->model_name}Test extends TestCase
private function getEditFields(array \$overrides = [])
{
return array_merge([
'name' => '{$this->model_name} 1 name',
'title' => '{$this->model_name} 1 title',
'description' => '{$this->model_name} 1 description',
], \$overrides);
}
@ -532,7 +532,7 @@ class Manage{$this->model_name}Test extends TestCase
public function user_can_edit_a_{$this->lang_name}()
{
\$this->loginAsUser();
\${$this->single_model_var_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']);
\${$this->single_model_var_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']);
\$this->visitRoute('{$this->table_name}.show', \${$this->single_model_var_name});
\$this->click('edit-{$this->lang_name}-'.\${$this->single_model_var_name}->id);
@ -548,34 +548,34 @@ class Manage{$this->model_name}Test extends TestCase
}
/** @test */
public function validate_{$this->lang_name}_name_update_is_required()
public function validate_{$this->lang_name}_title_update_is_required()
{
\$this->loginAsUser();
\${$this->lang_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']);
\${$this->lang_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']);
// name empty
\$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields(['name' => '']));
\$this->assertSessionHasErrors('name');
// title empty
\$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields(['title' => '']));
\$this->assertSessionHasErrors('title');
}
/** @test */
public function validate_{$this->lang_name}_name_update_is_not_more_than_60_characters()
public function validate_{$this->lang_name}_title_update_is_not_more_than_60_characters()
{
\$this->loginAsUser();
\${$this->lang_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']);
\${$this->lang_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']);
// name 70 characters
// title 70 characters
\$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields([
'name' => str_repeat('Test Title', 7),
'title' => str_repeat('Test Title', 7),
]));
\$this->assertSessionHasErrors('name');
\$this->assertSessionHasErrors('title');
}
/** @test */
public function validate_{$this->lang_name}_description_update_is_not_more_than_255_characters()
{
\$this->loginAsUser();
\${$this->lang_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']);
\${$this->lang_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']);
// description 256 characters
\$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields([

27
tests/Generators/FullControllerGeneratorTest.php

@ -26,10 +26,11 @@ class {$this->model_name}Controller extends Controller
*
* @return \Illuminate\View\View
*/
public function index()
public function index(Request \$request)
{
\${$this->single_model_var_name}Query = {$this->model_name}::query();
\${$this->single_model_var_name}Query->where('name', 'like', '%'.request('q').'%');
\${$this->single_model_var_name}Query->where('title', 'like', '%'.\$request->get('q').'%');
\${$this->single_model_var_name}Query->orderBy('title');
\${$this->collection_model_var_name} = \${$this->single_model_var_name}Query->paginate(25);
return view('{$this->table_name}.index', compact('{$this->collection_model_var_name}'));
@ -58,7 +59,7 @@ class {$this->model_name}Controller extends Controller
\$this->authorize('create', new {$this->model_name});
\$new{$this->model_name} = \$request->validate([
'name' => 'required|max:60',
'title' => 'required|max:60',
'description' => 'nullable|max:255',
]);
\$new{$this->model_name}['creator_id'] = auth()->id();
@ -104,7 +105,7 @@ class {$this->model_name}Controller extends Controller
\$this->authorize('update', \${$this->single_model_var_name});
\${$this->single_model_var_name}Data = \$request->validate([
'name' => 'required|max:60',
'title' => 'required|max:60',
'description' => 'nullable|max:255',
]);
\${$this->single_model_var_name}->update(\${$this->single_model_var_name}Data);
@ -156,10 +157,11 @@ class CategoryController extends Controller
*
* @return \Illuminate\View\View
*/
public function index()
public function index(Request \$request)
{
\$categoryQuery = Category::query();
\$categoryQuery->where('name', 'like', '%'.request('q').'%');
\$categoryQuery->where('title', 'like', '%'.\$request->get('q').'%');
\$categoryQuery->orderBy('title');
\$categories = \$categoryQuery->paginate(25);
return view('categories.index', compact('categories'));
@ -188,7 +190,7 @@ class CategoryController extends Controller
\$this->authorize('create', new Category);
\$newCategory = \$request->validate([
'name' => 'required|max:60',
'title' => 'required|max:60',
'description' => 'nullable|max:255',
]);
\$newCategory['creator_id'] = auth()->id();
@ -234,7 +236,7 @@ class CategoryController extends Controller
\$this->authorize('update', \$category);
\$categoryData = \$request->validate([
'name' => 'required|max:60',
'title' => 'required|max:60',
'description' => 'nullable|max:255',
]);
\$category->update(\$categoryData);
@ -287,10 +289,11 @@ class CategoryController extends Controller
*
* @return \Illuminate\View\View
*/
public function index()
public function index(Request \$request)
{
\$categoryQuery = Category::query();
\$categoryQuery->where('name', 'like', '%'.request('q').'%');
\$categoryQuery->where('title', 'like', '%'.\$request->get('q').'%');
\$categoryQuery->orderBy('title');
\$categories = \$categoryQuery->paginate(25);
return view('categories.index', compact('categories'));
@ -319,7 +322,7 @@ class CategoryController extends Controller
\$this->authorize('create', new Category);
\$newCategory = \$request->validate([
'name' => 'required|max:60',
'title' => 'required|max:60',
'description' => 'nullable|max:255',
]);
\$newCategory['creator_id'] = auth()->id();
@ -365,7 +368,7 @@ class CategoryController extends Controller
\$this->authorize('update', \$category);
\$categoryData = \$request->validate([
'name' => 'required|max:60',
'title' => 'required|max:60',
'description' => 'nullable|max:255',
]);
\$category->update(\$categoryData);

50
tests/Generators/LangGeneratorTest.php

@ -2,8 +2,8 @@
namespace Tests\Generators;
use Tests\TestCase;
use Illuminate\Support\Str;
use Tests\TestCase;
class LangGeneratorTest extends TestCase
{
@ -20,17 +20,17 @@ class LangGeneratorTest extends TestCase
return [
// Labels
'{$this->lang_name}' => '{$displayModelName}',
'list' => '{$displayModelName} List',
'search' => 'Search {$displayModelName}',
'search_text' => 'Name ...',
'all' => 'All {$displayModelName}',
'select' => 'Select {$displayModelName}',
'detail' => '{$displayModelName} Detail',
'not_found' => '{$displayModelName} not found.',
'empty' => '{$displayModelName} is empty.',
'back_to_show' => 'Back to {$displayModelName} Detail',
'back_to_index' => 'Back to {$displayModelName} List',
'{$this->lang_name}' => '{$displayModelName}',
'list' => '{$displayModelName} List',
'search' => 'Search {$displayModelName}',
'search_text' => 'Title ...',
'all' => 'All {$displayModelName}',
'select' => 'Select {$displayModelName}',
'detail' => '{$displayModelName} Detail',
'not_found' => '{$displayModelName} not found.',
'empty' => '{$displayModelName} is empty.',
'back_to_show' => 'Back to {$displayModelName} Detail',
'back_to_index' => 'Back to {$displayModelName} List',
// Actions
'create' => 'Create new {$displayModelName}',
@ -46,7 +46,7 @@ return [
'undeleteable' => '{$displayModelName} data cannot be deleted.',
// Attributes
'name' => '{$displayModelName} Name',
'title' => '{$displayModelName} Title',
'description' => '{$displayModelName} Description',
];
";
@ -67,17 +67,17 @@ return [
return [
// Labels
'{$this->lang_name}' => '{$displayModelName}',
'list' => 'Daftar {$displayModelName}',
'search' => 'Cari {$displayModelName}',
'search_text' => 'Nama ...',
'all' => 'Semua {$displayModelName}',
'select' => 'Pilih {$displayModelName}',
'detail' => 'Detail {$displayModelName}',
'not_found' => '{$displayModelName} tidak ditemukan',
'empty' => 'Belum ada {$displayModelName}',
'back_to_show' => 'Kembali ke detail {$displayModelName}',
'back_to_index' => 'Kembali ke daftar {$displayModelName}',
'{$this->lang_name}' => '{$displayModelName}',
'list' => 'Daftar {$displayModelName}',
'search' => 'Cari {$displayModelName}',
'search_text' => 'Judul ...',
'all' => 'Semua {$displayModelName}',
'select' => 'Pilih {$displayModelName}',
'detail' => 'Detail {$displayModelName}',
'not_found' => '{$displayModelName} tidak ditemukan',
'empty' => 'Belum ada {$displayModelName}',
'back_to_show' => 'Kembali ke detail {$displayModelName}',
'back_to_index' => 'Kembali ke daftar {$displayModelName}',
// Actions
'create' => 'Input {$displayModelName} Baru',
@ -93,7 +93,7 @@ return [
'undeleteable' => 'Data {$displayModelName} tidak dapat dihapus.',
// Attributes
'name' => 'Nama {$displayModelName}',
'title' => 'Judul {$displayModelName}',
'description' => 'Deskripsi {$displayModelName}',
];
";

6
tests/Generators/MigrationGeneratorTest.php

@ -30,12 +30,10 @@ class Create{$this->plural_model_name}Table extends Migration
{
Schema::create('{$this->table_name}', function (Blueprint \$table) {
\$table->bigIncrements('id');
\$table->string('name', 60);
\$table->string('title', 60);
\$table->string('description')->nullable();
\$table->unsignedBigInteger('creator_id');
\$table->foreignId('creator_id')->constrained('users')->onDelete('restrict');
\$table->timestamps();
\$table->foreign('creator_id')->references('id')->on('users')->onDelete('restrict');
});
}

2
tests/Generators/ModelFactoryGeneratorTest.php

@ -28,7 +28,7 @@ class {$this->model_name}Factory extends Factory
public function definition()
{
return [
'name' => \$this->faker->word,
'title' => \$this->faker->word,
'description' => \$this->faker->sentence,
'creator_id' => function () {
return User::factory()->create()->id;

16
tests/Generators/ModelGeneratorTest.php

@ -26,16 +26,16 @@ class {$this->model_name} extends Model
{
use HasFactory;
protected \$fillable = ['name', 'description', 'creator_id'];
protected \$fillable = ['title', 'description', 'creator_id'];
public function getNameLinkAttribute()
public function getTitleLinkAttribute()
{
\$title = __('app.show_detail_title', [
'name' => \$this->name, 'type' => __('{$this->lang_name}.{$this->lang_name}'),
'title' => \$this->title, 'type' => __('{$this->lang_name}.{$this->lang_name}'),
]);
\$link = '<a href=\"'.route('{$this->table_name}.show', \$this).'\"';
\$link .= ' title=\"'.\$title.'\">';
\$link .= \$this->name;
\$link .= \$this->title;
\$link .= '</a>';
return \$link;
@ -70,16 +70,16 @@ class Category extends Model
{
use HasFactory;
protected \$fillable = ['name', 'description', 'creator_id'];
protected \$fillable = ['title', 'description', 'creator_id'];
public function getNameLinkAttribute()
public function getTitleLinkAttribute()
{
\$title = __('app.show_detail_title', [
'name' => \$this->name, 'type' => __('category.category'),
'title' => \$this->title, 'type' => __('category.category'),
]);
\$link = '<a href=\"'.route('categories.show', \$this).'\"';
\$link .= ' title=\"'.\$title.'\">';
\$link .= \$this->name;
\$link .= \$this->title;
\$link .= '</a>';
return \$link;

2
tests/Generators/ModelPolicyTestGeneratorTest.php

@ -124,7 +124,7 @@ class {$this->model_name}PolicyTest extends TestCase
}
/** @test */
public function same_base_test_case_class_name_dont_use_alias()
public function same_base_test_case_class_title_dont_use_alias()
{
config(['simple-crud.base_test_path' => 'tests/TestCase.php']);
config(['simple-crud.base_test_class' => 'Tests\TestCase']);

26
tests/Generators/ModelTestGeneratorTest.php

@ -28,19 +28,19 @@ class {$this->model_name}Test extends TestCase
use RefreshDatabase;
/** @test */
public function a_{$this->lang_name}_has_name_link_attribute()
public function a_{$this->lang_name}_has_title_link_attribute()
{
\${$this->single_model_var_name} = {$this->model_name}::factory()->create();
\$title = __('app.show_detail_title', [
'name' => \${$this->single_model_var_name}->name, 'type' => __('{$this->lang_name}.{$this->lang_name}'),
'title' => \${$this->single_model_var_name}->title, 'type' => __('{$this->lang_name}.{$this->lang_name}'),
]);
\$link = '<a href=\"'.route('{$this->table_name}.show', \${$this->single_model_var_name}).'\"';
\$link .= ' title=\"'.\$title.'\">';
\$link .= \${$this->single_model_var_name}->name;
\$link .= \${$this->single_model_var_name}->title;
\$link .= '</a>';
\$this->assertEquals(\$link, \${$this->single_model_var_name}->name_link);
\$this->assertEquals(\$link, \${$this->single_model_var_name}->title_link);
}
/** @test */
@ -81,19 +81,19 @@ class {$this->model_name}Test extends TestCase
use RefreshDatabase;
/** @test */
public function a_{$this->lang_name}_has_name_link_attribute()
public function a_{$this->lang_name}_has_title_link_attribute()
{
\${$this->single_model_var_name} = {$this->model_name}::factory()->create();
\$title = __('app.show_detail_title', [
'name' => \${$this->single_model_var_name}->name, 'type' => __('{$this->lang_name}.{$this->lang_name}'),
'title' => \${$this->single_model_var_name}->title, 'type' => __('{$this->lang_name}.{$this->lang_name}'),
]);
\$link = '<a href=\"'.route('{$this->table_name}.show', \${$this->single_model_var_name}).'\"';
\$link .= ' title=\"'.\$title.'\">';
\$link .= \${$this->single_model_var_name}->name;
\$link .= \${$this->single_model_var_name}->title;
\$link .= '</a>';
\$this->assertEquals(\$link, \${$this->single_model_var_name}->name_link);
\$this->assertEquals(\$link, \${$this->single_model_var_name}->title_link);
}
/** @test */
@ -110,7 +110,7 @@ class {$this->model_name}Test extends TestCase
}
/** @test */
public function same_base_test_case_class_name_dont_use_alias()
public function same_base_test_case_class_title_dont_use_alias()
{
config(['auth.providers.users.model' => 'App\Models\User']);
config(['simple-crud.base_test_path' => 'tests/TestCase.php']);
@ -134,19 +134,19 @@ class {$this->model_name}Test extends TestCase
use RefreshDatabase;
/** @test */
public function a_{$this->lang_name}_has_name_link_attribute()
public function a_{$this->lang_name}_has_title_link_attribute()
{
\${$this->single_model_var_name} = {$this->model_name}::factory()->create();
\$title = __('app.show_detail_title', [
'name' => \${$this->single_model_var_name}->name, 'type' => __('{$this->lang_name}.{$this->lang_name}'),
'title' => \${$this->single_model_var_name}->title, 'type' => __('{$this->lang_name}.{$this->lang_name}'),
]);
\$link = '<a href=\"'.route('{$this->table_name}.show', \${$this->single_model_var_name}).'\"';
\$link .= ' title=\"'.\$title.'\">';
\$link .= \${$this->single_model_var_name}->name;
\$link .= \${$this->single_model_var_name}->title;
\$link .= '</a>';
\$this->assertEquals(\$link, \${$this->single_model_var_name}->name_link);
\$this->assertEquals(\$link, \${$this->single_model_var_name}->title_link);
}
/** @test */

108
tests/Generators/Simple/FeatureTestGeneratorTest.php

@ -67,7 +67,7 @@ class Manage{$this->model_name}Test extends TestCase
\$this->loginAsUser();
\$this->visitRoute('{$this->table_name}.index');
\$this->see(\${$this->single_model_var_name}->name);
\$this->see(\${$this->single_model_var_name}->title);
}
/** @test */
@ -80,14 +80,14 @@ class Manage{$this->model_name}Test extends TestCase
\$this->seeRouteIs('{$this->table_name}.index', ['action' => 'create']);
\$this->submitForm(__('{$this->lang_name}.create'), [
'name' => '{$this->model_name} 1 name',
'title' => '{$this->model_name} 1 title',
'description' => '{$this->model_name} 1 description',
]);
\$this->seeRouteIs('{$this->table_name}.index');
\$this->seeInDatabase('{$this->table_name}', [
'name' => '{$this->model_name} 1 name',
'title' => '{$this->model_name} 1 title',
'description' => '{$this->model_name} 1 description',
]);
}
@ -95,31 +95,31 @@ class Manage{$this->model_name}Test extends TestCase
private function getCreateFields(array \$overrides = [])
{
return array_merge([
'name' => '{$this->model_name} 1 name',
'title' => '{$this->model_name} 1 title',
'description' => '{$this->model_name} 1 description',
], \$overrides);
}
/** @test */
public function validate_{$this->lang_name}_name_is_required()
public function validate_{$this->lang_name}_title_is_required()
{
\$this->loginAsUser();
// name empty
\$this->post(route('{$this->table_name}.store'), \$this->getCreateFields(['name' => '']));
\$this->assertSessionHasErrors('name');
// title empty
\$this->post(route('{$this->table_name}.store'), \$this->getCreateFields(['title' => '']));
\$this->assertSessionHasErrors('title');
}
/** @test */
public function validate_{$this->lang_name}_name_is_not_more_than_60_characters()
public function validate_{$this->lang_name}_title_is_not_more_than_60_characters()
{
\$this->loginAsUser();
// name 70 characters
// title 70 characters
\$this->post(route('{$this->table_name}.store'), \$this->getCreateFields([
'name' => str_repeat('Test Title', 7),
'title' => str_repeat('Test Title', 7),
]));
\$this->assertSessionHasErrors('name');
\$this->assertSessionHasErrors('title');
}
/** @test */
@ -138,21 +138,21 @@ class Manage{$this->model_name}Test extends TestCase
public function user_can_edit_a_{$this->lang_name}_within_search_query()
{
\$this->loginAsUser();
\${$this->single_model_var_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']);
\${$this->single_model_var_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']);
\$this->visitRoute('{$this->table_name}.index', ['q' => '123']);
\$this->click('edit-{$this->lang_name}-'.\${$this->single_model_var_name}->id);
\$this->seeRouteIs('{$this->table_name}.index', ['action' => 'edit', 'id' => \${$this->single_model_var_name}->id, 'q' => '123']);
\$this->submitForm(__('{$this->lang_name}.update'), [
'name' => '{$this->model_name} 1 name',
'title' => '{$this->model_name} 1 title',
'description' => '{$this->model_name} 1 description',
]);
\$this->seeRouteIs('{$this->table_name}.index', ['q' => '123']);
\$this->seeInDatabase('{$this->table_name}', [
'name' => '{$this->model_name} 1 name',
'title' => '{$this->model_name} 1 title',
'description' => '{$this->model_name} 1 description',
]);
}
@ -160,40 +160,40 @@ class Manage{$this->model_name}Test extends TestCase
private function getEditFields(array \$overrides = [])
{
return array_merge([
'name' => '{$this->model_name} 1 name',
'title' => '{$this->model_name} 1 title',
'description' => '{$this->model_name} 1 description',
], \$overrides);
}
/** @test */
public function validate_{$this->lang_name}_name_update_is_required()
public function validate_{$this->lang_name}_title_update_is_required()
{
\$this->loginAsUser();
\${$this->lang_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']);
\${$this->lang_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']);
// name empty
\$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields(['name' => '']));
\$this->assertSessionHasErrors('name');
// title empty
\$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields(['title' => '']));
\$this->assertSessionHasErrors('title');
}
/** @test */
public function validate_{$this->lang_name}_name_update_is_not_more_than_60_characters()
public function validate_{$this->lang_name}_title_update_is_not_more_than_60_characters()
{
\$this->loginAsUser();
\${$this->lang_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']);
\${$this->lang_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']);
// name 70 characters
// title 70 characters
\$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields([
'name' => str_repeat('Test Title', 7),
'title' => str_repeat('Test Title', 7),
]));
\$this->assertSessionHasErrors('name');
\$this->assertSessionHasErrors('title');
}
/** @test */
public function validate_{$this->lang_name}_description_update_is_not_more_than_255_characters()
{
\$this->loginAsUser();
\${$this->lang_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']);
\${$this->lang_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']);
// description 256 characters
\$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields([
@ -298,7 +298,7 @@ class Manage{$this->model_name}Test extends TestCase
\$this->loginAsUser();
\$this->visitRoute('{$this->table_name}.index');
\$this->see(\${$this->single_model_var_name}->name);
\$this->see(\${$this->single_model_var_name}->title);
}
/** @test */
@ -311,14 +311,14 @@ class Manage{$this->model_name}Test extends TestCase
\$this->seeRouteIs('{$this->table_name}.index', ['action' => 'create']);
\$this->submitForm(__('{$this->lang_name}.create'), [
'name' => '{$this->model_name} 1 name',
'title' => '{$this->model_name} 1 title',
'description' => '{$this->model_name} 1 description',
]);
\$this->seeRouteIs('{$this->table_name}.index');
\$this->seeInDatabase('{$this->table_name}', [
'name' => '{$this->model_name} 1 name',
'title' => '{$this->model_name} 1 title',
'description' => '{$this->model_name} 1 description',
]);
}
@ -326,31 +326,31 @@ class Manage{$this->model_name}Test extends TestCase
private function getCreateFields(array \$overrides = [])
{
return array_merge([
'name' => '{$this->model_name} 1 name',
'title' => '{$this->model_name} 1 title',
'description' => '{$this->model_name} 1 description',
], \$overrides);
}
/** @test */
public function validate_{$this->lang_name}_name_is_required()
public function validate_{$this->lang_name}_title_is_required()
{
\$this->loginAsUser();
// name empty
\$this->post(route('{$this->table_name}.store'), \$this->getCreateFields(['name' => '']));
\$this->assertSessionHasErrors('name');
// title empty
\$this->post(route('{$this->table_name}.store'), \$this->getCreateFields(['title' => '']));
\$this->assertSessionHasErrors('title');
}
/** @test */
public function validate_{$this->lang_name}_name_is_not_more_than_60_characters()
public function validate_{$this->lang_name}_title_is_not_more_than_60_characters()
{
\$this->loginAsUser();
// name 70 characters
// title 70 characters
\$this->post(route('{$this->table_name}.store'), \$this->getCreateFields([
'name' => str_repeat('Test Title', 7),
'title' => str_repeat('Test Title', 7),
]));
\$this->assertSessionHasErrors('name');
\$this->assertSessionHasErrors('title');
}
/** @test */
@ -369,21 +369,21 @@ class Manage{$this->model_name}Test extends TestCase
public function user_can_edit_a_{$this->lang_name}_within_search_query()
{
\$this->loginAsUser();
\${$this->single_model_var_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']);
\${$this->single_model_var_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']);
\$this->visitRoute('{$this->table_name}.index', ['q' => '123']);
\$this->click('edit-{$this->lang_name}-'.\${$this->single_model_var_name}->id);
\$this->seeRouteIs('{$this->table_name}.index', ['action' => 'edit', 'id' => \${$this->single_model_var_name}->id, 'q' => '123']);
\$this->submitForm(__('{$this->lang_name}.update'), [
'name' => '{$this->model_name} 1 name',
'title' => '{$this->model_name} 1 title',
'description' => '{$this->model_name} 1 description',
]);
\$this->seeRouteIs('{$this->table_name}.index', ['q' => '123']);
\$this->seeInDatabase('{$this->table_name}', [
'name' => '{$this->model_name} 1 name',
'title' => '{$this->model_name} 1 title',
'description' => '{$this->model_name} 1 description',
]);
}
@ -391,40 +391,40 @@ class Manage{$this->model_name}Test extends TestCase
private function getEditFields(array \$overrides = [])
{
return array_merge([
'name' => '{$this->model_name} 1 name',
'title' => '{$this->model_name} 1 title',
'description' => '{$this->model_name} 1 description',
], \$overrides);
}
/** @test */
public function validate_{$this->lang_name}_name_update_is_required()
public function validate_{$this->lang_name}_title_update_is_required()
{
\$this->loginAsUser();
\${$this->lang_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']);
\${$this->lang_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']);
// name empty
\$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields(['name' => '']));
\$this->assertSessionHasErrors('name');
// title empty
\$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields(['title' => '']));
\$this->assertSessionHasErrors('title');
}
/** @test */
public function validate_{$this->lang_name}_name_update_is_not_more_than_60_characters()
public function validate_{$this->lang_name}_title_update_is_not_more_than_60_characters()
{
\$this->loginAsUser();
\${$this->lang_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']);
\${$this->lang_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']);
// name 70 characters
// title 70 characters
\$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields([
'name' => str_repeat('Test Title', 7),
'title' => str_repeat('Test Title', 7),
]));
\$this->assertSessionHasErrors('name');
\$this->assertSessionHasErrors('title');
}
/** @test */
public function validate_{$this->lang_name}_description_update_is_not_more_than_255_characters()
{
\$this->loginAsUser();
\${$this->lang_name} = {$this->model_name}::factory()->create(['name' => 'Testing 123']);
\${$this->lang_name} = {$this->model_name}::factory()->create(['title' => 'Testing 123']);
// description 256 characters
\$this->patch(route('{$this->table_name}.update', \${$this->lang_name}), \$this->getEditFields([

27
tests/Generators/Simple/SimpleControllerGeneratorTest.php

@ -26,11 +26,12 @@ class {$this->model_name}Controller extends Controller
*
* @return \Illuminate\View\View
*/
public function index()
public function index(Request \$request)
{
\$editable{$this->model_name} = null;
\${$this->single_model_var_name}Query = {$this->model_name}::query();
\${$this->single_model_var_name}Query->where('name', 'like', '%'.request('q').'%');
\${$this->single_model_var_name}Query->where('title', 'like', '%'.\$request->get('q').'%');
\${$this->single_model_var_name}Query->orderBy('title');
\${$this->collection_model_var_name} = \${$this->single_model_var_name}Query->paginate(25);
if (in_array(request('action'), ['edit', 'delete']) && request('id') != null) {
@ -51,7 +52,7 @@ class {$this->model_name}Controller extends Controller
\$this->authorize('create', new {$this->model_name});
\$new{$this->model_name} = \$request->validate([
'name' => 'required|max:60',
'title' => 'required|max:60',
'description' => 'nullable|max:255',
]);
\$new{$this->model_name}['creator_id'] = auth()->id();
@ -73,7 +74,7 @@ class {$this->model_name}Controller extends Controller
\$this->authorize('update', \${$this->single_model_var_name});
\${$this->single_model_var_name}Data = \$request->validate([
'name' => 'required|max:60',
'title' => 'required|max:60',
'description' => 'nullable|max:255',
]);
\${$this->single_model_var_name}->update(\${$this->single_model_var_name}Data);
@ -129,11 +130,12 @@ class CategoryController extends Controller
*
* @return \Illuminate\View\View
*/
public function index()
public function index(Request \$request)
{
\$editableCategory = null;
\$categoryQuery = Category::query();
\$categoryQuery->where('name', 'like', '%'.request('q').'%');
\$categoryQuery->where('title', 'like', '%'.\$request->get('q').'%');
\$categoryQuery->orderBy('title');
\$categories = \$categoryQuery->paginate(25);
if (in_array(request('action'), ['edit', 'delete']) && request('id') != null) {
@ -154,7 +156,7 @@ class CategoryController extends Controller
\$this->authorize('create', new Category);
\$newCategory = \$request->validate([
'name' => 'required|max:60',
'title' => 'required|max:60',
'description' => 'nullable|max:255',
]);
\$newCategory['creator_id'] = auth()->id();
@ -176,7 +178,7 @@ class CategoryController extends Controller
\$this->authorize('update', \$category);
\$categoryData = \$request->validate([
'name' => 'required|max:60',
'title' => 'required|max:60',
'description' => 'nullable|max:255',
]);
\$category->update(\$categoryData);
@ -233,11 +235,12 @@ class CategoryController extends Controller
*
* @return \Illuminate\View\View
*/
public function index()
public function index(Request \$request)
{
\$editableCategory = null;
\$categoryQuery = Category::query();
\$categoryQuery->where('name', 'like', '%'.request('q').'%');
\$categoryQuery->where('title', 'like', '%'.\$request->get('q').'%');
\$categoryQuery->orderBy('title');
\$categories = \$categoryQuery->paginate(25);
if (in_array(request('action'), ['edit', 'delete']) && request('id') != null) {
@ -258,7 +261,7 @@ class CategoryController extends Controller
\$this->authorize('create', new Category);
\$newCategory = \$request->validate([
'name' => 'required|max:60',
'title' => 'required|max:60',
'description' => 'nullable|max:255',
]);
\$newCategory['creator_id'] = auth()->id();
@ -280,7 +283,7 @@ class CategoryController extends Controller
\$this->authorize('update', \$category);
\$categoryData = \$request->validate([
'name' => 'required|max:60',
'title' => 'required|max:60',
'description' => 'nullable|max:255',
]);
\$category->update(\$categoryData);

22
tests/Generators/Simple/ViewsGeneratorTest.php

@ -2,8 +2,8 @@
namespace Tests\Generators\Simple;
use Tests\TestCase;
use Illuminate\Contracts\Console\Kernel;
use Tests\TestCase;
class ViewsGeneratorTest extends TestCase
{
@ -45,7 +45,7 @@ class ViewsGeneratorTest extends TestCase
<thead>
<tr>
<th class=\"text-center\">{{ __('app.table_no') }}</th>
<th>{{ __('{$this->lang_name}.name') }}</th>
<th>{{ __('{$this->lang_name}.title') }}</th>
<th>{{ __('{$this->lang_name}.description') }}</th>
<th class=\"text-center\">{{ __('app.action') }}</th>
</tr>
@ -54,7 +54,7 @@ class ViewsGeneratorTest extends TestCase
@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}->title }}</td>
<td>{{ \${$this->single_model_var_name}->description }}</td>
<td class=\"text-center\">
@can('update', \${$this->single_model_var_name})
@ -91,9 +91,9 @@ class ViewsGeneratorTest extends TestCase
<form method=\"POST\" action=\"{{ route('{$this->table_name}.store') }}\" accept-charset=\"UTF-8\">
{{ csrf_field() }}
<div class=\"form-group\">
<label for=\"name\" class=\"form-label\">{{ __('{$this->lang_name}.name') }} <span class=\"form-required\">*</span></label>
<input id=\"name\" type=\"text\" class=\"form-control{{ \$errors->has('name') ? ' is-invalid' : '' }}\" name=\"name\" value=\"{{ old('name') }}\" required>
{!! \$errors->first('name', '<span class=\"invalid-feedback\" role=\"alert\">:message</span>') !!}
<label for=\"title\" class=\"form-label\">{{ __('{$this->lang_name}.title') }} <span class=\"form-required\">*</span></label>
<input id=\"title\" type=\"text\" class=\"form-control{{ \$errors->has('title') ? ' is-invalid' : '' }}\" name=\"title\" value=\"{{ old('title') }}\" required>
{!! \$errors->first('title', '<span class=\"invalid-feedback\" role=\"alert\">:message</span>') !!}
</div>
<div class=\"form-group\">
<label for=\"description\" class=\"form-label\">{{ __('{$this->lang_name}.description') }}</label>
@ -110,9 +110,9 @@ class ViewsGeneratorTest extends TestCase
<form method=\"POST\" action=\"{{ route('{$this->table_name}.update', \$editable{$this->model_name}) }}\" accept-charset=\"UTF-8\">
{{ csrf_field() }} {{ method_field('patch') }}
<div class=\"form-group\">
<label for=\"name\" class=\"form-label\">{{ __('{$this->lang_name}.name') }} <span class=\"form-required\">*</span></label>
<input id=\"name\" type=\"text\" class=\"form-control{{ \$errors->has('name') ? ' is-invalid' : '' }}\" name=\"name\" value=\"{{ old('name', \$editable{$this->model_name}->name) }}\" required>
{!! \$errors->first('name', '<span class=\"invalid-feedback\" role=\"alert\">:message</span>') !!}
<label for=\"title\" class=\"form-label\">{{ __('{$this->lang_name}.title') }} <span class=\"form-required\">*</span></label>
<input id=\"title\" type=\"text\" class=\"form-control{{ \$errors->has('title') ? ' is-invalid' : '' }}\" name=\"title\" value=\"{{ old('title', \$editable{$this->model_name}->title) }}\" required>
{!! \$errors->first('title', '<span class=\"invalid-feedback\" role=\"alert\">:message</span>') !!}
</div>
<div class=\"form-group\">
<label for=\"description\" class=\"form-label\">{{ __('{$this->lang_name}.description') }}</label>
@ -134,8 +134,8 @@ class ViewsGeneratorTest extends TestCase
<div class=\"card\">
<div class=\"card-header\">{{ __('{$this->lang_name}.delete') }}</div>
<div class=\"card-body\">
<label class=\"form-label text-primary\">{{ __('{$this->lang_name}.name') }}</label>
<p>{{ \$editable{$this->model_name}->name }}</p>
<label class=\"form-label text-primary\">{{ __('{$this->lang_name}.title') }}</label>
<p>{{ \$editable{$this->model_name}->title }}</p>
<label class=\"form-label text-primary\">{{ __('{$this->lang_name}.description') }}</label>
<p>{{ \$editable{$this->model_name}->description }}</p>
{!! \$errors->first('{$this->lang_name}_id', '<span class=\"invalid-feedback\" role=\"alert\">:message</span>') !!}

24
tests/Generators/ViewsGeneratorTest.php

@ -2,8 +2,8 @@
namespace Tests\Generators;
use Tests\TestCase;
use Illuminate\Contracts\Console\Kernel;
use Tests\TestCase;
class ViewsGeneratorTest extends TestCase
{
@ -45,7 +45,7 @@ class ViewsGeneratorTest extends TestCase
<thead>
<tr>
<th class=\"text-center\">{{ __('app.table_no') }}</th>
<th>{{ __('{$this->lang_name}.name') }}</th>
<th>{{ __('{$this->lang_name}.title') }}</th>
<th>{{ __('{$this->lang_name}.description') }}</th>
<th class=\"text-center\">{{ __('app.action') }}</th>
</tr>
@ -54,7 +54,7 @@ class ViewsGeneratorTest extends TestCase
@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}->title_link !!}</td>
<td>{{ \${$this->single_model_var_name}->description }}</td>
<td class=\"text-center\">
@can('view', \${$this->single_model_var_name})
@ -93,7 +93,7 @@ class ViewsGeneratorTest extends TestCase
<div class=\"card-body\">
<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}.title') }}</td><td>{{ \${$this->single_model_var_name}->title }}</td></tr>
<tr><td>{{ __('{$this->lang_name}.description') }}</td><td>{{ \${$this->single_model_var_name}->description }}</td></tr>
</tbody>
</table>
@ -132,9 +132,9 @@ class ViewsGeneratorTest extends TestCase
{{ csrf_field() }}
<div class=\"card-body\">
<div class=\"form-group\">
<label for=\"name\" class=\"form-label\">{{ __('{$this->lang_name}.name') }} <span class=\"form-required\">*</span></label>
<input id=\"name\" type=\"text\" class=\"form-control{{ \$errors->has('name') ? ' is-invalid' : '' }}\" name=\"name\" value=\"{{ old('name') }}\" required>
{!! \$errors->first('name', '<span class=\"invalid-feedback\" role=\"alert\">:message</span>') !!}
<label for=\"title\" class=\"form-label\">{{ __('{$this->lang_name}.title') }} <span class=\"form-required\">*</span></label>
<input id=\"title\" type=\"text\" class=\"form-control{{ \$errors->has('title') ? ' is-invalid' : '' }}\" name=\"title\" value=\"{{ old('title') }}\" required>
{!! \$errors->first('title', '<span class=\"invalid-feedback\" role=\"alert\">:message</span>') !!}
</div>
<div class=\"form-group\">
<label for=\"description\" class=\"form-label\">{{ __('{$this->lang_name}.description') }}</label>
@ -174,8 +174,8 @@ class ViewsGeneratorTest extends TestCase
<div class=\"card\">
<div class=\"card-header\">{{ __('{$this->lang_name}.delete') }}</div>
<div class=\"card-body\">
<label class=\"form-label text-primary\">{{ __('{$this->lang_name}.name') }}</label>
<p>{{ \${$this->single_model_var_name}->name }}</p>
<label class=\"form-label text-primary\">{{ __('{$this->lang_name}.title') }}</label>
<p>{{ \${$this->single_model_var_name}->title }}</p>
<label class=\"form-label text-primary\">{{ __('{$this->lang_name}.description') }}</label>
<p>{{ \${$this->single_model_var_name}->description }}</p>
{!! \$errors->first('{$this->lang_name}_id', '<span class=\"invalid-feedback\" role=\"alert\">:message</span>') !!}
@ -199,9 +199,9 @@ class ViewsGeneratorTest extends TestCase
{{ csrf_field() }} {{ method_field('patch') }}
<div class=\"card-body\">
<div class=\"form-group\">
<label for=\"name\" class=\"form-label\">{{ __('{$this->lang_name}.name') }} <span class=\"form-required\">*</span></label>
<input id=\"name\" type=\"text\" class=\"form-control{{ \$errors->has('name') ? ' is-invalid' : '' }}\" name=\"name\" value=\"{{ old('name', \${$this->single_model_var_name}->name) }}\" required>
{!! \$errors->first('name', '<span class=\"invalid-feedback\" role=\"alert\">:message</span>') !!}
<label for=\"title\" class=\"form-label\">{{ __('{$this->lang_name}.title') }} <span class=\"form-required\">*</span></label>
<input id=\"title\" type=\"text\" class=\"form-control{{ \$errors->has('title') ? ' is-invalid' : '' }}\" name=\"title\" value=\"{{ old('title', \${$this->single_model_var_name}->title) }}\" required>
{!! \$errors->first('title', '<span class=\"invalid-feedback\" role=\"alert\">:message</span>') !!}
</div>
<div class=\"form-group\">
<label for=\"description\" class=\"form-label\">{{ __('{$this->lang_name}.description') }}</label>

Loading…
Cancel
Save