PHPackages                             larahammer/generator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. larahammer/generator

ActiveLibrary[Templating &amp; Views](/categories/templating)

larahammer/generator
====================

A powerful Laravel CRUD generator — scaffold migrations, models, controllers, views (Blade/Filament), and REST API resources from a single Artisan command.

v1.2.1(1mo ago)02↑2900%MITPHPPHP ^8.1

Since Mar 28Pushed 1mo agoCompare

[ Source](https://github.com/larahammer/generator)[ Packagist](https://packagist.org/packages/larahammer/generator)[ RSS](/packages/larahammer-generator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (6)Versions (5)Used By (0)

Larahammer Generator
====================

[](#larahammer-generator)

[![Latest Version on Packagist](https://camo.githubusercontent.com/0af3aa7a0abf483016e392b6b5cb57ed8645b9f01fd07903802d7dfc16cea09c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c61726168616d6d65722f67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/larahammer/generator)[![Total Downloads](https://camo.githubusercontent.com/abf2fbd798a432c06366c9849edeb2f4a31ed0f7ef78a65264be27d16132fc35/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c61726168616d6d65722f67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/larahammer/generator)[![License](https://camo.githubusercontent.com/17d4a3e96ccc16e720c287937ec31e860df44a9e058e646980b787c3ba93a7dc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6c61726168616d6d65722f67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

**Scaffold a complete Laravel CRUD in seconds.** One command generates migration, model, controller, form request, views, and routes — for Blade, Filament v3, or REST API.

---

Requirements
------------

[](#requirements)

PackageVersionPHP^8.1Laravel^10.0 | ^11.0 | ^12.0 | ^13.0Filament *(optional)*^3.0---

Installation
------------

[](#installation)

```
composer require larahammer/generator
```

That's it. Laravel auto-discovers the package via its Service Provider.

---

Usage
-----

[](#usage)

```
php artisan larahammer:make {ModelName} {field:type ...}
```

### Basic Example

[](#basic-example)

```
php artisan larahammer:make Product name:string price:decimal stock:integer status:enum(active,inactive)
```

You'll be prompted to choose an output target:

```
Select output target:
  [blade]    Blade + Tailwind
  [filament] Filament v3 Panel
  [api]      REST API (JSON)
  [all]      All of the above

```

### Skip the Prompt — Pass Target Directly

[](#skip-the-prompt--pass-target-directly)

```
php artisan larahammer:make Product name:string price:decimal --target=api
php artisan larahammer:make Post title:string body:text --target=filament
php artisan larahammer:make Order amount:decimal note:text:nullable --target=all
```

### Generate Everything — Use `--all` Flag

[](#generate-everything--use---all-flag)

Generate all targets and all advanced features with a single flag:

```
php artisan larahammer:make Product name:string price:decimal --all
```

This is equivalent to:

```
php artisan larahammer:make Product name:string price:decimal \
  --target=all \
  --with-roles \
  --with-admin \
  --with-landing \
  --with-security-middleware \
  --with-factories \
  --with-soft-deletes \
  --with-policies \
  --with-api-auth \
  --with-tests \
  --with-audit-log
```

**Output: 80+ production-ready files instantly!** 🚀

---

Field Types
-----------

[](#field-types)

TypeMigration ColumnNotes`string``string`Default`text``text``integer` / `int``integer``bigint``bigInteger``decimal``decimal(15,2)``boolean` / `bool``boolean``date``date``datetime``dateTime``json``json`Cast to array in model`uuid``uuid``foreignId``foreignId()->constrained()`Auto cascade`enum(a,b,c)``enum`Values in parentheses### Modifiers

[](#modifiers)

Append `:nullable` or `:unique` after the type:

```
php artisan larahammer:make User email:string:unique bio:text:nullable
```

---

What Gets Generated
-------------------

[](#what-gets-generated)

For a command like:

```
php artisan larahammer:make Post title:string body:text published:boolean --target=all
```

```
✓ Migration    → database/migrations/xxxx_create_posts_table.php
✓ Model        → app/Models/Post.php
✓ Request      → app/Http/Requests/PostRequest.php
✓ Seeder       → database/seeders/PostSeeder.php
✓ Controller   → app/Http/Controllers/PostController.php         (blade)
✓ Views        → resources/views/posts/{index,create,edit,show}  (blade)
✓ Controller   → app/Http/Controllers/Api/PostController.php     (api)
✓ Resource     → app/Http/Resources/PostResource.php             (api)
✓ Resource     → app/Filament/Resources/PostResource.php         (filament)
✓ Pages        → app/Filament/Resources/PostResource/Pages/      (filament)
✓ Routes       → injected into routes/web.php and routes/api.php

```

---

Advanced Options
----------------

[](#advanced-options)

### Generate with Role System

[](#generate-with-role-system)

Add user roles with automatic migration and seeder:

```
php artisan larahammer:make Product name:string --with-roles
```

This generates:

- `app/Models/Role.php` — Role model with relationships
- `database/migrations/xxxx_create_roles_table.php` — Roles table
- `database/seeders/RoleSeeder.php` — Seed predefined roles

**Seed roles:**

```
php artisan db:seed --class=RoleSeeder
```

Default roles created: `admin`, `editor`, `viewer`, `user`

### Generate Filament Admin Panel

[](#generate-filament-admin-panel)

Create a complete admin panel with User and Role management:

```
php artisan larahammer:make Product name:string --with-admin
```

This generates:

- `app/Filament/Resources/UserResource.php` — User management with role selection
- `app/Filament/Resources/RoleResource.php` — Role management
- All necessary Filament pages (List, Create, Edit)

**Access admin panel** at `/admin` (requires Filament v3 installed):

- User Management: `/admin/users`
- Role Management: `/admin/roles`

### Generate Landing Page

[](#generate-landing-page)

Create a ready-to-use landing page:

```
php artisan larahammer:make Product name:string --with-landing
```

This generates:

- `resources/views/landing.blade.php` — Beautiful landing page
- `app/Http/Controllers/LandingController.php` — Landing controller

**Add route to `routes/web.php`:**

```
use App\Http\Controllers\LandingController;

Route::get('/', [LandingController::class, 'index'])->name('home');
```

### Generate Security Middleware

[](#generate-security-middleware)

Add role-based access control and admin panel protection:

```
php artisan larahammer:make Product name:string --with-security-middleware
```

This generates:

- `app/Http/Middleware/CheckRole.php` — Role-based access control middleware
- `app/Http/Middleware/AdminPanelProtection.php` — Admin panel protection middleware
- Updated `app/Models/User.php` with role relationships and helper methods

**Register middleware in `app/Http/Kernel.php`:**

```
protected $routeMiddleware = [
    // ... other middleware ...
    'role' => \App\Http\Middleware\CheckRole::class,
    'admin' => \App\Http\Middleware\AdminPanelProtection::class,
];
```

**Usage in routes:**

```
// Restrict to specific roles
Route::middleware('role:admin,editor')->group(function () {
    Route::get('/content', ContentController::class);
});

// Restrict to admin only
Route::middleware(['auth', 'admin'])->group(function () {
    Route::get('/admin/dashboard', AdminController::class);
});
```

**User model helpers:**

```
auth()->user()->hasRole('admin');           // Check single role
auth()->user()->hasAnyRole(['admin', 'editor']); // Check multiple roles
auth()->user()->isAdmin();                  // Check if admin
```

### Combine Options

[](#combine-options)

```
php artisan larahammer:make Product name:string price:decimal \
  --target=filament \
  --with-roles \
  --with-admin \
  --with-landing \
  --with-security-middleware
```

---

After Generation
----------------

[](#after-generation)

Standard setup steps:

```
php artisan migrate
php artisan db:seed --class=ProductSeeder
php artisan serve
```

**If using `--with-roles`:**

```
php artisan db:seed --class=RoleSeeder  # seed roles
```

**If using `--with-admin`:**

- Ensure Filament v3 is installed: `composer require filament/filament`
- Run admin panel: `php artisan serve`
- Access at: `http://localhost:8000/admin`

**If using `--with-landing`:**

- Register the landing route in `routes/web.php`
- Landing page accessible at home route

---

Advanced Features — 3 Phases
----------------------------

[](#advanced-features--3-phases)

### **Phase 1: Factories &amp; Data Management**

[](#phase-1-factories--data-management)

#### Generate Model Factories

[](#generate-model-factories)

```
php artisan larahammer:make Product name:string price:decimal --with-factories
```

**Generates:** `database/factories/ProductFactory.php` with auto-generated Faker data

**Usage:**

```
// Create 10 products
Product::factory(10)->create();

// Create with specific state
Product::factory(5)->active()->create();

// Create with relationships
Product::factory(20)
    ->has(Review::factory(3))
    ->has(Tag::factory(5))
    ->create();
```

**Enhanced Seeder:** Automatically generates advanced seeder with factory usage instead of basic array data.

#### Add Soft Deletes

[](#add-soft-deletes)

```
php artisan larahammer:make Product name:string --with-soft-deletes
```

**Generates:**

- Migration with `softDeletes()` column
- Model with `SoftDeletes` trait
- Automatic scopes for include/exclude deleted records

**Usage:**

```
$product->delete();              // Soft delete
$product->restore();              // Restore
$product->forceDelete();           // Permanent delete
Product::withTrashed()->get();    // Include soft deleted
Product::onlyTrashed()->get();    // Only soft deleted
```

---

### **Phase 2: Security &amp; Authorization**

[](#phase-2-security--authorization)

#### Generate Authorization Policies

[](#generate-authorization-policies)

```
php artisan larahammer:make Product name:string --with-policies
```

**Generates:** `app/Policies/ProductPolicy.php` with CRUD authorization gates

**Features:**

- `viewAny()`, `view()` — View authorization
- `create()` — Creation authorization
- `update()` — Update authorization (checks ownership)
- `delete()` — Delete authorization
- `restore()` / `forceDelete()` — Soft delete operations

**Usage in Controller:**

```
public function update(Product $product)
{
    $this->authorize('update', $product);
    // Your update logic
}
```

**Usage in Blade:**

```
@can('update', $product)
    Edit Product
@endcan
```

**Register Policy** (in `app/Providers/AuthServiceProvider.php`):

```
protected $policies = [
    Product::class => ProductPolicy::class,
];
```

#### API Authentication &amp; Rate Limiting

[](#api-authentication--rate-limiting)

```
php artisan larahammer:make Product name:string --with-api-auth
```

**Generates:**

- `ApiAuthentication` middleware for token validation
- Rate limiting configuration
- Bearer token validation with Sanctum

**Setup in `routes/api.php`:**

```
Route::middleware('api.auth')->group(function () {
    Route::get('/products', [ProductController::class, 'index']);
    Route::post('/products', [ProductController::class, 'store']);
    Route::get('/products/{id}', [ProductController::class, 'show']);
    Route::put('/products/{id}', [ProductController::class, 'update']);
    Route::delete('/products/{id}', [ProductController::class, 'destroy']);
});
```

**Create API token for client:**

```
$token = auth()->user()->createToken('api-token')->plainTextToken;
```

**Rate limiting:**

```
Route::middleware('throttle:100,1')->group(function () {
    // Max 100 requests per minute
    Route::get('/products/search', SearchController::class);
});
```

---

### **Phase 3: Testing &amp; Auditing**

[](#phase-3-testing--auditing)

#### Generate Automated Tests

[](#generate-automated-tests)

```
php artisan larahammer:make Product name:string --with-tests
```

**Generates:**

- `tests/Feature/ProductCrudTest.php` — Full CRUD feature tests
- `tests/Unit/ProductTest.php` — Unit tests
- Test helpers with factory integration

**Feature Tests Include:**

- Test list/show/create/update/delete operations
- Test validation failures
- Test authentication requirements
- Response assertions

**Run tests:**

```
php artisan test
php artisan test tests/Feature/ProductCrudTest.php
php artisan test --filter=test_can_create_record
```

#### Activity Logging &amp; Audit Trail

[](#activity-logging--audit-trail)

```
php artisan larahammer:make Product name:string --with-audit-log
```

**Generates:**

- `ActivityLog` model and migration
- `ProductObserver` class for automatic logging
- Audit trail with before/after changes

**Features:**

- Automatically logs: created, updated, deleted, restored events
- Records: user, IP address, user agent, timestamp
- Stores: before and after data for changes
- JSON-storable change data

**Register observer** (in `app/Providers/EventServiceProvider.php`):

```
use App\Models\Product;
use App\Observers\ProductObserver;

public function boot(): void
{
    Product::observe(ProductObserver::class);
}
```

**Query activity logs:**

```
// Get all activity for a product
$product->activityLogs()->get();

// Get creation activity only
ActivityLog::byAction('created')->byModel(Product::class)->get();

// Get recent activity (last 24 hours)
ActivityLog::recent()->get();

// Check who updated what
$log = ActivityLog::where('action', 'updated')->first();
echo $log->user->name;           // Who made the change
echo $log->changes['before'];    // Old data
echo $log->changes['after'];     // New data
```

---

Super Command — All Features Combined
-------------------------------------

[](#super-command--all-features-combined)

Generate everything at once:

```
php artisan larahammer:make Product \
  name:string \
  price:decimal \
  stock:integer \
  status:enum(active,inactive) \
  --target=filament \
  --with-roles \
  --with-admin \
  --with-landing \
  --with-security-middleware \
  --with-factories \
  --with-soft-deletes \
  --with-policies \
  --with-api-auth \
  --with-tests \
  --with-audit-log
```

**This generates 80+ files instantly with:**

- ✅ Complete CRUD (Migration, Model, Controller)
- ✅ Role system &amp; admin panel (Filament)
- ✅ Landing page
- ✅ Security middleware
- ✅ Model factories with Faker
- ✅ Soft deletes
- ✅ Authorization policies
- ✅ API authentication &amp; rate limiting
- ✅ Feature &amp; unit tests
- ✅ Activity logging with audit trail

Customizing Stubs
-----------------

[](#customizing-stubs)

Publish the stubs to your project and modify them freely:

```
php artisan vendor:publish --tag=larahammer-stubs
```

Stubs will be published to `stubs/larahammer/`. Larahammer will use your custom stubs over the package defaults automatically.

---

Configuration
-------------

[](#configuration)

Publish the config:

```
php artisan vendor:publish --tag=larahammer-config
```

Options in `config/larahammer.php`:

```
'default_target' => 'blade',   // Skip the prompt — set your default
'force'          => false,     // Overwrite existing files by default
```

---

Force Overwrite
---------------

[](#force-overwrite)

```
php artisan larahammer:make Product name:string --force
```

---

License
-------

[](#license)

MIT — free to use in personal and commercial projects.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance90

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

46d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5e5dff20b7dd0039477fba989aacad86baa26f7221f3e568d6b860f738656605?d=identicon)[larahammer](/maintainers/larahammer)

---

Top Contributors

[![larahammer](https://avatars.githubusercontent.com/u/271703969?v=4)](https://github.com/larahammer "larahammer (8 commits)")

---

Tags

laravelgeneratorscaffoldbladecrudREST APIfilament

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/larahammer-generator/health.svg)

```
[![Health](https://phpackages.com/badges/larahammer-generator/health.svg)](https://phpackages.com/packages/larahammer-generator)
```

###  Alternatives

[tightenco/jigsaw

Simple static sites with Laravel's Blade.

2.2k438.5k29](/packages/tightenco-jigsaw)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[infyomlabs/generator-builder

InfyOm Laravel Generator GUI Builder

132435.7k](/packages/infyomlabs-generator-builder)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
