zerocactusSearch guides

Laravel CRUD generator or hand-written code: what it costs later

Artisan make commands, CRUD generator packages and admin panels compared on what they produce for one model and what that generated code costs you later on.

Laravel CRUD generator or hand-written code: what it costs later

A Laravel CRUD generator promises the boring part of a project in one command: model, migration, controller, validation, views and routes for a new table, all wired together before your coffee cools. I have used them on client work, regretted some of them, and kept others. The honest answer to "should I use one" is that the generation is never the expensive part. What costs money is the code you then own, and how much of it you understand when it breaks in eighteen months.

This piece looks at the three common routes in general terms: Laravel's own Artisan make commands, third-party generator packages, and admin panels that generate screens for you. Then it compares, for one Order model, what each of them leaves in your repository.

What "CRUD" really includes

Create, read, update and delete sounds like four things. On a real back-office screen it is closer to a dozen:

  • a migration and a model with relationships and casts
  • validation rules for create and for update, which are rarely identical
  • an index screen with pagination, search and sorting
  • create and edit forms with sensible inputs for dates, money and relations
  • authorisation, so not everyone can delete
  • routes, flash messages, redirects after save
  • tests, if you write them, and factories to feed the tests

A generator that covers four of those is still useful. Just be clear which four, because the remaining eight are where your time goes.

Route one: Artisan make commands

Laravel ships its own scaffolding, and it is the most conservative kind of generator. It creates files with the right names, namespaces and empty methods, and then gets out of the way. For a new model, one command does most of it:

php artisan make:model Order --all

The --all flag (short form -a) asks for a migration, a factory, a seeder and a resource controller alongside the model. Depending on your Laravel version, it also adds a policy and form request classes for store and update. Check php artisan make:model --help on your own project to see exactly which options it bundles.

The resource controller has the seven conventional methods: index, create, store, show, edit, update and destroy. All of them are empty. One line in your routes file connects them:

Route::resource('orders', OrderController::class)->middleware('auth');

What you do not get is any HTML. There are no Blade views, no table, no form. You write those yourself, or you put an admin panel in front of the model instead.

The cost later is close to zero. Every file is short, follows the framework's own conventions, and contains only the code you typed into it. A developer who joins the project already knows where everything is. This is the baseline the other routes have to beat.

Route two: generator packages

There is a long tail of community packages that go further: you describe a table, either from an existing database schema, a config file or command options, and they produce filled-in controllers, form requests with rules guessed from column types, Blade views for list and form screens, and sometimes tests. Some target plain Blade, some Livewire, some an Inertia frontend.

The appeal is obvious. In one go you have a working screen. For a prototype, an internal tool that will never get much attention, or a demo for a client, that speed is real.

The costs show up later, in a few predictable places:

  • The generated code has the package author's style, not yours. Naming, folder layout and view structure may not match the rest of the app, and every developer has to learn both.
  • Rules guessed from column types are rarely the business rules. A string(32) becomes "max 32 characters" when it should also have been "unique, uppercase, starts with ORD".
  • Once you edit a generated file, regenerating it overwrites your changes. In practice you regenerate once, at the start, and then the generator is irrelevant.
  • If the package depends on its own base classes or traits at runtime, you now have a dependency to upgrade alongside Laravel. If it is abandoned, you are maintaining its code too.

That last point is the one to check before installing anything. A generator that writes plain Laravel code and can be removed afterwards is a scaffolding tool. One whose generated code calls into the package at runtime is a framework you have adopted, whether you meant to or not.

Route three: admin panels that generate screens

Admin panels such as Filament, Nova and Backpack are not usually called CRUD generators, but for back-office screens they do the same job, with a different contract. Instead of writing controllers and views into your app, they give you a resource or controller class that describes fields and columns, and the panel renders the screens at runtime.

Some of them also have a generate step. Filament, for example, can read a table's columns and draft a resource for you:

php artisan make:filament-resource Order --generate

The result is a resource class and a few small page classes, which I walk through in the Filament resource tutorial. The panel itself owns the HTML, search, sorting, pagination and bulk actions. You own a declarative description of the screen.

The cost later is the panel's upgrade path. Major versions of admin panels change APIs, and every custom field or page you wrote moves with them. In exchange you write much less code per screen. My comparison of Laravel admin panel options goes through the main packages and their licence models.

A worked example: one Order model, four ways

To make the comparison concrete, here is what each route leaves in the repository for an Order model with a customer relationship, five fields and a list and edit screen. This is an illustrative breakdown based on how each kind of tool works, not a measurement of any specific package; generator packages in particular vary widely.

Approach Files created What is filled in Who maintains the HTML
Artisan make:model --all Model, migration, factory, seeder, controller, policy and form requests, depending on version Class shells and empty methods You, all of it
Artisan plus hand-written views As above, plus index, create, edit and show Blade views Everything, by you You
Generic generator package Model, migration, filled controller, form requests, several Blade views, often a route entry and tests Most of it, by the package You, after first edit
Admin panel with a generate step One resource class and a few page classes, plus your model and migration Field and column lists The panel

The row worth staring at is the last column. Every line of generated HTML becomes yours to maintain the moment you change it, and you will change it, because the first thing a client asks for is a different column order.

For a single model this barely matters. For twenty, it decides how the project feels to work on. Twenty generated sets of Blade views are twenty places to fix when you change the table design. Twenty panel resources share one table component.

What I actually do

My own pattern, after a few projects that went each way:

  1. Always use Artisan make commands for models, migrations, factories, policies and form requests. They are free, conventional and leave nothing behind.
  2. For back-office screens with more than a handful of models, use an admin panel and its generate step, then edit the resource by hand straight away.
  3. For customer-facing screens, write the views myself, usually with Livewire. These screens carry the design and the odd requirements, and generated views get in the way.
  4. Use a generator package only for throwaway prototypes, and say so in the repository readme.

I also write the validation rules by hand every time. They are the part of CRUD where the business lives, and a guessed rule that looks right is worse than an obvious gap.

AI assistants as generators

Coding assistants are, in effect, a new kind of CRUD generator: ask for a controller with validation and Blade views for orders and you get something plausible in seconds. The same rules apply, only more so. The output has no consistent style across requests, it can invent methods that do not exist in your Laravel version, and it has no regenerate step at all, so you own it immediately.

I find assistants most useful for the parts Artisan does not fill: drafting validation rules from a written spec, or writing feature tests for an existing controller. If you are choosing one, I compared two common options in Cursor or GitHub Copilot. Read every line they produce as if a junior colleague wrote it.

A note on the box below: it links to a partner. Buying or signing up through it can pay Zero Cactus a fee, and your price stays the same. Partners do not review or approve our guides.

Questions people ask

Is Laravel's make:model --all enough for a small project?

For the back end, often yes. It gives you the files with the right names, and you fill in the logic. You will still need views or an admin panel for anyone to use the data.

Can I remove a generator package after using it?

Only if the generated code does not depend on it at runtime. Search your app for the package's namespace after generating. If nothing references it, you can remove it.

Should generated code be committed as is?

Commit it as a separate first commit, then commit your edits on top. That way the diff shows exactly what you changed and anyone can tell generated code from deliberate code.

Do admin panels count as lock-in?

Somewhat. Your models, migrations and policies stay plain Laravel. The resource classes are panel-specific, so moving to a different panel means rewriting them, but they are short.

Before you pick a route for your next project, try this: generate one model all three ways in a scratch branch, then make the same small change to each, say adding a field and a new validation rule. Count the files you had to touch. That number tells you more about the next eighteen months than the first five minutes ever will.

Stacks: Laravel & Admin Panels

More from this stack