A (maybe?) missing destroy command for anyone who has second thoughts. This will delete artisan-generated files from your project.
Let's say, you have generated some files using the artisan make
command. Then you think of a better name, or the generated files don't have a proper name based on the Laravel naming convention. This simple package will help you clean up those messes.
Just replace your artisan make:...
command with artisan destroy:...
and you're good to go. These commands will also warn you if the file you are trying to delete is untracked or has uncommitted changes.
I have used some of these commands on my projects, so ️they should work.
Class | Command | Destroy Command | Test |
---|---|---|---|
Cast | destroy:cast |
✅ | ✅ |
Channel | destroy:channel |
✅ | ✅ |
Component | destroy:component |
✅ | |
Controller | destroy:controller |
✅ | |
Console | destroy:console |
✅ | |
Event | destroy:event |
✅ | |
Exception | destroy:exception |
✅ | |
Factory | destroy:factory |
✅ | |
Job | destroy:job |
✅ | |
Listener | destroy:listener |
✅ | |
destroy:mail |
✅ | ||
Middleware | destroy:middleware |
✅ | |
Migration | destroy:migration |
✅ | |
Model | destroy:model |
✅ | |
Notification | destroy:notification |
✅ | |
Observer | destroy:observer |
✅ | |
Policy | destroy:policy |
✅ | |
Provider | destroy:provider |
✅ | |
Request | destroy:request |
✅ | |
Resource | destroy:resource |
✅ | |
Rule | destroy:rule |
✅ | |
Scope | destroy:scope |
✅ | |
Seeder | destroy:seeder |
✅ | |
Test | destroy:test |
✅ | |
View | destroy:view |
✅ |
- Git. This package will check if the file to be deleted is tracked and clean. If git is not installed, you'll need to use the
--force
option or disable git checking through the config file.
You can install the package as a dev dependency via composer:
composer require --dev msazzuhair/laravel-artisan-destroy
You can publish the config file with:
php artisan vendor:publish --tag="laravel-artisan-destroy-config"
php artisan destroy:model <Model Name>
You can use artisan help to see all available options for each command. For example:
php artisan help destroy:model
Description:
Delete an Eloquent model class
Usage:
destroy:model [options] [--] <name>
Arguments:
name The name of the model
Options:
-a, --all Delete a migration, seeder, factory, policy, resource controller, and form request classes for the model
-c, --controller Delete a controller for the model
-f, --factory Delete a factory for the model
--force Delete the class without prompting for confirmation
-m, --migration Delete a migration file for the model
--policy Delete a policy for the model
-s, --seed Delete a seeder for the model
-R, --requests Delete new form request classes and use them in the resource controller
-t, --test Delete any accompanying PHPUnit test for the model and every related classes that is going to also be deleted
-h, --help Display help for the given command. When no command is given display help for the list command
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi|--no-ansi Force (or disable --no-ansi) ANSI output
-n, --no-interaction Do not ask any interactive question
--env[=ENV] The environment the command should run under
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.