DELETE Component

Source: /f/apachefriends/xampp/htdocs/wallpaperama/forums-react/Oct2025-Laravel-Version/app3-crud/Laravel12ReactCrud/ReactLaravel

Purpose: safe, interactive deletion tool to remove a Laravel + Inertia (React) “component” (model, controller, factory, migrations, seeder entries, routes, and React page files) from the project.

Where to run: from inside the Laravel project (script locates the project root by searching for artisan).

Invocation / flags:

cr-DELETE-component-laravel.sh [ModelName]
Options: -y|--yes (assume yes for all confirmations), --dry-run (show actions without deleting), -h|--help.
Interactive confirmations: prompts before each destructive action (can be bypassed with --yes).

Dry-run mode: prints what would be removed without touching files.

Backups: when editing critical files (e.g., routes/web.php, database/seeders/DatabaseSeeder.php) the script creates backups (timestamped .bak) before changes.

What it checks and can remove:

app/Models/<Model>.php
database/factories/<Model>Factory.php
Migration files matching patterns under database/migrations (multiple possible matches)
database/seeders/<Model>Seeder.php and factory lines in DatabaseSeeder.php
app/Http/Controllers/<Model>Controller.php
References to <Model>Controller in routes/web.php (removes use and route lines optionally)
resources/js/Pages/<PluralModel> directory and common page files (All.jsx, Index.jsx, etc.)
Optionally runs a project-wide grep (or ripgrep if available) to list remaining references
Deletion behavior: uses rm -f (or rm -rf for directories), with DRY-RUN support and safe quoting for Windows/Git Bash.

Safety notes / recommendations:

Review the backups (.bak and timestamped .bak) before committing.
Use --dry-run first to confirm matched files.
The pluralization is naive (adds "s"); verify file paths if irregular plural forms are used.
The script edits DatabaseSeeder.php with a sed operation — keep a copy/commit before running.
Output: prints actions taken and locations of backups; suggests manual review after completion.

23-p5342-cr-delete-component-laravel.sh