kareemtarek / crud-pack
Reusable Laravel CRUD generator (controllers, requests, models, migrations, policies, views, routes).
Installs: 25
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/kareemtarek/crud-pack
Requires
- php: ^8.0
- illuminate/console: ^8.0|^9.0|^10.0|^11.0|^12.0
- illuminate/filesystem: ^8.0|^9.0|^10.0|^11.0|^12.0
- illuminate/support: ^8.0|^9.0|^10.0|^11.0|^12.0
README
[0.1.0] - Initial Release
Added
- Single Artisan command
crud:makefor CRUD generation - Support for Web and API controllers
- Mandatory controller type and soft-delete mode selection
- Optional generators:
- Routes
- Eloquent model
- Migration
- Form request (store + update)
- Policy
- Blade views (Web only)
- Blade ready pagination components (Bootstrap 5, Bootstrap 4, tailwind, default, etc.)
- Shared delete-handling trait generated once per application
- Soft delete workflows:
- Trashed listing (partially deleted resources)
- Restore (single & bulk)
- Force delete (single & bulk)
- Bulk delete support
- Blueprint-first design (no hidden logic, no magic)
- Bootstrap 5–based Blade views
- Interactive wizard mode
- Full Laravel naming convention compliance
- Compatibility with PHP 8.0+ and Laravel 8.0+
Notes
- This is the first stable release.
- All generated code is intended to be edited and customized by developers.
⬇️ Lets get started❗ ⬇️
CRUD Pack (kareemtarek/crud-pack)
CRUD Pack is a blueprint-first Laravel CRUD generator that allows developers to scaffold complete CRUD resources (Web or API) using a single Artisan command, while strictly following Laravel conventions.
It is designed to eliminate repetitive boilerplate without hiding logic, without magic, and without locking developers into abstractions. Everything generated by CRUD Pack is readable, editable, and intended to be owned and customized by the developer.
CRUD Pack includes first-class support for:
- Soft deletes
- Bulk operations
- Trashed listings (partially deleted resources)
- Restore workflows
- Force-delete workflows
All delete-related behavior is implemented in a shared, reusable way, ensuring consistency across the entire application.
Why CRUD Pack Exists
Most Laravel CRUD generators fall into one of two categories:
-
Overly magical generators
These hide logic, abstract behavior too aggressively, and make customization difficult. -
Minimal stub generators
These save very little time and leave all real-world concerns to the developer.
CRUD Pack intentionally sits between these two extremes.
It generates a complete, real-world CRUD blueprint that:
- Follows Laravel conventions strictly
- Handles real application needs (soft deletes, bulk actions, restore flows)
- Keeps all logic explicit and visible
- Encourages customization instead of hiding behavior
The goal is speed without sacrificing control.
Requirements
- PHP: 8.0 or higher
- Laravel: 8.0 or higher
- Developed and tested on Laravel 12
- Fully compatible with Laravel 8.0+
Installation
After installing the package
composer require kareemtarek/crud-pack php artisan crud-pack:install
To override without prompts:
php artisan crud-pack:install --force
Lets jump into the package instructions ⤵️
Core Concept
CRUD Pack is centered around one single Artisan command and one resource name.
From that resource name, CRUD Pack automatically derives everything else according to Laravel conventions, including:
- Model names
- Table names
- Controller classes
- Route URIs and route names
- View directories
- Variable names
This guarantees:
- Consistency across the application
- Predictable structure
- Zero naming ambiguity
Command Overview
php artisan crud:make ResourceName
This command always generates a "controller" (wether web or api) and can optionally generate:
- Routes
- Eloquent model
- Migration
- Request validation
- Policy
- Blade views (Web controllers only)
The command requires two mandatory decisions and supports optional generators through flags or an interactive wizard.
Resource Name Rules
The resource name is the foundation of everything CRUD Pack generates and must strictly follow Laravel conventions.
Rules
- Must be singular
- Must be StudlyCase
- Must NOT include suffixes like Controller, Model, Request, etc.
Valid Examples ✅
php artisan crud:make Category php artisan crud:make Product php artisan crud:make ProductCategory
Invalid Examples ❌
php artisan crud:make categories php artisan crud:make category php artisan crud:make product_categories
From this single resource name, CRUD Pack dynamically derives:
| Item | Result |
|---|---|
| Model | App\Models\Category |
| Table | categories |
| Controller (Web) | App\Http\Controllers\CategoryController |
| Controller (API) | App\Http\Controllers\Api\CategoryController |
| Route URI | /categories |
| Route names | categories.* |
| Variables | $category, $categories |
| Views folder | resources/views/categories |
Mandatory Decisions (Always Required)
Every execution of the command requires two mandatory decisions. These are never optional and must be resolved before generation proceeds.
1) Controller Type
Choose exactly one:
- --web → Web controller (Blade views, redirects, sessions)
- --api → API controller (JSON responses only)
2) Soft Delete Mode
Choose exactly one:
- --soft-deletes
- --no-soft-deletes
These decisions can be passed as flags or selected interactively.
Example
php artisan crud:make Category --web --soft-deletes
If either decision is missing, CRUD Pack will prompt the developer to choose.
Publish the config file
Publish the package config into your Laravel app:
CRUD Pack ships with a default configuration file that controls things like the navbar CRUD resources dropdown (which resources appear, their labels/routes, and whether a resource shows a Trash link when Soft Deletes are enabled) in the resources\views\layouts\navigation.blade.php.
To copy the config file into your Laravel app (so you can customize it), publish it using:
php artisan vendor:publish --tag=crud-pack-config
This will create:
config/crud-pack.phpAfter publishing, editconfig/crud-pack.phpto define your resources and menu behavior
Optional Generators
In addition to the controller (which is always generated), CRUD Pack can optionally generate:
| Option | Description |
|---|---|
--routes |
Append routes to routes/web.php or routes/api.php |
--model |
Generate an Eloquent model |
--migration |
Generate a migration |
--request |
Generate a single FormRequest (used for store & update) |
--policy-style |
Generate a policy and wire authorization |
--views |
Generate Blade views (Web only) |
CRUD Pack provides a convenience shortcut:
The --policy-style= Shortcut (default "authorize")
- --policy-style=authorize (adds use AuthorizesRequests and $this->authorize(...)) [default]
- --policy-style=gate (\Illuminate\Support\Facades\Gate::authorize(...))
- --policy-style=resource (uses authorizeResource() but only if compatible)
- --policy-style=none (no policy is used)
The --all Shortcut
php artisan crud:make Category --web --soft-deletes --all
Behavior of --all
Web controller
- routes
- model
- migration
- request
- policy
- views
API controller
- routes
- model
- migration
- request
- policy
- never generates views
Important Rules
--allis exclusive- It cannot be combined with any other generator flags
- Invalid combinations cause a hard error and stop execution
Wizard Mode (Interactive Prompts)
If the developer:
- does not pass
--all - and does not explicitly pass any optional generator flags
CRUD Pack enters wizard mode and prompts the developer with yes/no questions:
- Generate routes?
- Generate model?
- Generate migration?
- Generate request validation?
- Generate policy?
- Generate views? (Web only)
If the controller type is API, the views prompt is never shown.
Shared Delete-Handling Trait (Created Once Per App)
CRUD Pack uses one shared delete-handling trait across the entire application.
Trait Location
app/Http/Controllers/Concerns/HandlesDeletes.php
To create (if not existing)/replace (if existing) the HandlesDeletes.php trait with prompting [for any updates made from the package, and if you want to recreate the file to pull the updated logic] + including soft-delete methods (uncommented)
php artisan crud:trait --soft-deletes
To create (if not existing)/replace (if existing) the HandlesDeletes.php trait with prompting [for any updates made from the package, and if you want to recreate the file to pull the updated logic] + including soft-delete methods (commented)
php artisan crud:trait --no-soft-deletes
To overwrite existing HandlesDeletes.php trait without prompting + with/without including soft-delete methods
php artisan crud:trait [--soft-deletes or --no-soft-deletes] --force
Behavior
- The trait is generated once per Laravel application
- On the first CRUD generation, the trait is created
- On subsequent CRUD generations:
- The trait is detected
- Creation is skipped
- A message is printed indicating it already exists
This ensures:
- No duplicated delete logic
- One consistent delete blueprint
- Reusable behavior across all controllers
Delete & Soft-Delete Endpoints (Trait Methods)
All delete-related endpoints live directly inside the trait, not in controllers.
Methods Provided
destroy — single record delete (resource method)
destroyBulk — bulk delete
trash — list soft-deleted records
restore — restore single record
restoreBulk — restore multiple records
forceDelete — permanently delete single record
forceDeleteBulk — permanently delete multiple records
Important Rules
- destroy is always active
- The other six methods are soft-delete related
- The trait always contains real logic
- Methods are enabled/disabled via routes, not by modifying the trait
- Responses automatically adapt:
- JSON for API
- Redirects + flash messages for Web
Soft Delete Behavior (Blueprint-First Design)
When route generation is enabled:
If --soft-deletes is selected
- All soft-delete routes are generated active
- trash (Deleted) listing, restore, force delete, and bulk operations work immediately
If --no-soft-deletes is selected
- Soft-delete routes are still generated
- They are commented out
- This provides a visible blueprint developers can enable later
Nothing is hidden. Nothing is removed.
Routes Generation
If route generation is enabled:
Main CRUD Route (Single Line)
Web
Route::resource('categories', CategoryController::class);
API
Route::apiResource('categories', Api\CategoryController::class);
This covers all standard CRUD actions, including single-record destroy.
Additional Delete Routes
Generated explicitly:
- destroyBulk (destroy/delete multiple resource at once)
- trash (the blade/page that has the deleted resources by the soft-delete)
- restore (restore action for a single soft-deleted resource)
- restoreBulk (restore action for a multiple soft-deleted resources)
- forceDelete (permanent destroy/delete action for a single soft-deleted resource)
- forceDeleteBulk (permanent destroy/delete action for a multiple soft-deleted resources)
These routes are:
- Appended to the correct routes file (web or api, based on the option entered in the CLI)
- Wrapped with clear start/end markers (Comments)
- Enabled or commented based on soft-delete choice (dynamic to the selected soft-delete option in the CLI)
Blade Views (Web Controllers Only)
When views are enabled, CRUD Pack generates Bootstrap 5–based Blade templates:
- index (listing + bulk actions)
- create
- edit
- show
_form(shared with create & edit blades)- trash (soft-deleted records)
View Features
- Checkbox selection + select-all
- Single & bulk actions (delete actions)
- Confirmation prompts
- Validation error display
- Proper old() handling
- Clean, minimal, production-ready layout
Request Validation
If request generation is enabled:
- A single FormRequest is generated
- Used for both
storeandupdate - Handles unique validation correctly with ignore logic
Policies
If policy generation is enabled:
- A policy is generated following Laravel conventions
- Authorization is wired into the controller constructor
If no policy is generated: -The controller constructor remains empty -No authorization logic is injected
Example Commands
Web CRUD with everything
php artisan crud:make Category --web --soft-deletes --all
API CRUD with everything
php artisan crud:make Product --api --no-soft-deletes --all
Interactive wizard
php artisan crud:make Department
Philosophy & Customization
CRUD Pack exists to:
- Remove repetitive CRUD boilerplate
- Provide a professional, realistic starting point
- Preserve full developer control
All generated code is:
- Readable
- Editable
- Replaceable
You are never locked in.