DEV Community

Cover image for Boost Your Workflow: Generate Laravel 12 CRUD in Seconds
Sunny Siddiqui
Sunny Siddiqui

Posted on

Boost Your Workflow: Generate Laravel 12 CRUD in Seconds

Okay, let's be honest.

If you've built even one Laravel project, you've done this:
Create model → migration → controller → form request → add routes
…every. single. time.

It's boring, right? And kinda repetitive.
Well, good news - here's a quick Laravel 12 tip to save your time (and sanity):

Let's make an Artisan command that generates all the basic CRUD stuff for you in one go.

What This Command Does

You give it a name like:

php artisan make:crud Product
Enter fullscreen mode Exit fullscreen mode

And it'll auto-generate:
• A Model
• A Migration
• A Controller (resource-style)
• A Form Request
• And even add the route for you

No more copy-paste or switching between 5 terminal commands. One and done.

Step 1: Make the Command

Run this:

php artisan make:command GenerateCrud
Enter fullscreen mode Exit fullscreen mode

Step 2: Add the Logic

Open up app/Console/Commands/GenerateCrud.php and drop this in:

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;

class GenerateCrud extends Command
{
    protected $signature = 'make:crud {name}';
    protected $description = 'Quickly generate CRUD files';

    public function handle(): void
    {
        $name = Str::studly($this->argument('name'));
        $table = Str::snake(Str::plural($name));
        $controller = "{$name}Controller";
        $request = "{$name}Request";

        // Create model + migration
        $this->call('make:model', ['name' => $name, '--migration' => true]);

        // Controller (resource style)
        $this->call('make:controller', [
            'name' => $controller,
            '--resource' => true,
            '--model' => $name,
        ]);

        // Form request
        $this->call('make:request', ['name' => $request]);

        // Route
        $route = "Route::resource('" . Str::kebab(Str::plural($name)) . "', \\App\\Http\\Controllers\\$controller::class);";
        File::append(base_path('routes/web.php'), "\n" . $route);

        $this->info("All done! CRUD for {$name} created.");
    }
}
Enter fullscreen mode Exit fullscreen mode

Step 3: Register It

In app/Console/Kernel.php, register the command:

protected $commands = [
    \App\Console\Commands\GenerateCrud::class,
];
Enter fullscreen mode Exit fullscreen mode

Step 4: Use It!

php artisan make:crud Blog
Enter fullscreen mode Exit fullscreen mode

Done. You've got:
• app/Models/Blog.php
• BlogController.php
• BlogRequest.php
• create_blogs_table migration
• Route in routes/web.php

Extra Sauce (Optional)

Want to take it further?

• Auto-generate Blade views too (index, create, etc.)
• Add API version ( - api)
• Include soft deletes or timestamps

Final Thoughts

Laravel 12 gives you the tools. But building a dev-friendly workflow? That's on us.

This CRUD generator command is a small thing , but it makes a big impact. It saves time, keeps your structure consistent, and lets you focus on what matters: building features, not boilerplate.
Whether you're a solo dev or part of a team, this trick adds serious value to your Laravel toolbox.


If you found this helpful, consider:

• Bookmarking this page for future projects
• Sharing it with your Laravel developer group or team
• Commenting if you want an advanced version (like generating Blade views or API-only resources)

Thanks for reading, and happy coding!


Need Help with Your Laravel Project?
If you're looking to update your existing Laravel project or develop a new one, our expert team at BrainsOfTech is here to help. Contact us today to bring your Laravel project to life with cutting-edge technology and best practices!

Top comments (0)