diff --git a/readme.md b/readme.md
index 1411407..78232ce 100644
--- a/readme.md
+++ b/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.
@@ -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
-
-
+
+
```
diff --git a/src/stubs/controllers/api.stub b/src/stubs/controllers/api.stub
index 256d02f..7fce7b5 100644
--- a/src/stubs/controllers/api.stub
+++ b/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);
diff --git a/src/stubs/controllers/full-formrequests.stub b/src/stubs/controllers/full-formrequests.stub
index 8a2b08f..2efb58e 100644
--- a/src/stubs/controllers/full-formrequests.stub
+++ b/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'));
diff --git a/src/stubs/controllers/full.stub b/src/stubs/controllers/full.stub
index 41ca598..c108603 100644
--- a/src/stubs/controllers/full.stub
+++ b/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);
diff --git a/src/stubs/controllers/simple.stub b/src/stubs/controllers/simple.stub
index ecb92e4..f5ff38d 100644
--- a/src/stubs/controllers/simple.stub
+++ b/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);
diff --git a/src/stubs/database/factories/model-factory.stub b/src/stubs/database/factories/model-factory.stub
index c4c5caf..2032a56 100644
--- a/src/stubs/database/factories/model-factory.stub
+++ b/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;
diff --git a/src/stubs/database/migrations/migration-create.stub b/src/stubs/database/migrations/migration-create.stub
index 4d735a8..72f92e3 100755
--- a/src/stubs/database/migrations/migration-create.stub
+++ b/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');
});
}
diff --git a/src/stubs/models/model-formfield.stub b/src/stubs/models/model-formfield.stub
index f755497..b2ea9b5 100644
--- a/src/stubs/models/model-formfield.stub
+++ b/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')]
),
]);
}
diff --git a/src/stubs/models/model.stub b/src/stubs/models/model.stub
index 0c70568..e3595d6 100644
--- a/src/stubs/models/model.stub
+++ b/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 = '';
- $link .= $this->name;
+ $link .= $this->title;
$link .= '';
return $link;
diff --git a/src/stubs/requests/create-request.stub b/src/stubs/requests/create-request.stub
index 72557f6..4c8ee7b 100644
--- a/src/stubs/requests/create-request.stub
+++ b/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',
];
}
diff --git a/src/stubs/requests/update-request.stub b/src/stubs/requests/update-request.stub
index 2173556..cd932a1 100644
--- a/src/stubs/requests/update-request.stub
+++ b/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',
];
}
diff --git a/src/stubs/resources/lang/en/master.stub b/src/stubs/resources/lang/en/master.stub
index 903313a..42a15d4 100644
--- a/src/stubs/resources/lang/en/master.stub
+++ b/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',
];
diff --git a/src/stubs/resources/lang/id/master.stub b/src/stubs/resources/lang/id/master.stub
index b618830..6a60ec8 100644
--- a/src/stubs/resources/lang/id/master.stub
+++ b/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',
];
diff --git a/src/stubs/resources/views/full/create-bs3.stub b/src/stubs/resources/views/full/create-bs3.stub
index 0018b7e..f03a749 100644
--- a/src/stubs/resources/views/full/create-bs3.stub
+++ b/src/stubs/resources/views/full/create-bs3.stub
@@ -10,10 +10,10 @@