Skip to content

4.4.0 - Add --parent-model Command Option

Latest

Choose a tag to compare

@nafiesl nafiesl released this 22 Mar 13:31
97ad278

Description

We are adding a new --parent-model option to create a CRUD feature nested with existing model.

Why I Need This?

I often creating a CRUD feature nested with the existing model, like:

  • Adding payment history entries for an invoice
  • Adding work orders under a project
  • Adding attachments under document
  • Many more

Since this package was (only) for creating the "first-class citizen" CRUD feature, I always create the nested CRUD feature manually (off course using TDD approach).

I hope this command new --parent-model option can save my time more.

Example

When 1 department has many section, then we are adding a nested controller like so:

Route::resource('departments.sections', Departements\SectionController::class);

So we will have routes like:

GET departments/{department}/sections
GET departments/{department}/sections/{section}
GET departments/{department}/sections/create
POST departments/{department}/sections
GET departments/{department}/sections/{section}
GET departments/{department}/sections/{section}/edit
PATCH departments/{department}/sections/{section}
DELETE departments/{department}/sections/{section}

Including the model, controller, views, feature test, unit tests.

When we run:

php artisan make:crud --parent-model=Department Section

We will have a working Section CRUD feature with title and description attribute under Departments namespace, completed with tests.