Vivek Mistry 👋

I’m a Certified Senior Laravel Developer with 8+ years of experience , specializing in building robust APIs and admin panels, frontend templates converting them into fully functional web applications.

Book A Call
  • 14 Feb, 2026
  • 14 Views
  • Create powerful CLI utilities inside your Laravel application for automation and maintenance.

Build Smart Internal Tools Using Laravel Artisan Console Commands

Laravel Artisan allows developers to create powerful custom console commands for automation, maintenance, and internal tools. This article explains how to build a practical real-world command that improves productivity.

Real Project Example: Bulk Deactivate Inactive Users

Imagine you want to deactivate users who haven’t logged in for 6 months.

Instead of writing temporary controller logic, create a command.


Step 1: Create Command

php artisan make:command DeactivateInactiveUsers

Step 2: Add Logic

public function handle()
{
    $count = \App\Models\User::where('last_login_at', '<', now()->subMonths(6))
        ->update(['is_active' => false]);
    $this->info("{$count} users deactivated successfully.");
}

Step 3: Run It Anytime

php artisan users:deactivate-inactive

Done.

No admin route.

No temporary code.

No UI needed.

Why This Approach Is Powerful

Using Artisan commands:

  • Keeps maintenance logic out of controllers
  • Makes automation reusable
  • Improves security (CLI-only access)
  • Works perfectly with task scheduling

You can even schedule it:

$schedule->command('users:deactivate-inactive')->daily();

Share: