-
-
Couldn't load subscription status.
- Fork 3.6k
Fixed #8709 - Bulk Deletion of Categories, Suppliers, Manufa... #17573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
snipe
merged 41 commits into
grokability:develop
from
spencerrlongg:feature/8709-bulk-deletion-of-asset-categories-suppliers-manufacturers
Oct 13, 2025
Merged
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
ee5aac8
supplier destroy action creaated and a lot scratched out
spencerrlongg a0431e1
supplier actions working
spencerrlongg 1745648
category destroy action
spencerrlongg 5e81c63
some notes and things moved
spencerrlongg 1cee7e4
more (reusable) exceptions, a couple notes
spencerrlongg 13c971b
some refinements, bulk categories controller
spencerrlongg 5da79cd
destroy manufacturer action, bulk manufacturer controller
spencerrlongg db63ad1
add image check to supplier action
spencerrlongg d5ca543
start introducing parent exception
spencerrlongg 5f835aa
delete unused imports
spencerrlongg 4d8c5a8
routes added, tests scratched but need writing
spencerrlongg f1584b7
work on bulk tests, switching branches to check something
spencerrlongg 59ccc70
bulk changes that should make this work
spencerrlongg 7cdfaa9
a couple more tests and cleanup
spencerrlongg f590fcf
some tests, a component i probably won't use, beginning of front end
spencerrlongg b61419c
oop, revert delete
spencerrlongg 3eefeec
partials made, need to figure out all this jquery, button disabled
spencerrlongg d0e068f
suppliers completely done, rinse and repeat for the other two
spencerrlongg 0dcdfc5
fix tests after routing change
spencerrlongg 5cd5392
manufacturer completed, just categories left
spencerrlongg 6159ee8
category done!
spencerrlongg 78ca1d1
some cleanup
spencerrlongg 3052029
Merge branch 'develop' into feature/8709-bulk-deletion-of-asset-categ…
spencerrlongg e33b1b6
fixed maintenances
spencerrlongg b934f43
rename all exceptions
spencerrlongg 643d44a
change \Throwable to \Exceptionm, add missing `report()`s
spencerrlongg a091baf
component finally working
spencerrlongg c429964
rm unused import
spencerrlongg c39d484
rm unused import, new prop
spencerrlongg fdb0651
tests passing, needs some manual testing
spencerrlongg 7b6c0c3
Revert "tests passing, needs some manual testing"
spencerrlongg 1d88cf4
revert SuppliersController as well
spencerrlongg 51f6927
add details block for more than 3 errors to notification
spencerrlongg c450c0d
lots of translation changes
spencerrlongg 526bb2c
more translation changes
spencerrlongg 1d24b79
another translation change
spencerrlongg 36f5099
added new counts and throw new exceptions and catch them
spencerrlongg 32882f8
replace `box-default`
spencerrlongg b9f4dc1
translation
spencerrlongg 24bb45a
change translation
spencerrlongg 5fdb999
Merge branch 'develop' into feature/8709-bulk-deletion-of-asset-categ…
snipe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| <?php | ||
|
|
||
| namespace App\Actions\Categories; | ||
|
|
||
| use App\Exceptions\ItemStillHasAccessories; | ||
| use App\Exceptions\ItemStillHasAssetModels; | ||
| use App\Exceptions\ItemStillHasAssets; | ||
| use App\Exceptions\ItemStillHasComponents; | ||
| use App\Exceptions\ItemStillHasConsumables; | ||
| use App\Exceptions\ItemStillHasLicenses; | ||
| use App\Models\Category; | ||
| use Illuminate\Support\Facades\Storage; | ||
|
|
||
| class DestroyCategoryAction | ||
| { | ||
| /** | ||
| * @throws ItemStillHasAssets | ||
| * @throws ItemStillHasAssetModels | ||
| * @throws ItemStillHasComponents | ||
| * @throws ItemStillHasAccessories | ||
| * @throws ItemStillHasLicenses | ||
| * @throws ItemStillHasConsumables | ||
| */ | ||
| static function run(Category $category): bool | ||
| { | ||
| $category->loadCount([ | ||
| 'assets as assets_count', | ||
| 'accessories as accessories_count', | ||
| 'consumables as consumables_count', | ||
| 'components as components_count', | ||
| 'licenses as licenses_count', | ||
| 'models as models_count' | ||
| ]); | ||
|
|
||
| if ($category->assets_count > 0) { | ||
| throw new ItemStillHasAssets($category); | ||
| } | ||
| if ($category->accessories_count > 0) { | ||
| throw new ItemStillHasAccessories($category); | ||
| } | ||
| if ($category->consumables_count > 0) { | ||
| throw new ItemStillHasConsumables($category); | ||
| } | ||
| if ($category->components_count > 0) { | ||
| throw new ItemStillHasComponents($category); | ||
| } | ||
| if ($category->licenses_count > 0) { | ||
| throw new ItemStillHasLicenses($category); | ||
| } | ||
| if ($category->models_count > 0) { | ||
| throw new ItemStillHasAssetModels($category); | ||
| } | ||
|
|
||
| Storage::disk('public')->delete('categories'.'/'.$category->image); | ||
| $category->delete(); | ||
|
|
||
| return true; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| <?php | ||
|
|
||
| namespace App\Actions\Manufacturers; | ||
|
|
||
| use App\Exceptions\ItemStillHasAccessories; | ||
| use App\Exceptions\ItemStillHasAssets; | ||
| use App\Exceptions\ItemStillHasComponents; | ||
| use App\Exceptions\ItemStillHasConsumables; | ||
| use App\Exceptions\ItemStillHasLicenses; | ||
| use App\Models\Manufacturer; | ||
| use Illuminate\Support\Facades\Log; | ||
| use Illuminate\Support\Facades\Storage; | ||
|
|
||
| class DeleteManufacturerAction | ||
| { | ||
| /** | ||
| * @throws ItemStillHasAssets | ||
| * @throws ItemStillHasComponents | ||
| * @throws ItemStillHasAccessories | ||
| * @throws ItemStillHasLicenses | ||
| * @throws ItemStillHasConsumables | ||
| */ | ||
| static function run(Manufacturer $manufacturer): bool | ||
| { | ||
| $manufacturer->loadCount([ | ||
| 'assets as assets_count', | ||
| 'accessories as accessories_count', | ||
| 'consumables as consumables_count', | ||
| 'components as components_count', | ||
| 'licenses as licenses_count', | ||
| ]); | ||
|
|
||
| if ($manufacturer->assets_count > 0) { | ||
| throw new ItemStillHasAssets($manufacturer); | ||
| } | ||
| if ($manufacturer->accessories_count > 0) { | ||
| throw new ItemStillHasAccessories($manufacturer); | ||
| } | ||
| if ($manufacturer->consumables_count > 0) { | ||
| throw new ItemStillHasConsumables($manufacturer); | ||
| } | ||
| if ($manufacturer->components_count > 0) { | ||
| throw new ItemStillHasComponents($manufacturer); | ||
| } | ||
| if ($manufacturer->licenses_count > 0) { | ||
| throw new ItemStillHasLicenses($manufacturer); | ||
| } | ||
|
|
||
| if ($manufacturer->image) { | ||
| try { | ||
| Storage::disk('public')->delete('manufacturers/'.$manufacturer->image); | ||
| } catch (\Exception $e) { | ||
| Log::info($e); | ||
| } | ||
| } | ||
|
|
||
| $manufacturer->delete(); | ||
| //dd($manufacturer); | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| <?php | ||
|
|
||
| namespace App\Actions\Suppliers; | ||
|
|
||
| use App\Exceptions\ItemStillHasAccessories; | ||
| use App\Exceptions\ItemStillHasComponents; | ||
| use App\Exceptions\ItemStillHasConsumables; | ||
| use App\Models\Supplier; | ||
| use App\Exceptions\ItemStillHasAssets; | ||
| use App\Exceptions\ItemStillHasMaintenances; | ||
| use App\Exceptions\ItemStillHasLicenses; | ||
| use Illuminate\Support\Facades\Log; | ||
| use Illuminate\Support\Facades\Storage; | ||
|
|
||
| class DestroySupplierAction | ||
| { | ||
| /** | ||
| * | ||
| * @throws ItemStillHasLicenses | ||
| * @throws ItemStillHasAssets | ||
| * @throws ItemStillHasMaintenances | ||
| * @throws ItemStillHasAccessories | ||
| * @throws ItemStillHasConsumables | ||
| * @throws ItemStillHasComponents | ||
| */ | ||
| static function run(Supplier $supplier): bool | ||
| { | ||
| $supplier->loadCount([ | ||
| 'maintenances as maintenances_count', | ||
| 'assets as assets_count', | ||
| 'licenses as licenses_count', | ||
| 'accessories as accessories_count', | ||
| 'consumables as consumables_count', | ||
| 'components as components_count', | ||
| ]); | ||
| if ($supplier->assets_count > 0) { | ||
| throw new ItemStillHasAssets($supplier); | ||
| } | ||
|
|
||
| if ($supplier->maintenances_count > 0) { | ||
| throw new ItemStillHasMaintenances($supplier); | ||
| } | ||
|
|
||
| if ($supplier->licenses_count > 0) { | ||
| throw new ItemStillHasLicenses($supplier); | ||
| } | ||
|
|
||
| if ($supplier->accessories_count > 0) { | ||
| throw new ItemStillHasAccessories($supplier); | ||
| } | ||
|
|
||
| if ($supplier->consumables_count > 0) { | ||
| throw new ItemStillHasConsumables($supplier); | ||
| } | ||
|
|
||
| if ($supplier->components_count > 0) { | ||
| throw new ItemStillHasComponents($supplier); | ||
| } | ||
|
|
||
| if ($supplier->image) { | ||
| try { | ||
| Storage::disk('public')->delete('suppliers/'.$supplier->image); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we restore these categories, etc, the image will be broken |
||
| } catch (\Exception $e) { | ||
| Log::info($e->getMessage()); | ||
| } | ||
| } | ||
|
|
||
| $supplier->delete(); | ||
|
|
||
| return true; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <?php | ||
|
|
||
| namespace App\Exceptions; | ||
|
|
||
| use Exception; | ||
|
|
||
| class ItemStillHasAccessories extends ItemStillHasChildren | ||
| { | ||
| // | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <?php | ||
|
|
||
| namespace App\Exceptions; | ||
|
|
||
| use Exception; | ||
|
|
||
| class ItemStillHasAssetModels extends ItemStillHasChildren | ||
| { | ||
| // | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <?php | ||
|
|
||
| namespace App\Exceptions; | ||
|
|
||
| use Exception; | ||
|
|
||
| class ItemStillHasAssets extends ItemStillHasChildren | ||
| { | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| <?php | ||
|
|
||
| namespace App\Exceptions; | ||
|
|
||
| use Exception; | ||
|
|
||
| class ItemStillHasChildren extends Exception | ||
| { | ||
| //public function __construct($message, $code = 0, Exception $previous = null, $parent, $children) | ||
| //{ | ||
| // trans() | ||
| // | ||
| //} | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <?php | ||
|
|
||
| namespace App\Exceptions; | ||
|
|
||
| use Exception; | ||
|
|
||
| class ItemStillHasComponents extends ItemStillHasChildren | ||
| { | ||
| // | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <?php | ||
|
|
||
| namespace App\Exceptions; | ||
|
|
||
| use Exception; | ||
|
|
||
| class ItemStillHasConsumables extends ItemStillHasChildren | ||
| { | ||
| // | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <?php | ||
|
|
||
| namespace App\Exceptions; | ||
|
|
||
| use Exception; | ||
|
|
||
| class ItemStillHasLicenses extends ItemStillHasChildren | ||
| { | ||
| // | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <?php | ||
|
|
||
| namespace App\Exceptions; | ||
|
|
||
| use Exception; | ||
|
|
||
| class ItemStillHasMaintenances extends ItemStillHasChildren | ||
| { | ||
| // | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kinda feel like all these checks could get put in something like:
And then you can make
is_deletable()just be like this: