From d8682f601116fe7d336739e232c39142cfb7d6ca Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Tue, 11 Jan 2022 12:24:20 +0000 Subject: [PATCH 01/73] Dependencies - Updated FE and BE dependencies - Updated copyright date --- LICENSE | 2 +- app/Cache/Collection.php | 2 +- app/Cache/Control.php | 2 +- app/Cache/Job.php | 2 +- app/Cache/JobPayload.php | 2 +- app/Cache/Summary.php | 2 +- app/Http/Controllers/CategoryManage.php | 2 +- app/Http/Controllers/CategoryView.php | 2 +- app/Http/Controllers/CurrencyView.php | 2 +- app/Http/Controllers/IndexView.php | 2 +- app/Http/Controllers/ItemCategoryManage.php | 2 +- app/Http/Controllers/ItemCategoryView.php | 2 +- app/Http/Controllers/ItemManage.php | 2 +- .../Controllers/ItemPartialTransferManage.php | 2 +- .../Controllers/ItemPartialTransferView.php | 2 +- .../Controllers/ItemSubcategoryManage.php | 2 +- app/Http/Controllers/ItemSubcategoryView.php | 2 +- app/Http/Controllers/ItemSubtypeView.php | 2 +- app/Http/Controllers/ItemTransferManage.php | 2 +- app/Http/Controllers/ItemTransferView.php | 2 +- app/Http/Controllers/ItemTypeView.php | 2 +- app/Http/Controllers/ItemView.php | 2 +- app/Http/Controllers/PermittedUserView.php | 2 +- app/Http/Controllers/QueueView.php | 2 +- app/Http/Controllers/RequestManage.php | 2 +- app/Http/Controllers/RequestView.php | 2 +- app/Http/Controllers/ResourceManage.php | 2 +- app/Http/Controllers/ResourceTypeItemView.php | 2 +- app/Http/Controllers/ResourceTypeManage.php | 2 +- app/Http/Controllers/ResourceTypeView.php | 2 +- app/Http/Controllers/ResourceView.php | 2 +- app/Http/Controllers/SubcategoryManage.php | 2 +- app/Http/Controllers/SubcategoryView.php | 2 +- app/Http/Controllers/Summary/CategoryView.php | 2 +- .../Summary/ResourceTypeItemView.php | 2 +- .../Controllers/Summary/ResourceTypeView.php | 2 +- app/Http/Controllers/Summary/ResourceView.php | 2 +- .../Controllers/Summary/SubcategoryView.php | 2 +- app/Http/Controllers/ToolManage.php | 2 +- app/Http/Controllers/ToolView.php | 2 +- app/Http/Middleware/ConvertGetParameters.php | 2 +- .../Middleware/ConvertRouteParameters.php | 2 +- app/ItemType/AllocatedExpense/Model.php | 2 +- .../AllocatedExpense/ResourceTypeModel.php | 2 +- .../ResourceTypeTransformer.php | 2 +- .../AllocatedExpense/SummaryModel.php | 2 +- .../SummaryResourceTypeModel.php | 2 +- .../AllocatedExpense/SummaryTransformer.php | 2 +- .../SummaryTransformerByCategory.php | 2 +- .../SummaryTransformerByMonth.php | 2 +- .../SummaryTransformerByResource.php | 2 +- .../SummaryTransformerBySubcategory.php | 2 +- .../SummaryTransformerByYear.php | 2 +- app/ItemType/AllocatedExpense/Transformer.php | 2 +- app/ItemType/AllocatedExpense/Validator.php | 2 +- app/ItemType/Game/Model.php | 2 +- app/ItemType/Game/ResourceTypeModel.php | 2 +- app/ItemType/Game/ResourceTypeTransformer.php | 2 +- app/ItemType/Game/SummaryModel.php | 2 +- .../Game/SummaryResourceTypeModel.php | 2 +- app/ItemType/Game/SummaryTransformer.php | 2 +- .../Game/SummaryTransformerByResource.php | 2 +- app/ItemType/Game/Transformer.php | 2 +- app/ItemType/Game/Validator.php | 2 +- app/ItemType/SimpleExpense/Model.php | 2 +- .../SimpleExpense/ResourceTypeModel.php | 2 +- .../SimpleExpense/ResourceTypeTransformer.php | 2 +- app/ItemType/SimpleExpense/SummaryModel.php | 2 +- .../SummaryResourceTypeModel.php | 2 +- .../SimpleExpense/SummaryTransformer.php | 2 +- .../SummaryTransformerByCategory.php | 2 +- .../SummaryTransformerByResource.php | 2 +- .../SummaryTransformerBySubcategory.php | 2 +- app/ItemType/SimpleExpense/Transformer.php | 2 +- app/ItemType/SimpleExpense/Validator.php | 2 +- app/ItemType/SimpleItem/Model.php | 2 +- app/ItemType/SimpleItem/ResourceTypeModel.php | 2 +- .../SimpleItem/ResourceTypeTransformer.php | 2 +- app/ItemType/SimpleItem/SummaryModel.php | 2 +- .../SimpleItem/SummaryResourceTypeModel.php | 2 +- .../SimpleItem/SummaryTransformer.php | 2 +- .../SummaryTransformerByResource.php | 2 +- app/ItemType/SimpleItem/Transformer.php | 2 +- app/ItemType/SimpleItem/Validator.php | 2 +- app/Jobs/ClearCache.php | 2 +- app/Method/DeleteRequest.php | 2 +- app/Method/GetRequest.php | 2 +- app/Method/Method.php | 2 +- app/Method/PatchRequest.php | 2 +- app/Method/PostRequest.php | 2 +- app/Models/Cache.php | 2 +- app/Models/Category.php | 2 +- app/Models/Clause.php | 2 +- app/Models/Currency.php | 2 +- app/Models/EntityLimits.php | 2 +- app/Models/ErrorLog.php | 2 +- app/Models/Item.php | 2 +- app/Models/ItemCategory.php | 2 +- app/Models/ItemPartialTransfer.php | 2 +- app/Models/ItemSubcategory.php | 2 +- app/Models/ItemSubtype.php | 2 +- app/Models/ItemTransfer.php | 2 +- app/Models/ItemType.php | 2 +- app/Models/PermittedUser.php | 2 +- app/Models/Queue.php | 2 +- app/Models/RequestErrorLog.php | 2 +- app/Models/Resource.php | 2 +- app/Models/ResourceAccess.php | 2 +- app/Models/ResourceItemSubtype.php | 2 +- app/Models/ResourceType.php | 2 +- app/Models/ResourceTypeItem.php | 2 +- app/Models/ResourceTypeItemType.php | 2 +- app/Models/Subcategory.php | 2 +- app/Models/Summary/Category.php | 2 +- app/Models/Summary/Resource.php | 2 +- app/Models/Summary/ResourceType.php | 2 +- app/Models/Summary/Subcategory.php | 2 +- app/Request/BodyValidation.php | 2 +- app/Request/Hash.php | 2 +- app/Request/Parameter/Filter.php | 2 +- app/Request/Parameter/Request.php | 2 +- app/Request/Parameter/Search.php | 2 +- app/Request/Parameter/Sort.php | 2 +- app/Request/Route/Validate/Currency.php | 2 +- app/Request/Route/Validate/ItemSubtype.php | 2 +- app/Request/Route/Validate/ItemType.php | 2 +- app/Request/Route/Validate/Queue.php | 2 +- app/Request/Validate/Boolean.php | 2 +- app/Request/Validate/Category.php | 2 +- app/Request/Validate/ItemCategory.php | 2 +- app/Request/Validate/ItemPartialTransfer.php | 2 +- app/Request/Validate/ItemSubcategory.php | 2 +- app/Request/Validate/ItemTransfer.php | 2 +- app/Request/Validate/RequestErrorLog.php | 2 +- app/Request/Validate/Resource.php | 2 +- app/Request/Validate/ResourceType.php | 2 +- app/Request/Validate/Subcategory.php | 2 +- app/Request/Validate/Validator.php | 2 +- app/Response/Header.php | 2 +- app/Response/Pagination.php | 2 +- app/Response/Responses.php | 2 +- app/Transformers/Category.php | 2 +- app/Transformers/Currency.php | 2 +- app/Transformers/ItemCategory.php | 2 +- app/Transformers/ItemPartialTransfer.php | 2 +- app/Transformers/ItemSubcategory.php | 2 +- app/Transformers/ItemSubtype.php | 2 +- app/Transformers/ItemTransfer.php | 2 +- app/Transformers/ItemType.php | 2 +- app/Transformers/PermittedUser.php | 2 +- app/Transformers/Queue.php | 2 +- app/Transformers/RequestErrorLog.php | 2 +- app/Transformers/Resource.php | 2 +- app/Transformers/ResourceType.php | 2 +- app/Transformers/ResourceTypeItem.php | 2 +- app/Transformers/Subcategory.php | 2 +- app/Transformers/Transformer.php | 2 +- composer.lock | 1082 ++++++++--------- 158 files changed, 676 insertions(+), 720 deletions(-) diff --git a/LICENSE b/LICENSE index 7b1ab612..c30c9045 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2018-2020 Dean Blackborough +Copyright (c) 2018-2022 Dean Blackborough Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/app/Cache/Collection.php b/app/Cache/Collection.php index c0b83923..cd38b99a 100644 --- a/app/Cache/Collection.php +++ b/app/Cache/Collection.php @@ -9,7 +9,7 @@ * object to interact with * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Collection diff --git a/app/Cache/Control.php b/app/Cache/Control.php index 6fe7e528..8e8ee19b 100644 --- a/app/Cache/Control.php +++ b/app/Cache/Control.php @@ -12,7 +12,7 @@ * Cache helper, wrapper around the Laravel cache facade * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Control diff --git a/app/Cache/Job.php b/app/Cache/Job.php index e639024e..11b156ac 100644 --- a/app/Cache/Job.php +++ b/app/Cache/Job.php @@ -7,7 +7,7 @@ * Decode the payload for a job * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Job diff --git a/app/Cache/JobPayload.php b/app/Cache/JobPayload.php index 70c9889b..16307bcc 100644 --- a/app/Cache/JobPayload.php +++ b/app/Cache/JobPayload.php @@ -9,7 +9,7 @@ * necessary * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class JobPayload diff --git a/app/Cache/Summary.php b/app/Cache/Summary.php index 3eb03562..cc6e38a3 100644 --- a/app/Cache/Summary.php +++ b/app/Cache/Summary.php @@ -9,7 +9,7 @@ * object to interact with * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Summary diff --git a/app/Http/Controllers/CategoryManage.php b/app/Http/Controllers/CategoryManage.php index 2ee0af8b..e5c689a5 100644 --- a/app/Http/Controllers/CategoryManage.php +++ b/app/Http/Controllers/CategoryManage.php @@ -14,7 +14,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class CategoryManage extends Controller diff --git a/app/Http/Controllers/CategoryView.php b/app/Http/Controllers/CategoryView.php index 3590c941..ef5226db 100644 --- a/app/Http/Controllers/CategoryView.php +++ b/app/Http/Controllers/CategoryView.php @@ -15,7 +15,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class CategoryView extends Controller diff --git a/app/Http/Controllers/CurrencyView.php b/app/Http/Controllers/CurrencyView.php index 321ddcbf..13cec7ae 100644 --- a/app/Http/Controllers/CurrencyView.php +++ b/app/Http/Controllers/CurrencyView.php @@ -14,7 +14,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class CurrencyView extends Controller diff --git a/app/Http/Controllers/IndexView.php b/app/Http/Controllers/IndexView.php index 8d241492..55e6487d 100644 --- a/app/Http/Controllers/IndexView.php +++ b/app/Http/Controllers/IndexView.php @@ -12,7 +12,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class IndexView extends Controller diff --git a/app/Http/Controllers/ItemCategoryManage.php b/app/Http/Controllers/ItemCategoryManage.php index a839f4cd..cad85cdd 100644 --- a/app/Http/Controllers/ItemCategoryManage.php +++ b/app/Http/Controllers/ItemCategoryManage.php @@ -15,7 +15,7 @@ * Manage the category for an item row * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ItemCategoryManage extends Controller diff --git a/app/Http/Controllers/ItemCategoryView.php b/app/Http/Controllers/ItemCategoryView.php index 5dd1e1ce..f70af0d3 100644 --- a/app/Http/Controllers/ItemCategoryView.php +++ b/app/Http/Controllers/ItemCategoryView.php @@ -14,7 +14,7 @@ * Manage the category for an item row * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ItemCategoryView extends Controller diff --git a/app/Http/Controllers/ItemManage.php b/app/Http/Controllers/ItemManage.php index 145b8388..f50ae7a4 100644 --- a/app/Http/Controllers/ItemManage.php +++ b/app/Http/Controllers/ItemManage.php @@ -16,7 +16,7 @@ * Manage items * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ItemManage extends Controller diff --git a/app/Http/Controllers/ItemPartialTransferManage.php b/app/Http/Controllers/ItemPartialTransferManage.php index 8869451c..20b0c371 100644 --- a/app/Http/Controllers/ItemPartialTransferManage.php +++ b/app/Http/Controllers/ItemPartialTransferManage.php @@ -15,7 +15,7 @@ * Partial transfer of items * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ItemPartialTransferManage extends Controller diff --git a/app/Http/Controllers/ItemPartialTransferView.php b/app/Http/Controllers/ItemPartialTransferView.php index 6523b200..8bfcf880 100644 --- a/app/Http/Controllers/ItemPartialTransferView.php +++ b/app/Http/Controllers/ItemPartialTransferView.php @@ -18,7 +18,7 @@ * Partial transfer of items * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ItemPartialTransferView extends Controller diff --git a/app/Http/Controllers/ItemSubcategoryManage.php b/app/Http/Controllers/ItemSubcategoryManage.php index 6be8ef73..773cfee5 100644 --- a/app/Http/Controllers/ItemSubcategoryManage.php +++ b/app/Http/Controllers/ItemSubcategoryManage.php @@ -16,7 +16,7 @@ * Manage the category for an item row * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ItemSubcategoryManage extends Controller diff --git a/app/Http/Controllers/ItemSubcategoryView.php b/app/Http/Controllers/ItemSubcategoryView.php index 238d5d6e..64c57e5b 100644 --- a/app/Http/Controllers/ItemSubcategoryView.php +++ b/app/Http/Controllers/ItemSubcategoryView.php @@ -15,7 +15,7 @@ * Manage the category for an item row * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ItemSubcategoryView extends Controller diff --git a/app/Http/Controllers/ItemSubtypeView.php b/app/Http/Controllers/ItemSubtypeView.php index 9a3c343b..fee5adab 100644 --- a/app/Http/Controllers/ItemSubtypeView.php +++ b/app/Http/Controllers/ItemSubtypeView.php @@ -16,7 +16,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ItemSubtypeView extends Controller diff --git a/app/Http/Controllers/ItemTransferManage.php b/app/Http/Controllers/ItemTransferManage.php index 087daf4c..6091807c 100644 --- a/app/Http/Controllers/ItemTransferManage.php +++ b/app/Http/Controllers/ItemTransferManage.php @@ -15,7 +15,7 @@ * Transfer items * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ItemTransferManage extends Controller diff --git a/app/Http/Controllers/ItemTransferView.php b/app/Http/Controllers/ItemTransferView.php index 2431454c..32a03fc0 100644 --- a/app/Http/Controllers/ItemTransferView.php +++ b/app/Http/Controllers/ItemTransferView.php @@ -17,7 +17,7 @@ * Transfer items * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ItemTransferView extends Controller diff --git a/app/Http/Controllers/ItemTypeView.php b/app/Http/Controllers/ItemTypeView.php index 33041d43..b40d767b 100644 --- a/app/Http/Controllers/ItemTypeView.php +++ b/app/Http/Controllers/ItemTypeView.php @@ -18,7 +18,7 @@ * Manage the item types supported by the API * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ItemTypeView extends Controller diff --git a/app/Http/Controllers/ItemView.php b/app/Http/Controllers/ItemView.php index 14a6b3eb..d568be2b 100644 --- a/app/Http/Controllers/ItemView.php +++ b/app/Http/Controllers/ItemView.php @@ -11,7 +11,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ItemView extends Controller diff --git a/app/Http/Controllers/PermittedUserView.php b/app/Http/Controllers/PermittedUserView.php index 420d47e4..6a0cf8e8 100644 --- a/app/Http/Controllers/PermittedUserView.php +++ b/app/Http/Controllers/PermittedUserView.php @@ -15,7 +15,7 @@ * Manage permitted users * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class PermittedUserView extends Controller diff --git a/app/Http/Controllers/QueueView.php b/app/Http/Controllers/QueueView.php index 35b7f5c3..ff8f2675 100644 --- a/app/Http/Controllers/QueueView.php +++ b/app/Http/Controllers/QueueView.php @@ -14,7 +14,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class QueueView extends Controller diff --git a/app/Http/Controllers/RequestManage.php b/app/Http/Controllers/RequestManage.php index 9bb6c99d..4031726f 100644 --- a/app/Http/Controllers/RequestManage.php +++ b/app/Http/Controllers/RequestManage.php @@ -12,7 +12,7 @@ * Manage categories * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class RequestManage extends Controller diff --git a/app/Http/Controllers/RequestView.php b/app/Http/Controllers/RequestView.php index b027b40a..a2eb1efd 100644 --- a/app/Http/Controllers/RequestView.php +++ b/app/Http/Controllers/RequestView.php @@ -12,7 +12,7 @@ * Manage categories * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class RequestView extends Controller diff --git a/app/Http/Controllers/ResourceManage.php b/app/Http/Controllers/ResourceManage.php index 4574579f..8b8e2108 100644 --- a/app/Http/Controllers/ResourceManage.php +++ b/app/Http/Controllers/ResourceManage.php @@ -18,7 +18,7 @@ * Manage resources * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ResourceManage extends Controller diff --git a/app/Http/Controllers/ResourceTypeItemView.php b/app/Http/Controllers/ResourceTypeItemView.php index 644c3e95..ed704dd7 100644 --- a/app/Http/Controllers/ResourceTypeItemView.php +++ b/app/Http/Controllers/ResourceTypeItemView.php @@ -10,7 +10,7 @@ * View items for all resources for a resource type * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ResourceTypeItemView extends Controller diff --git a/app/Http/Controllers/ResourceTypeManage.php b/app/Http/Controllers/ResourceTypeManage.php index 5d227ec5..d3bb518a 100644 --- a/app/Http/Controllers/ResourceTypeManage.php +++ b/app/Http/Controllers/ResourceTypeManage.php @@ -20,7 +20,7 @@ * Manage resource types * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ResourceTypeManage extends Controller diff --git a/app/Http/Controllers/ResourceTypeView.php b/app/Http/Controllers/ResourceTypeView.php index b71496f0..b8139124 100644 --- a/app/Http/Controllers/ResourceTypeView.php +++ b/app/Http/Controllers/ResourceTypeView.php @@ -18,7 +18,7 @@ * Manage resource types * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ResourceTypeView extends Controller diff --git a/app/Http/Controllers/ResourceView.php b/app/Http/Controllers/ResourceView.php index 34edda45..8b8e10aa 100644 --- a/app/Http/Controllers/ResourceView.php +++ b/app/Http/Controllers/ResourceView.php @@ -18,7 +18,7 @@ * Manage resources * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ResourceView extends Controller diff --git a/app/Http/Controllers/SubcategoryManage.php b/app/Http/Controllers/SubcategoryManage.php index e8d2b695..66f5e677 100644 --- a/app/Http/Controllers/SubcategoryManage.php +++ b/app/Http/Controllers/SubcategoryManage.php @@ -15,7 +15,7 @@ * Manage category sub categories * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class SubcategoryManage extends Controller diff --git a/app/Http/Controllers/SubcategoryView.php b/app/Http/Controllers/SubcategoryView.php index ca7a6aa9..efa70af4 100644 --- a/app/Http/Controllers/SubcategoryView.php +++ b/app/Http/Controllers/SubcategoryView.php @@ -16,7 +16,7 @@ * Manage category sub categories * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class SubcategoryView extends Controller diff --git a/app/Http/Controllers/Summary/CategoryView.php b/app/Http/Controllers/Summary/CategoryView.php index 54f4ed6b..5992b201 100644 --- a/app/Http/Controllers/Summary/CategoryView.php +++ b/app/Http/Controllers/Summary/CategoryView.php @@ -14,7 +14,7 @@ * Summary controller for the categories routes * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class CategoryView extends Controller diff --git a/app/Http/Controllers/Summary/ResourceTypeItemView.php b/app/Http/Controllers/Summary/ResourceTypeItemView.php index cd873c03..f02c6545 100644 --- a/app/Http/Controllers/Summary/ResourceTypeItemView.php +++ b/app/Http/Controllers/Summary/ResourceTypeItemView.php @@ -12,7 +12,7 @@ * Summary for resource type items route * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ResourceTypeItemView extends Controller diff --git a/app/Http/Controllers/Summary/ResourceTypeView.php b/app/Http/Controllers/Summary/ResourceTypeView.php index 3c4faaf5..13198e84 100644 --- a/app/Http/Controllers/Summary/ResourceTypeView.php +++ b/app/Http/Controllers/Summary/ResourceTypeView.php @@ -14,7 +14,7 @@ * Summary controller for the resource-type routes * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ResourceTypeView extends Controller diff --git a/app/Http/Controllers/Summary/ResourceView.php b/app/Http/Controllers/Summary/ResourceView.php index 6e8e50fc..87507750 100644 --- a/app/Http/Controllers/Summary/ResourceView.php +++ b/app/Http/Controllers/Summary/ResourceView.php @@ -14,7 +14,7 @@ * Summary controller for the resource routes * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ResourceView extends Controller diff --git a/app/Http/Controllers/Summary/SubcategoryView.php b/app/Http/Controllers/Summary/SubcategoryView.php index 548bc908..bcc05a16 100644 --- a/app/Http/Controllers/Summary/SubcategoryView.php +++ b/app/Http/Controllers/Summary/SubcategoryView.php @@ -14,7 +14,7 @@ * Summary controller for the subcategories routes * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class SubcategoryView extends Controller diff --git a/app/Http/Controllers/ToolManage.php b/app/Http/Controllers/ToolManage.php index 5b27da01..acc12315 100644 --- a/app/Http/Controllers/ToolManage.php +++ b/app/Http/Controllers/ToolManage.php @@ -7,7 +7,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ToolManage extends Controller diff --git a/app/Http/Controllers/ToolView.php b/app/Http/Controllers/ToolView.php index e00013ad..ff899e60 100644 --- a/app/Http/Controllers/ToolView.php +++ b/app/Http/Controllers/ToolView.php @@ -7,7 +7,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ToolView extends Controller diff --git a/app/Http/Middleware/ConvertGetParameters.php b/app/Http/Middleware/ConvertGetParameters.php index f647a1bf..576f6bdd 100644 --- a/app/Http/Middleware/ConvertGetParameters.php +++ b/app/Http/Middleware/ConvertGetParameters.php @@ -10,7 +10,7 @@ * Convert hashed GET params, decode the value and reset in the request * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ConvertGetParameters diff --git a/app/Http/Middleware/ConvertRouteParameters.php b/app/Http/Middleware/ConvertRouteParameters.php index 9dc353b1..2c1a57da 100644 --- a/app/Http/Middleware/ConvertRouteParameters.php +++ b/app/Http/Middleware/ConvertRouteParameters.php @@ -10,7 +10,7 @@ * Convert hashed route params, decode the value and reset in the route * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ConvertRouteParameters diff --git a/app/ItemType/AllocatedExpense/Model.php b/app/ItemType/AllocatedExpense/Model.php index a846b210..87071a08 100644 --- a/app/ItemType/AllocatedExpense/Model.php +++ b/app/ItemType/AllocatedExpense/Model.php @@ -13,7 +13,7 @@ /** * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Model extends LaravelModel diff --git a/app/ItemType/AllocatedExpense/ResourceTypeModel.php b/app/ItemType/AllocatedExpense/ResourceTypeModel.php index 9c330e27..bb503c68 100644 --- a/app/ItemType/AllocatedExpense/ResourceTypeModel.php +++ b/app/ItemType/AllocatedExpense/ResourceTypeModel.php @@ -12,7 +12,7 @@ /** * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ResourceTypeModel extends LaravelModel diff --git a/app/ItemType/AllocatedExpense/ResourceTypeTransformer.php b/app/ItemType/AllocatedExpense/ResourceTypeTransformer.php index 45c97654..aa9b6e69 100644 --- a/app/ItemType/AllocatedExpense/ResourceTypeTransformer.php +++ b/app/ItemType/AllocatedExpense/ResourceTypeTransformer.php @@ -7,7 +7,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ResourceTypeTransformer extends BaseTransformer diff --git a/app/ItemType/AllocatedExpense/SummaryModel.php b/app/ItemType/AllocatedExpense/SummaryModel.php index 43e4b57a..67029d81 100644 --- a/app/ItemType/AllocatedExpense/SummaryModel.php +++ b/app/ItemType/AllocatedExpense/SummaryModel.php @@ -11,7 +11,7 @@ /** * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class SummaryModel extends LaravelModel diff --git a/app/ItemType/AllocatedExpense/SummaryResourceTypeModel.php b/app/ItemType/AllocatedExpense/SummaryResourceTypeModel.php index 5b7a4bb8..d9d4de05 100644 --- a/app/ItemType/AllocatedExpense/SummaryResourceTypeModel.php +++ b/app/ItemType/AllocatedExpense/SummaryResourceTypeModel.php @@ -11,7 +11,7 @@ /** * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class SummaryResourceTypeModel extends LaravelModel diff --git a/app/ItemType/AllocatedExpense/SummaryTransformer.php b/app/ItemType/AllocatedExpense/SummaryTransformer.php index f9139172..ca8ba4e7 100644 --- a/app/ItemType/AllocatedExpense/SummaryTransformer.php +++ b/app/ItemType/AllocatedExpense/SummaryTransformer.php @@ -7,7 +7,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class SummaryTransformer extends Transformer diff --git a/app/ItemType/AllocatedExpense/SummaryTransformerByCategory.php b/app/ItemType/AllocatedExpense/SummaryTransformerByCategory.php index 46280ccc..b1b94780 100644 --- a/app/ItemType/AllocatedExpense/SummaryTransformerByCategory.php +++ b/app/ItemType/AllocatedExpense/SummaryTransformerByCategory.php @@ -7,7 +7,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class SummaryTransformerByCategory extends Transformer diff --git a/app/ItemType/AllocatedExpense/SummaryTransformerByMonth.php b/app/ItemType/AllocatedExpense/SummaryTransformerByMonth.php index 501f7605..c7a12609 100644 --- a/app/ItemType/AllocatedExpense/SummaryTransformerByMonth.php +++ b/app/ItemType/AllocatedExpense/SummaryTransformerByMonth.php @@ -7,7 +7,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class SummaryTransformerByMonth extends Transformer diff --git a/app/ItemType/AllocatedExpense/SummaryTransformerByResource.php b/app/ItemType/AllocatedExpense/SummaryTransformerByResource.php index f12cafde..53eb8d7e 100644 --- a/app/ItemType/AllocatedExpense/SummaryTransformerByResource.php +++ b/app/ItemType/AllocatedExpense/SummaryTransformerByResource.php @@ -7,7 +7,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class SummaryTransformerByResource extends Transformer diff --git a/app/ItemType/AllocatedExpense/SummaryTransformerBySubcategory.php b/app/ItemType/AllocatedExpense/SummaryTransformerBySubcategory.php index 92d4c6a3..0d963721 100644 --- a/app/ItemType/AllocatedExpense/SummaryTransformerBySubcategory.php +++ b/app/ItemType/AllocatedExpense/SummaryTransformerBySubcategory.php @@ -7,7 +7,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class SummaryTransformerBySubcategory extends Transformer diff --git a/app/ItemType/AllocatedExpense/SummaryTransformerByYear.php b/app/ItemType/AllocatedExpense/SummaryTransformerByYear.php index 40b7e0ec..9c6ec84f 100644 --- a/app/ItemType/AllocatedExpense/SummaryTransformerByYear.php +++ b/app/ItemType/AllocatedExpense/SummaryTransformerByYear.php @@ -7,7 +7,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class SummaryTransformerByYear extends Transformer diff --git a/app/ItemType/AllocatedExpense/Transformer.php b/app/ItemType/AllocatedExpense/Transformer.php index 41629114..5300d6ab 100644 --- a/app/ItemType/AllocatedExpense/Transformer.php +++ b/app/ItemType/AllocatedExpense/Transformer.php @@ -7,7 +7,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Transformer extends BaseTransformer diff --git a/app/ItemType/AllocatedExpense/Validator.php b/app/ItemType/AllocatedExpense/Validator.php index e946b548..0b2e12f8 100644 --- a/app/ItemType/AllocatedExpense/Validator.php +++ b/app/ItemType/AllocatedExpense/Validator.php @@ -8,7 +8,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Validator extends BaseValidator diff --git a/app/ItemType/Game/Model.php b/app/ItemType/Game/Model.php index 3a54f108..8d7438ab 100644 --- a/app/ItemType/Game/Model.php +++ b/app/ItemType/Game/Model.php @@ -11,7 +11,7 @@ /** * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Model extends LaravelModel diff --git a/app/ItemType/Game/ResourceTypeModel.php b/app/ItemType/Game/ResourceTypeModel.php index e461a5c5..3df02f80 100644 --- a/app/ItemType/Game/ResourceTypeModel.php +++ b/app/ItemType/Game/ResourceTypeModel.php @@ -10,7 +10,7 @@ /** * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ResourceTypeModel extends LaravelModel diff --git a/app/ItemType/Game/ResourceTypeTransformer.php b/app/ItemType/Game/ResourceTypeTransformer.php index a67f1097..1a2b9120 100644 --- a/app/ItemType/Game/ResourceTypeTransformer.php +++ b/app/ItemType/Game/ResourceTypeTransformer.php @@ -7,7 +7,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ResourceTypeTransformer extends BaseTransformer diff --git a/app/ItemType/Game/SummaryModel.php b/app/ItemType/Game/SummaryModel.php index c136cf1c..4cc3e087 100644 --- a/app/ItemType/Game/SummaryModel.php +++ b/app/ItemType/Game/SummaryModel.php @@ -10,7 +10,7 @@ /** * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class SummaryModel extends LaravelModel diff --git a/app/ItemType/Game/SummaryResourceTypeModel.php b/app/ItemType/Game/SummaryResourceTypeModel.php index 9fa815ea..bf3b403b 100644 --- a/app/ItemType/Game/SummaryResourceTypeModel.php +++ b/app/ItemType/Game/SummaryResourceTypeModel.php @@ -9,7 +9,7 @@ /** * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class SummaryResourceTypeModel extends LaravelModel diff --git a/app/ItemType/Game/SummaryTransformer.php b/app/ItemType/Game/SummaryTransformer.php index f9d6f94b..c5ff0cf0 100644 --- a/app/ItemType/Game/SummaryTransformer.php +++ b/app/ItemType/Game/SummaryTransformer.php @@ -7,7 +7,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class SummaryTransformer extends Transformer diff --git a/app/ItemType/Game/SummaryTransformerByResource.php b/app/ItemType/Game/SummaryTransformerByResource.php index 3cd9bfe5..4451a878 100644 --- a/app/ItemType/Game/SummaryTransformerByResource.php +++ b/app/ItemType/Game/SummaryTransformerByResource.php @@ -7,7 +7,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class SummaryTransformerByResource extends Transformer diff --git a/app/ItemType/Game/Transformer.php b/app/ItemType/Game/Transformer.php index 3e2e00f4..e3c9aa05 100644 --- a/app/ItemType/Game/Transformer.php +++ b/app/ItemType/Game/Transformer.php @@ -7,7 +7,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Transformer extends BaseTransformer diff --git a/app/ItemType/Game/Validator.php b/app/ItemType/Game/Validator.php index 741069c4..ea11a14d 100644 --- a/app/ItemType/Game/Validator.php +++ b/app/ItemType/Game/Validator.php @@ -9,7 +9,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Validator extends BaseValidator diff --git a/app/ItemType/SimpleExpense/Model.php b/app/ItemType/SimpleExpense/Model.php index a01a2112..c60ca663 100644 --- a/app/ItemType/SimpleExpense/Model.php +++ b/app/ItemType/SimpleExpense/Model.php @@ -12,7 +12,7 @@ /** * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Model extends LaravelModel diff --git a/app/ItemType/SimpleExpense/ResourceTypeModel.php b/app/ItemType/SimpleExpense/ResourceTypeModel.php index a7f2a0e9..04b5b6d1 100644 --- a/app/ItemType/SimpleExpense/ResourceTypeModel.php +++ b/app/ItemType/SimpleExpense/ResourceTypeModel.php @@ -11,7 +11,7 @@ /** * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ResourceTypeModel extends LaravelModel diff --git a/app/ItemType/SimpleExpense/ResourceTypeTransformer.php b/app/ItemType/SimpleExpense/ResourceTypeTransformer.php index ab3b56a9..0b1388c0 100644 --- a/app/ItemType/SimpleExpense/ResourceTypeTransformer.php +++ b/app/ItemType/SimpleExpense/ResourceTypeTransformer.php @@ -7,7 +7,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ResourceTypeTransformer extends BaseTransformer diff --git a/app/ItemType/SimpleExpense/SummaryModel.php b/app/ItemType/SimpleExpense/SummaryModel.php index 7cc1ee56..ce991150 100644 --- a/app/ItemType/SimpleExpense/SummaryModel.php +++ b/app/ItemType/SimpleExpense/SummaryModel.php @@ -10,7 +10,7 @@ /** * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class SummaryModel extends LaravelModel diff --git a/app/ItemType/SimpleExpense/SummaryResourceTypeModel.php b/app/ItemType/SimpleExpense/SummaryResourceTypeModel.php index 91a20b97..780fe75b 100644 --- a/app/ItemType/SimpleExpense/SummaryResourceTypeModel.php +++ b/app/ItemType/SimpleExpense/SummaryResourceTypeModel.php @@ -9,7 +9,7 @@ /** * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class SummaryResourceTypeModel extends LaravelModel diff --git a/app/ItemType/SimpleExpense/SummaryTransformer.php b/app/ItemType/SimpleExpense/SummaryTransformer.php index e07d51a4..8d7ebe12 100644 --- a/app/ItemType/SimpleExpense/SummaryTransformer.php +++ b/app/ItemType/SimpleExpense/SummaryTransformer.php @@ -7,7 +7,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class SummaryTransformer extends Transformer diff --git a/app/ItemType/SimpleExpense/SummaryTransformerByCategory.php b/app/ItemType/SimpleExpense/SummaryTransformerByCategory.php index 1333a197..bd0579eb 100644 --- a/app/ItemType/SimpleExpense/SummaryTransformerByCategory.php +++ b/app/ItemType/SimpleExpense/SummaryTransformerByCategory.php @@ -7,7 +7,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class SummaryTransformerByCategory extends Transformer diff --git a/app/ItemType/SimpleExpense/SummaryTransformerByResource.php b/app/ItemType/SimpleExpense/SummaryTransformerByResource.php index 86ead82b..ebce902a 100644 --- a/app/ItemType/SimpleExpense/SummaryTransformerByResource.php +++ b/app/ItemType/SimpleExpense/SummaryTransformerByResource.php @@ -7,7 +7,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class SummaryTransformerByResource extends Transformer diff --git a/app/ItemType/SimpleExpense/SummaryTransformerBySubcategory.php b/app/ItemType/SimpleExpense/SummaryTransformerBySubcategory.php index c5f0e035..4d6ccd06 100644 --- a/app/ItemType/SimpleExpense/SummaryTransformerBySubcategory.php +++ b/app/ItemType/SimpleExpense/SummaryTransformerBySubcategory.php @@ -7,7 +7,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class SummaryTransformerBySubcategory extends Transformer diff --git a/app/ItemType/SimpleExpense/Transformer.php b/app/ItemType/SimpleExpense/Transformer.php index 27477e8e..18574a6d 100644 --- a/app/ItemType/SimpleExpense/Transformer.php +++ b/app/ItemType/SimpleExpense/Transformer.php @@ -7,7 +7,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Transformer extends BaseTransformer diff --git a/app/ItemType/SimpleExpense/Validator.php b/app/ItemType/SimpleExpense/Validator.php index ef134db6..aca8a89d 100644 --- a/app/ItemType/SimpleExpense/Validator.php +++ b/app/ItemType/SimpleExpense/Validator.php @@ -8,7 +8,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Validator extends BaseValidator diff --git a/app/ItemType/SimpleItem/Model.php b/app/ItemType/SimpleItem/Model.php index d6c5e5e1..20df82a4 100644 --- a/app/ItemType/SimpleItem/Model.php +++ b/app/ItemType/SimpleItem/Model.php @@ -10,7 +10,7 @@ /** * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Model extends LaravelModel diff --git a/app/ItemType/SimpleItem/ResourceTypeModel.php b/app/ItemType/SimpleItem/ResourceTypeModel.php index d5deca3c..3a9dd541 100644 --- a/app/ItemType/SimpleItem/ResourceTypeModel.php +++ b/app/ItemType/SimpleItem/ResourceTypeModel.php @@ -10,7 +10,7 @@ /** * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ResourceTypeModel extends LaravelModel diff --git a/app/ItemType/SimpleItem/ResourceTypeTransformer.php b/app/ItemType/SimpleItem/ResourceTypeTransformer.php index dd41fbf0..9365ae07 100644 --- a/app/ItemType/SimpleItem/ResourceTypeTransformer.php +++ b/app/ItemType/SimpleItem/ResourceTypeTransformer.php @@ -7,7 +7,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ResourceTypeTransformer extends BaseTransformer diff --git a/app/ItemType/SimpleItem/SummaryModel.php b/app/ItemType/SimpleItem/SummaryModel.php index 8601f35e..e015ffe4 100644 --- a/app/ItemType/SimpleItem/SummaryModel.php +++ b/app/ItemType/SimpleItem/SummaryModel.php @@ -10,7 +10,7 @@ /** * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class SummaryModel extends LaravelModel diff --git a/app/ItemType/SimpleItem/SummaryResourceTypeModel.php b/app/ItemType/SimpleItem/SummaryResourceTypeModel.php index 3aa4f3af..e05f1a95 100644 --- a/app/ItemType/SimpleItem/SummaryResourceTypeModel.php +++ b/app/ItemType/SimpleItem/SummaryResourceTypeModel.php @@ -9,7 +9,7 @@ /** * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class SummaryResourceTypeModel extends LaravelModel diff --git a/app/ItemType/SimpleItem/SummaryTransformer.php b/app/ItemType/SimpleItem/SummaryTransformer.php index abe61d8a..4154723e 100644 --- a/app/ItemType/SimpleItem/SummaryTransformer.php +++ b/app/ItemType/SimpleItem/SummaryTransformer.php @@ -7,7 +7,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class SummaryTransformer extends Transformer diff --git a/app/ItemType/SimpleItem/SummaryTransformerByResource.php b/app/ItemType/SimpleItem/SummaryTransformerByResource.php index 4d1081f1..891b1f0e 100644 --- a/app/ItemType/SimpleItem/SummaryTransformerByResource.php +++ b/app/ItemType/SimpleItem/SummaryTransformerByResource.php @@ -7,7 +7,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class SummaryTransformerByResource extends Transformer diff --git a/app/ItemType/SimpleItem/Transformer.php b/app/ItemType/SimpleItem/Transformer.php index caf0a660..94315ac3 100644 --- a/app/ItemType/SimpleItem/Transformer.php +++ b/app/ItemType/SimpleItem/Transformer.php @@ -7,7 +7,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Transformer extends BaseTransformer diff --git a/app/ItemType/SimpleItem/Validator.php b/app/ItemType/SimpleItem/Validator.php index 6cb39ce6..20bfc3a4 100644 --- a/app/ItemType/SimpleItem/Validator.php +++ b/app/ItemType/SimpleItem/Validator.php @@ -8,7 +8,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Validator extends BaseValidator diff --git a/app/Jobs/ClearCache.php b/app/Jobs/ClearCache.php index 005b0d47..8904050a 100644 --- a/app/Jobs/ClearCache.php +++ b/app/Jobs/ClearCache.php @@ -18,7 +18,7 @@ * Clear the requested cache keys * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ClearCache implements ShouldQueue diff --git a/app/Method/DeleteRequest.php b/app/Method/DeleteRequest.php index 04d78201..aa0105d2 100644 --- a/app/Method/DeleteRequest.php +++ b/app/Method/DeleteRequest.php @@ -5,7 +5,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class DeleteRequest extends Method diff --git a/app/Method/GetRequest.php b/app/Method/GetRequest.php index de95a4c5..0d605a83 100644 --- a/app/Method/GetRequest.php +++ b/app/Method/GetRequest.php @@ -5,7 +5,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class GetRequest extends Method diff --git a/app/Method/Method.php b/app/Method/Method.php index 4db35f47..f206d2c8 100644 --- a/app/Method/Method.php +++ b/app/Method/Method.php @@ -7,7 +7,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ abstract class Method diff --git a/app/Method/PatchRequest.php b/app/Method/PatchRequest.php index 66c66f9e..9dc8cde0 100644 --- a/app/Method/PatchRequest.php +++ b/app/Method/PatchRequest.php @@ -8,7 +8,7 @@ * a single HTTP Verb, in this case PATCH * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class PatchRequest extends Method diff --git a/app/Method/PostRequest.php b/app/Method/PostRequest.php index 71ac5a98..707d0748 100644 --- a/app/Method/PostRequest.php +++ b/app/Method/PostRequest.php @@ -5,7 +5,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class PostRequest extends Method diff --git a/app/Models/Cache.php b/app/Models/Cache.php index 0711e953..c994f25d 100644 --- a/app/Models/Cache.php +++ b/app/Models/Cache.php @@ -12,7 +12,7 @@ * * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Cache extends Model diff --git a/app/Models/Category.php b/app/Models/Category.php index e93d112e..a126510e 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -13,7 +13,7 @@ * * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Category extends Model diff --git a/app/Models/Clause.php b/app/Models/Clause.php index 7a15cca1..1489ae3c 100644 --- a/app/Models/Clause.php +++ b/app/Models/Clause.php @@ -9,7 +9,7 @@ /** * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Clause diff --git a/app/Models/Currency.php b/app/Models/Currency.php index 175fc737..a9413d92 100644 --- a/app/Models/Currency.php +++ b/app/Models/Currency.php @@ -9,7 +9,7 @@ /** * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Currency extends Model diff --git a/app/Models/EntityLimits.php b/app/Models/EntityLimits.php index 76398aa7..7c3d2b75 100644 --- a/app/Models/EntityLimits.php +++ b/app/Models/EntityLimits.php @@ -11,7 +11,7 @@ * * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class EntityLimits extends Model diff --git a/app/Models/ErrorLog.php b/app/Models/ErrorLog.php index 9caa936e..64d0a8d7 100644 --- a/app/Models/ErrorLog.php +++ b/app/Models/ErrorLog.php @@ -11,7 +11,7 @@ * * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ErrorLog extends Model diff --git a/app/Models/Item.php b/app/Models/Item.php index 600fa8a7..cc7e9218 100644 --- a/app/Models/Item.php +++ b/app/Models/Item.php @@ -11,7 +11,7 @@ * * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Item extends Model diff --git a/app/Models/ItemCategory.php b/app/Models/ItemCategory.php index 45c62c0d..98957cd3 100644 --- a/app/Models/ItemCategory.php +++ b/app/Models/ItemCategory.php @@ -11,7 +11,7 @@ * * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ItemCategory extends Model diff --git a/app/Models/ItemPartialTransfer.php b/app/Models/ItemPartialTransfer.php index 25bb9f90..87c496ca 100644 --- a/app/Models/ItemPartialTransfer.php +++ b/app/Models/ItemPartialTransfer.php @@ -11,7 +11,7 @@ * * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ItemPartialTransfer extends Model diff --git a/app/Models/ItemSubcategory.php b/app/Models/ItemSubcategory.php index b07ac6c7..913ee241 100644 --- a/app/Models/ItemSubcategory.php +++ b/app/Models/ItemSubcategory.php @@ -11,7 +11,7 @@ * * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ItemSubcategory extends Model diff --git a/app/Models/ItemSubtype.php b/app/Models/ItemSubtype.php index 30d1f011..acb870fe 100644 --- a/app/Models/ItemSubtype.php +++ b/app/Models/ItemSubtype.php @@ -9,7 +9,7 @@ /** * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ItemSubtype extends Model diff --git a/app/Models/ItemTransfer.php b/app/Models/ItemTransfer.php index fb451b6d..019f5108 100644 --- a/app/Models/ItemTransfer.php +++ b/app/Models/ItemTransfer.php @@ -11,7 +11,7 @@ * * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ItemTransfer extends Model diff --git a/app/Models/ItemType.php b/app/Models/ItemType.php index 40893af0..14e63d58 100644 --- a/app/Models/ItemType.php +++ b/app/Models/ItemType.php @@ -11,7 +11,7 @@ * * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ItemType extends Model diff --git a/app/Models/PermittedUser.php b/app/Models/PermittedUser.php index f2cd1fb1..fd4eb0da 100644 --- a/app/Models/PermittedUser.php +++ b/app/Models/PermittedUser.php @@ -11,7 +11,7 @@ * * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class PermittedUser extends Model diff --git a/app/Models/Queue.php b/app/Models/Queue.php index bb7a8d88..7895fd40 100644 --- a/app/Models/Queue.php +++ b/app/Models/Queue.php @@ -9,7 +9,7 @@ /** * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Queue extends Model diff --git a/app/Models/RequestErrorLog.php b/app/Models/RequestErrorLog.php index 41538a7c..c0e93d83 100644 --- a/app/Models/RequestErrorLog.php +++ b/app/Models/RequestErrorLog.php @@ -11,7 +11,7 @@ * * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class RequestErrorLog extends Model diff --git a/app/Models/Resource.php b/app/Models/Resource.php index 48ceeea1..7ae9e098 100644 --- a/app/Models/Resource.php +++ b/app/Models/Resource.php @@ -12,7 +12,7 @@ * * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Resource extends Model diff --git a/app/Models/ResourceAccess.php b/app/Models/ResourceAccess.php index f0b69c0e..f816a496 100644 --- a/app/Models/ResourceAccess.php +++ b/app/Models/ResourceAccess.php @@ -9,7 +9,7 @@ /** * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ResourceAccess extends Model diff --git a/app/Models/ResourceItemSubtype.php b/app/Models/ResourceItemSubtype.php index fafaba89..c6bcb81b 100644 --- a/app/Models/ResourceItemSubtype.php +++ b/app/Models/ResourceItemSubtype.php @@ -9,7 +9,7 @@ /** * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ResourceItemSubtype extends Model diff --git a/app/Models/ResourceType.php b/app/Models/ResourceType.php index 621c0637..4c6b48ad 100644 --- a/app/Models/ResourceType.php +++ b/app/Models/ResourceType.php @@ -12,7 +12,7 @@ * * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ResourceType extends Model diff --git a/app/Models/ResourceTypeItem.php b/app/Models/ResourceTypeItem.php index 04332921..a13e5d51 100644 --- a/app/Models/ResourceTypeItem.php +++ b/app/Models/ResourceTypeItem.php @@ -13,7 +13,7 @@ * * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ResourceTypeItem extends Model diff --git a/app/Models/ResourceTypeItemType.php b/app/Models/ResourceTypeItemType.php index 86df27a8..feab4e05 100644 --- a/app/Models/ResourceTypeItemType.php +++ b/app/Models/ResourceTypeItemType.php @@ -11,7 +11,7 @@ * * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ResourceTypeItemType extends Model diff --git a/app/Models/Subcategory.php b/app/Models/Subcategory.php index 9f6719c3..d1a0df22 100644 --- a/app/Models/Subcategory.php +++ b/app/Models/Subcategory.php @@ -12,7 +12,7 @@ * * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Subcategory extends Model diff --git a/app/Models/Summary/Category.php b/app/Models/Summary/Category.php index c471e992..ca7062de 100644 --- a/app/Models/Summary/Category.php +++ b/app/Models/Summary/Category.php @@ -12,7 +12,7 @@ * * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Category extends Model diff --git a/app/Models/Summary/Resource.php b/app/Models/Summary/Resource.php index e22f4e4c..d841a68b 100644 --- a/app/Models/Summary/Resource.php +++ b/app/Models/Summary/Resource.php @@ -12,7 +12,7 @@ * * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Resource extends Model diff --git a/app/Models/Summary/ResourceType.php b/app/Models/Summary/ResourceType.php index 37520c47..47bfd7de 100644 --- a/app/Models/Summary/ResourceType.php +++ b/app/Models/Summary/ResourceType.php @@ -12,7 +12,7 @@ * * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ResourceType extends Model diff --git a/app/Models/Summary/Subcategory.php b/app/Models/Summary/Subcategory.php index 929c6eb4..9f4f099b 100644 --- a/app/Models/Summary/Subcategory.php +++ b/app/Models/Summary/Subcategory.php @@ -12,7 +12,7 @@ * * @mixin QueryBuilder * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Subcategory extends Model diff --git a/app/Request/BodyValidation.php b/app/Request/BodyValidation.php index f0d95774..14bf8f10 100644 --- a/app/Request/BodyValidation.php +++ b/app/Request/BodyValidation.php @@ -14,7 +14,7 @@ * sense. * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class BodyValidation diff --git a/app/Request/Hash.php b/app/Request/Hash.php index 7f33b322..edf6a956 100644 --- a/app/Request/Hash.php +++ b/app/Request/Hash.php @@ -14,7 +14,7 @@ * sense. * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Hash diff --git a/app/Request/Parameter/Filter.php b/app/Request/Parameter/Filter.php index 815120c6..8a5e339b 100644 --- a/app/Request/Parameter/Filter.php +++ b/app/Request/Parameter/Filter.php @@ -10,7 +10,7 @@ * Fetch and validate any filter parameters * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Filter diff --git a/app/Request/Parameter/Request.php b/app/Request/Parameter/Request.php index cd64ed1d..c00f823b 100644 --- a/app/Request/Parameter/Request.php +++ b/app/Request/Parameter/Request.php @@ -15,7 +15,7 @@ * ignore any invalid parameters * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Request diff --git a/app/Request/Parameter/Search.php b/app/Request/Parameter/Search.php index 257120d8..7d13b669 100644 --- a/app/Request/Parameter/Search.php +++ b/app/Request/Parameter/Search.php @@ -7,7 +7,7 @@ * Fetch and validate any search parameters * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Search diff --git a/app/Request/Parameter/Sort.php b/app/Request/Parameter/Sort.php index da22fb82..cd17cc4a 100644 --- a/app/Request/Parameter/Sort.php +++ b/app/Request/Parameter/Sort.php @@ -7,7 +7,7 @@ * Fetch and validate any sort parameters * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Sort diff --git a/app/Request/Route/Validate/Currency.php b/app/Request/Route/Validate/Currency.php index 0a6c6f52..12f0e987 100644 --- a/app/Request/Route/Validate/Currency.php +++ b/app/Request/Route/Validate/Currency.php @@ -9,7 +9,7 @@ * Validate the route params to a currency * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Currency diff --git a/app/Request/Route/Validate/ItemSubtype.php b/app/Request/Route/Validate/ItemSubtype.php index f8013a8b..0b4eb77e 100644 --- a/app/Request/Route/Validate/ItemSubtype.php +++ b/app/Request/Route/Validate/ItemSubtype.php @@ -9,7 +9,7 @@ * Validate the route params to an item subtype * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ItemSubtype diff --git a/app/Request/Route/Validate/ItemType.php b/app/Request/Route/Validate/ItemType.php index b378faea..a7a43c60 100644 --- a/app/Request/Route/Validate/ItemType.php +++ b/app/Request/Route/Validate/ItemType.php @@ -9,7 +9,7 @@ * Validate the route params to an item type * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ItemType diff --git a/app/Request/Route/Validate/Queue.php b/app/Request/Route/Validate/Queue.php index 5e432b91..6582b3fc 100644 --- a/app/Request/Route/Validate/Queue.php +++ b/app/Request/Route/Validate/Queue.php @@ -7,7 +7,7 @@ /** * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Queue diff --git a/app/Request/Validate/Boolean.php b/app/Request/Validate/Boolean.php index 77f62c03..881f003e 100644 --- a/app/Request/Validate/Boolean.php +++ b/app/Request/Validate/Boolean.php @@ -7,7 +7,7 @@ * Small boolean validation utility * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Boolean diff --git a/app/Request/Validate/Category.php b/app/Request/Validate/Category.php index b944a979..3dadd508 100644 --- a/app/Request/Validate/Category.php +++ b/app/Request/Validate/Category.php @@ -11,7 +11,7 @@ * Validation helper class for categories, returns the generated validator objects * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Category extends BaseValidator diff --git a/app/Request/Validate/ItemCategory.php b/app/Request/Validate/ItemCategory.php index dd7bf8f3..e782546c 100644 --- a/app/Request/Validate/ItemCategory.php +++ b/app/Request/Validate/ItemCategory.php @@ -11,7 +11,7 @@ * Validation helper class for item category, returns the generated validator objects * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ItemCategory extends BaseValidator diff --git a/app/Request/Validate/ItemPartialTransfer.php b/app/Request/Validate/ItemPartialTransfer.php index d5ef7547..6408b593 100644 --- a/app/Request/Validate/ItemPartialTransfer.php +++ b/app/Request/Validate/ItemPartialTransfer.php @@ -13,7 +13,7 @@ * objects * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ItemPartialTransfer extends BaseValidator diff --git a/app/Request/Validate/ItemSubcategory.php b/app/Request/Validate/ItemSubcategory.php index 12945ba7..6a41f547 100644 --- a/app/Request/Validate/ItemSubcategory.php +++ b/app/Request/Validate/ItemSubcategory.php @@ -11,7 +11,7 @@ * Validation helper class for item sub category, returns the generated validator objects * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ItemSubcategory extends BaseValidator diff --git a/app/Request/Validate/ItemTransfer.php b/app/Request/Validate/ItemTransfer.php index 40a02e06..3b486f8c 100644 --- a/app/Request/Validate/ItemTransfer.php +++ b/app/Request/Validate/ItemTransfer.php @@ -12,7 +12,7 @@ * objects * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ItemTransfer extends BaseValidator diff --git a/app/Request/Validate/RequestErrorLog.php b/app/Request/Validate/RequestErrorLog.php index 0580dbed..3892a7a8 100644 --- a/app/Request/Validate/RequestErrorLog.php +++ b/app/Request/Validate/RequestErrorLog.php @@ -12,7 +12,7 @@ * object * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class RequestErrorLog extends BaseValidator diff --git a/app/Request/Validate/Resource.php b/app/Request/Validate/Resource.php index 1c3b95b9..07aee5d5 100644 --- a/app/Request/Validate/Resource.php +++ b/app/Request/Validate/Resource.php @@ -12,7 +12,7 @@ * Validation helper class for resources, returns the generated validator objects * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Resource extends BaseValidator diff --git a/app/Request/Validate/ResourceType.php b/app/Request/Validate/ResourceType.php index be2bfe2f..f4074cae 100644 --- a/app/Request/Validate/ResourceType.php +++ b/app/Request/Validate/ResourceType.php @@ -12,7 +12,7 @@ * Validation helper class for resource types, returns the generated validator objects * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ResourceType extends BaseValidator diff --git a/app/Request/Validate/Subcategory.php b/app/Request/Validate/Subcategory.php index db088843..b0bf9739 100644 --- a/app/Request/Validate/Subcategory.php +++ b/app/Request/Validate/Subcategory.php @@ -12,7 +12,7 @@ * validator objects * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Subcategory extends BaseValidator diff --git a/app/Request/Validate/Validator.php b/app/Request/Validate/Validator.php index 8450ac90..872ee989 100644 --- a/app/Request/Validate/Validator.php +++ b/app/Request/Validate/Validator.php @@ -12,7 +12,7 @@ * Base validator class, sets up the interface and includes helper methods * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ abstract class Validator diff --git a/app/Response/Header.php b/app/Response/Header.php index 766b1733..4391318f 100644 --- a/app/Response/Header.php +++ b/app/Response/Header.php @@ -11,7 +11,7 @@ * sense. * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Header diff --git a/app/Response/Pagination.php b/app/Response/Pagination.php index 93f57703..c3f399ce 100644 --- a/app/Response/Pagination.php +++ b/app/Response/Pagination.php @@ -12,7 +12,7 @@ * Generate the pagination URIs based on all the request parameters * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Pagination diff --git a/app/Response/Responses.php b/app/Response/Responses.php index c9ebf805..470303cd 100644 --- a/app/Response/Responses.php +++ b/app/Response/Responses.php @@ -17,7 +17,7 @@ * sense. * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Responses diff --git a/app/Transformers/Category.php b/app/Transformers/Category.php index d0ff9a54..6c471854 100644 --- a/app/Transformers/Category.php +++ b/app/Transformers/Category.php @@ -7,7 +7,7 @@ * Transform the data from our queries into the format we want to display * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Category extends Transformer diff --git a/app/Transformers/Currency.php b/app/Transformers/Currency.php index caa41ee7..086ed8f3 100644 --- a/app/Transformers/Currency.php +++ b/app/Transformers/Currency.php @@ -7,7 +7,7 @@ * Transform the data from our queries into the format we want to display * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Currency extends Transformer diff --git a/app/Transformers/ItemCategory.php b/app/Transformers/ItemCategory.php index d149d60a..19cdb034 100644 --- a/app/Transformers/ItemCategory.php +++ b/app/Transformers/ItemCategory.php @@ -7,7 +7,7 @@ * Transform the data from our queries into the format we want to display * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ItemCategory extends Transformer diff --git a/app/Transformers/ItemPartialTransfer.php b/app/Transformers/ItemPartialTransfer.php index 8225aef6..0e3ca554 100644 --- a/app/Transformers/ItemPartialTransfer.php +++ b/app/Transformers/ItemPartialTransfer.php @@ -7,7 +7,7 @@ * Transform the data from our queries into the format we want to display * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ItemPartialTransfer extends Transformer diff --git a/app/Transformers/ItemSubcategory.php b/app/Transformers/ItemSubcategory.php index e0d7194d..cdced15c 100644 --- a/app/Transformers/ItemSubcategory.php +++ b/app/Transformers/ItemSubcategory.php @@ -7,7 +7,7 @@ * Transform the data from our queries into the format we want to display * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ItemSubcategory extends Transformer diff --git a/app/Transformers/ItemSubtype.php b/app/Transformers/ItemSubtype.php index 6313e0f3..46bcca18 100644 --- a/app/Transformers/ItemSubtype.php +++ b/app/Transformers/ItemSubtype.php @@ -7,7 +7,7 @@ * Transform the data from our queries into the format we want to display * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ItemSubtype extends Transformer diff --git a/app/Transformers/ItemTransfer.php b/app/Transformers/ItemTransfer.php index a91d3cc3..1915154a 100644 --- a/app/Transformers/ItemTransfer.php +++ b/app/Transformers/ItemTransfer.php @@ -7,7 +7,7 @@ * Transform the data from our queries into the format we want to display * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ItemTransfer extends Transformer diff --git a/app/Transformers/ItemType.php b/app/Transformers/ItemType.php index ad8db543..900ade08 100644 --- a/app/Transformers/ItemType.php +++ b/app/Transformers/ItemType.php @@ -7,7 +7,7 @@ * Transform the data from our queries into the format we want to display * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ItemType extends Transformer diff --git a/app/Transformers/PermittedUser.php b/app/Transformers/PermittedUser.php index 16a18c10..438a6f67 100644 --- a/app/Transformers/PermittedUser.php +++ b/app/Transformers/PermittedUser.php @@ -7,7 +7,7 @@ * Transform the data from our queries into the format we want to display * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class PermittedUser extends Transformer diff --git a/app/Transformers/Queue.php b/app/Transformers/Queue.php index b3cd0b0c..87168664 100644 --- a/app/Transformers/Queue.php +++ b/app/Transformers/Queue.php @@ -7,7 +7,7 @@ * Transform the data from our queries into the format we want to display * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Queue extends Transformer diff --git a/app/Transformers/RequestErrorLog.php b/app/Transformers/RequestErrorLog.php index bfb85287..79863890 100644 --- a/app/Transformers/RequestErrorLog.php +++ b/app/Transformers/RequestErrorLog.php @@ -7,7 +7,7 @@ * Transform the data from our queries into the format we want to display * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class RequestErrorLog extends Transformer diff --git a/app/Transformers/Resource.php b/app/Transformers/Resource.php index 09a99049..6cb9b755 100644 --- a/app/Transformers/Resource.php +++ b/app/Transformers/Resource.php @@ -7,7 +7,7 @@ * Transform the data from our queries into the format we want to display * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Resource extends Transformer diff --git a/app/Transformers/ResourceType.php b/app/Transformers/ResourceType.php index ea3ea467..8849f02a 100644 --- a/app/Transformers/ResourceType.php +++ b/app/Transformers/ResourceType.php @@ -9,7 +9,7 @@ * Transform the data from our queries into the format we want to display * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ResourceType extends Transformer diff --git a/app/Transformers/ResourceTypeItem.php b/app/Transformers/ResourceTypeItem.php index f16222a7..014d33a9 100644 --- a/app/Transformers/ResourceTypeItem.php +++ b/app/Transformers/ResourceTypeItem.php @@ -7,7 +7,7 @@ * Transform the data from our queries into the format we want to display * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ResourceTypeItem extends Transformer diff --git a/app/Transformers/Subcategory.php b/app/Transformers/Subcategory.php index 8da991c7..fb2f1917 100644 --- a/app/Transformers/Subcategory.php +++ b/app/Transformers/Subcategory.php @@ -7,7 +7,7 @@ * Transform the data from our queries into the format we want to display * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class Subcategory extends Transformer diff --git a/app/Transformers/Transformer.php b/app/Transformers/Transformer.php index ac4dc0f8..4e9fbe44 100644 --- a/app/Transformers/Transformer.php +++ b/app/Transformers/Transformer.php @@ -10,7 +10,7 @@ * a useful structure and then the required format * * @author Dean Blackborough - * @copyright Dean Blackborough 2018-2021 + * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ abstract class Transformer diff --git a/composer.lock b/composer.lock index 14022f0d..26d16c15 100644 --- a/composer.lock +++ b/composer.lock @@ -242,16 +242,16 @@ }, { "name": "doctrine/dbal", - "version": "2.13.5", + "version": "2.13.7", "source": { "type": "git", "url": "https://github.com/doctrine/dbal.git", - "reference": "d92ddb260547c2a7b650ff140f744eb6f395d8fc" + "reference": "6e22f6012b42d7932674857989fcf184e9e9b1c3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/dbal/zipball/d92ddb260547c2a7b650ff140f744eb6f395d8fc", - "reference": "d92ddb260547c2a7b650ff140f744eb6f395d8fc", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/6e22f6012b42d7932674857989fcf184e9e9b1c3", + "reference": "6e22f6012b42d7932674857989fcf184e9e9b1c3", "shasum": "" }, "require": { @@ -264,13 +264,13 @@ "require-dev": { "doctrine/coding-standard": "9.0.0", "jetbrains/phpstorm-stubs": "2021.1", - "phpstan/phpstan": "1.1.1", - "phpunit/phpunit": "^7.5.20|^8.5|9.5.10", + "phpstan/phpstan": "1.3.0", + "phpunit/phpunit": "^7.5.20|^8.5|9.5.11", "psalm/plugin-phpunit": "0.16.1", - "squizlabs/php_codesniffer": "3.6.1", + "squizlabs/php_codesniffer": "3.6.2", "symfony/cache": "^4.4", "symfony/console": "^2.0.5|^3.0|^4.0|^5.0", - "vimeo/psalm": "4.12.0" + "vimeo/psalm": "4.16.1" }, "suggest": { "symfony/console": "For helpful console commands such as SQL execution and import of files." @@ -331,7 +331,7 @@ ], "support": { "issues": "https://github.com/doctrine/dbal/issues", - "source": "https://github.com/doctrine/dbal/tree/2.13.5" + "source": "https://github.com/doctrine/dbal/tree/2.13.7" }, "funding": [ { @@ -347,7 +347,7 @@ "type": "tidelift" } ], - "time": "2021-11-11T16:27:36+00:00" + "time": "2022-01-06T09:08:04+00:00" }, { "name": "doctrine/deprecations", @@ -659,16 +659,16 @@ }, { "name": "dragonmantank/cron-expression", - "version": "v3.1.0", + "version": "v3.2.3", "source": { "type": "git", "url": "https://github.com/dragonmantank/cron-expression.git", - "reference": "7a8c6e56ab3ffcc538d05e8155bb42269abf1a0c" + "reference": "47c53bbb260d3c398fba9bfa9683dcf67add2579" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/dragonmantank/cron-expression/zipball/7a8c6e56ab3ffcc538d05e8155bb42269abf1a0c", - "reference": "7a8c6e56ab3ffcc538d05e8155bb42269abf1a0c", + "url": "https://api.github.com/repos/dragonmantank/cron-expression/zipball/47c53bbb260d3c398fba9bfa9683dcf67add2579", + "reference": "47c53bbb260d3c398fba9bfa9683dcf67add2579", "shasum": "" }, "require": { @@ -708,7 +708,7 @@ ], "support": { "issues": "https://github.com/dragonmantank/cron-expression/issues", - "source": "https://github.com/dragonmantank/cron-expression/tree/v3.1.0" + "source": "https://github.com/dragonmantank/cron-expression/tree/v3.2.3" }, "funding": [ { @@ -716,7 +716,7 @@ "type": "github" } ], - "time": "2020-11-24T19:55:57+00:00" + "time": "2022-01-06T05:35:07+00:00" }, { "name": "egulias/email-validator", @@ -846,16 +846,16 @@ }, { "name": "graham-campbell/result-type", - "version": "v1.0.3", + "version": "v1.0.4", "source": { "type": "git", "url": "https://github.com/GrahamCampbell/Result-Type.git", - "reference": "296c015dc30ec4322168c5ad3ee5cc11dae827ac" + "reference": "0690bde05318336c7221785f2a932467f98b64ca" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/296c015dc30ec4322168c5ad3ee5cc11dae827ac", - "reference": "296c015dc30ec4322168c5ad3ee5cc11dae827ac", + "url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/0690bde05318336c7221785f2a932467f98b64ca", + "reference": "0690bde05318336c7221785f2a932467f98b64ca", "shasum": "" }, "require": { @@ -878,7 +878,8 @@ "authors": [ { "name": "Graham Campbell", - "email": "hello@gjcampbell.co.uk" + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" } ], "description": "An Implementation Of The Result Type", @@ -891,7 +892,7 @@ ], "support": { "issues": "https://github.com/GrahamCampbell/Result-Type/issues", - "source": "https://github.com/GrahamCampbell/Result-Type/tree/v1.0.3" + "source": "https://github.com/GrahamCampbell/Result-Type/tree/v1.0.4" }, "funding": [ { @@ -903,20 +904,20 @@ "type": "tidelift" } ], - "time": "2021-10-17T19:48:54+00:00" + "time": "2021-11-21T21:41:47+00:00" }, { "name": "guzzlehttp/guzzle", - "version": "7.4.0", + "version": "7.4.1", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "868b3571a039f0ebc11ac8f344f4080babe2cb94" + "reference": "ee0a041b1760e6a53d2a39c8c34115adc2af2c79" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/868b3571a039f0ebc11ac8f344f4080babe2cb94", - "reference": "868b3571a039f0ebc11ac8f344f4080babe2cb94", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/ee0a041b1760e6a53d2a39c8c34115adc2af2c79", + "reference": "ee0a041b1760e6a53d2a39c8c34115adc2af2c79", "shasum": "" }, "require": { @@ -925,7 +926,7 @@ "guzzlehttp/psr7": "^1.8.3 || ^2.1", "php": "^7.2.5 || ^8.0", "psr/http-client": "^1.0", - "symfony/deprecation-contracts": "^2.2" + "symfony/deprecation-contracts": "^2.2 || ^3.0" }, "provide": { "psr/http-client-implementation": "1.0" @@ -1011,7 +1012,7 @@ ], "support": { "issues": "https://github.com/guzzle/guzzle/issues", - "source": "https://github.com/guzzle/guzzle/tree/7.4.0" + "source": "https://github.com/guzzle/guzzle/tree/7.4.1" }, "funding": [ { @@ -1027,7 +1028,7 @@ "type": "tidelift" } ], - "time": "2021-10-18T09:52:00+00:00" + "time": "2021-12-06T18:43:05+00:00" }, { "name": "guzzlehttp/promises", @@ -1300,16 +1301,16 @@ }, { "name": "laravel/framework", - "version": "v8.70.2", + "version": "v8.78.1", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "dec9524cd0f9fa35a6eb8e25d0b40f8bbc8ec225" + "reference": "16359b5ebafba6579b397d7505b082a6d1bb2e31" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/dec9524cd0f9fa35a6eb8e25d0b40f8bbc8ec225", - "reference": "dec9524cd0f9fa35a6eb8e25d0b40f8bbc8ec225", + "url": "https://api.github.com/repos/laravel/framework/zipball/16359b5ebafba6579b397d7505b082a6d1bb2e31", + "reference": "16359b5ebafba6579b397d7505b082a6d1bb2e31", "shasum": "" }, "require": { @@ -1327,19 +1328,19 @@ "opis/closure": "^3.6", "php": "^7.3|^8.0", "psr/container": "^1.0", - "psr/log": "^1.0 || ^2.0", + "psr/log": "^1.0|^2.0", "psr/simple-cache": "^1.0", "ramsey/uuid": "^4.2.2", "swiftmailer/swiftmailer": "^6.3", - "symfony/console": "^5.1.4", - "symfony/error-handler": "^5.1.4", - "symfony/finder": "^5.1.4", - "symfony/http-foundation": "^5.1.4", - "symfony/http-kernel": "^5.1.4", - "symfony/mime": "^5.1.4", - "symfony/process": "^5.1.4", - "symfony/routing": "^5.1.4", - "symfony/var-dumper": "^5.1.4", + "symfony/console": "^5.4", + "symfony/error-handler": "^5.4", + "symfony/finder": "^5.4", + "symfony/http-foundation": "^5.4", + "symfony/http-kernel": "^5.4", + "symfony/mime": "^5.4", + "symfony/process": "^5.4", + "symfony/routing": "^5.4", + "symfony/var-dumper": "^5.4", "tijsverkoyen/css-to-inline-styles": "^2.2.2", "vlucas/phpdotenv": "^5.2", "voku/portable-ascii": "^1.4.8" @@ -1386,21 +1387,21 @@ }, "require-dev": { "aws/aws-sdk-php": "^3.198.1", - "doctrine/dbal": "^2.13.3|^3.1.2", + "doctrine/dbal": "^2.13.3|^3.1.4", "filp/whoops": "^2.14.3", "guzzlehttp/guzzle": "^6.5.5|^7.0.1", "league/flysystem-cached-adapter": "^1.0", "mockery/mockery": "^1.4.4", - "orchestra/testbench-core": "^6.23", + "orchestra/testbench-core": "^6.27", "pda/pheanstalk": "^4.0", "phpunit/phpunit": "^8.5.19|^9.5.8", "predis/predis": "^1.1.9", - "symfony/cache": "^5.1.4" + "symfony/cache": "^5.4" }, "suggest": { "aws/aws-sdk-php": "Required to use the SQS queue driver, DynamoDb failed job storage and SES mail driver (^3.198.1).", "brianium/paratest": "Required to run tests in parallel (^6.0).", - "doctrine/dbal": "Required to rename columns and drop SQLite columns (^2.13.3|^3.1.2).", + "doctrine/dbal": "Required to rename columns and drop SQLite columns (^2.13.3|^3.1.4).", "ext-bcmath": "Required to use the multiple_of validation rule.", "ext-ftp": "Required to use the Flysystem FTP driver.", "ext-gd": "Required to use Illuminate\\Http\\Testing\\FileFactory::image().", @@ -1421,9 +1422,9 @@ "phpunit/phpunit": "Required to use assertions and run tests (^8.5.19|^9.5.8).", "predis/predis": "Required to use the predis connector (^1.1.9).", "psr/http-message": "Required to allow Storage::put to accept a StreamInterface (^1.0).", - "pusher/pusher-php-server": "Required to use the Pusher broadcast driver (^4.0|^5.0|^6.0).", - "symfony/cache": "Required to PSR-6 cache bridge (^5.1.4).", - "symfony/filesystem": "Required to enable support for relative symbolic links (^5.1.4).", + "pusher/pusher-php-server": "Required to use the Pusher broadcast driver (^4.0|^5.0|^6.0|^7.0).", + "symfony/cache": "Required to PSR-6 cache bridge (^5.4).", + "symfony/filesystem": "Required to enable support for relative symbolic links (^5.4).", "symfony/psr-http-message-bridge": "Required to use PSR-7 bridging features (^2.0).", "wildbit/swiftmailer-postmark": "Required to use Postmark mail driver (^3.0)." }, @@ -1468,7 +1469,7 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2021-11-09T22:48:33+00:00" + "time": "2022-01-05T14:52:50+00:00" }, { "name": "laravel/helpers", @@ -1528,16 +1529,16 @@ }, { "name": "laravel/sanctum", - "version": "v2.12.1", + "version": "v2.13.0", "source": { "type": "git", "url": "https://github.com/laravel/sanctum.git", - "reference": "e610647b04583ace6b30c8eb74cee0a866040420" + "reference": "b4c07d0014b78430a3c827064217f811f0708eaa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/sanctum/zipball/e610647b04583ace6b30c8eb74cee0a866040420", - "reference": "e610647b04583ace6b30c8eb74cee0a866040420", + "url": "https://api.github.com/repos/laravel/sanctum/zipball/b4c07d0014b78430a3c827064217f811f0708eaa", + "reference": "b4c07d0014b78430a3c827064217f811f0708eaa", "shasum": "" }, "require": { @@ -1588,20 +1589,20 @@ "issues": "https://github.com/laravel/sanctum/issues", "source": "https://github.com/laravel/sanctum" }, - "time": "2021-10-26T18:23:26+00:00" + "time": "2021-12-14T17:49:47+00:00" }, { "name": "laravel/serializable-closure", - "version": "v1.0.3", + "version": "v1.0.5", "source": { "type": "git", "url": "https://github.com/laravel/serializable-closure.git", - "reference": "6cfc678735f22ccedad761b8cae2bab14c3d8e5b" + "reference": "25de3be1bca1b17d52ff0dc02b646c667ac7266c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/6cfc678735f22ccedad761b8cae2bab14c3d8e5b", - "reference": "6cfc678735f22ccedad761b8cae2bab14c3d8e5b", + "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/25de3be1bca1b17d52ff0dc02b646c667ac7266c", + "reference": "25de3be1bca1b17d52ff0dc02b646c667ac7266c", "shasum": "" }, "require": { @@ -1647,20 +1648,20 @@ "issues": "https://github.com/laravel/serializable-closure/issues", "source": "https://github.com/laravel/serializable-closure" }, - "time": "2021-10-07T14:00:57+00:00" + "time": "2021-11-30T15:53:04+00:00" }, { "name": "laravel/tinker", - "version": "v2.6.2", + "version": "v2.6.3", "source": { "type": "git", "url": "https://github.com/laravel/tinker.git", - "reference": "c808a7227f97ecfd9219fbf913bad842ea854ddc" + "reference": "a9ddee4761ec8453c584e393b393caff189a3e42" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/tinker/zipball/c808a7227f97ecfd9219fbf913bad842ea854ddc", - "reference": "c808a7227f97ecfd9219fbf913bad842ea854ddc", + "url": "https://api.github.com/repos/laravel/tinker/zipball/a9ddee4761ec8453c584e393b393caff189a3e42", + "reference": "a9ddee4761ec8453c584e393b393caff189a3e42", "shasum": "" }, "require": { @@ -1713,22 +1714,22 @@ ], "support": { "issues": "https://github.com/laravel/tinker/issues", - "source": "https://github.com/laravel/tinker/tree/v2.6.2" + "source": "https://github.com/laravel/tinker/tree/v2.6.3" }, - "time": "2021-09-28T15:47:34+00:00" + "time": "2021-12-07T16:41:42+00:00" }, { "name": "league/commonmark", - "version": "2.0.2", + "version": "2.1.1", "source": { "type": "git", "url": "https://github.com/thephpleague/commonmark.git", - "reference": "2df87709f44b0dd733df86aef0830dce9b1f0f13" + "reference": "17d2b9cb5161a2ea1a8dd30e6991d668e503fb9d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/2df87709f44b0dd733df86aef0830dce9b1f0f13", - "reference": "2df87709f44b0dd733df86aef0830dce9b1f0f13", + "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/17d2b9cb5161a2ea1a8dd30e6991d668e503fb9d", + "reference": "17d2b9cb5161a2ea1a8dd30e6991d668e503fb9d", "shasum": "" }, "require": { @@ -1747,11 +1748,11 @@ "ext-json": "*", "github/gfm": "0.29.0", "michelf/php-markdown": "^1.4", - "phpstan/phpstan": "^0.12.88", + "phpstan/phpstan": "^0.12.88 || ^1.0.0", "phpunit/phpunit": "^9.5.5", "scrutinizer/ocular": "^1.8.1", "symfony/finder": "^5.3", - "symfony/yaml": "^2.3 | ^3.0 | ^4.0 | ^5.0", + "symfony/yaml": "^2.3 | ^3.0 | ^4.0 | ^5.0 | ^6.0", "unleashedtech/php-coding-standard": "^3.1", "vimeo/psalm": "^4.7.3" }, @@ -1761,7 +1762,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "2.1-dev" + "dev-main": "2.2-dev" } }, "autoload": { @@ -1801,10 +1802,6 @@ "source": "https://github.com/thephpleague/commonmark" }, "funding": [ - { - "url": "https://enjoy.gitstore.app/repositories/thephpleague/commonmark", - "type": "custom" - }, { "url": "https://www.colinodell.com/sponsor", "type": "custom" @@ -1817,16 +1814,12 @@ "url": "https://github.com/colinodell", "type": "github" }, - { - "url": "https://www.patreon.com/colinodell", - "type": "patreon" - }, { "url": "https://tidelift.com/funding/github/packagist/league/commonmark", "type": "tidelift" } ], - "time": "2021-08-14T14:06:04+00:00" + "time": "2022-01-02T18:25:06+00:00" }, { "name": "league/config", @@ -1912,16 +1905,16 @@ }, { "name": "league/flysystem", - "version": "1.1.5", + "version": "1.1.9", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem.git", - "reference": "18634df356bfd4119fe3d6156bdb990c414c14ea" + "reference": "094defdb4a7001845300334e7c1ee2335925ef99" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/18634df356bfd4119fe3d6156bdb990c414c14ea", - "reference": "18634df356bfd4119fe3d6156bdb990c414c14ea", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/094defdb4a7001845300334e7c1ee2335925ef99", + "reference": "094defdb4a7001845300334e7c1ee2335925ef99", "shasum": "" }, "require": { @@ -1994,7 +1987,7 @@ ], "support": { "issues": "https://github.com/thephpleague/flysystem/issues", - "source": "https://github.com/thephpleague/flysystem/tree/1.1.5" + "source": "https://github.com/thephpleague/flysystem/tree/1.1.9" }, "funding": [ { @@ -2002,20 +1995,20 @@ "type": "other" } ], - "time": "2021-08-17T13:49:42+00:00" + "time": "2021-12-09T09:40:50+00:00" }, { "name": "league/mime-type-detection", - "version": "1.8.0", + "version": "1.9.0", "source": { "type": "git", "url": "https://github.com/thephpleague/mime-type-detection.git", - "reference": "b38b25d7b372e9fddb00335400467b223349fd7e" + "reference": "aa70e813a6ad3d1558fc927863d47309b4c23e69" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/mime-type-detection/zipball/b38b25d7b372e9fddb00335400467b223349fd7e", - "reference": "b38b25d7b372e9fddb00335400467b223349fd7e", + "url": "https://api.github.com/repos/thephpleague/mime-type-detection/zipball/aa70e813a6ad3d1558fc927863d47309b4c23e69", + "reference": "aa70e813a6ad3d1558fc927863d47309b4c23e69", "shasum": "" }, "require": { @@ -2023,7 +2016,7 @@ "php": "^7.2 || ^8.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^2.18", + "friendsofphp/php-cs-fixer": "^3.2", "phpstan/phpstan": "^0.12.68", "phpunit/phpunit": "^8.5.8 || ^9.3" }, @@ -2046,7 +2039,7 @@ "description": "Mime-type detection for Flysystem", "support": { "issues": "https://github.com/thephpleague/mime-type-detection/issues", - "source": "https://github.com/thephpleague/mime-type-detection/tree/1.8.0" + "source": "https://github.com/thephpleague/mime-type-detection/tree/1.9.0" }, "funding": [ { @@ -2058,7 +2051,7 @@ "type": "tidelift" } ], - "time": "2021-09-25T08:23:19+00:00" + "time": "2021-11-21T11:48:40+00:00" }, { "name": "monolog/monolog", @@ -2161,16 +2154,16 @@ }, { "name": "nesbot/carbon", - "version": "2.54.0", + "version": "2.55.2", "source": { "type": "git", "url": "https://github.com/briannesbitt/Carbon.git", - "reference": "eed83939f1aed3eee517d03a33f5ec587ac529b5" + "reference": "8c2a18ce3e67c34efc1b29f64fe61304368259a2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/eed83939f1aed3eee517d03a33f5ec587ac529b5", - "reference": "eed83939f1aed3eee517d03a33f5ec587ac529b5", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/8c2a18ce3e67c34efc1b29f64fe61304368259a2", + "reference": "8c2a18ce3e67c34efc1b29f64fe61304368259a2", "shasum": "" }, "require": { @@ -2178,7 +2171,7 @@ "php": "^7.1.8 || ^8.0", "symfony/polyfill-mbstring": "^1.0", "symfony/polyfill-php80": "^1.16", - "symfony/translation": "^3.4 || ^4.0 || ^5.0" + "symfony/translation": "^3.4 || ^4.0 || ^5.0 || ^6.0" }, "require-dev": { "doctrine/dbal": "^2.0 || ^3.0", @@ -2239,6 +2232,7 @@ "time" ], "support": { + "docs": "https://carbon.nesbot.com/docs", "issues": "https://github.com/briannesbitt/Carbon/issues", "source": "https://github.com/briannesbitt/Carbon" }, @@ -2252,7 +2246,7 @@ "type": "tidelift" } ], - "time": "2021-11-01T21:22:20+00:00" + "time": "2021-12-03T14:59:52+00:00" }, { "name": "nette/schema", @@ -2318,16 +2312,16 @@ }, { "name": "nette/utils", - "version": "v3.2.5", + "version": "v3.2.6", "source": { "type": "git", "url": "https://github.com/nette/utils.git", - "reference": "9cd80396ca58d7969ab44fc7afcf03624dfa526e" + "reference": "2f261e55bd6a12057442045bf2c249806abc1d02" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/utils/zipball/9cd80396ca58d7969ab44fc7afcf03624dfa526e", - "reference": "9cd80396ca58d7969ab44fc7afcf03624dfa526e", + "url": "https://api.github.com/repos/nette/utils/zipball/2f261e55bd6a12057442045bf2c249806abc1d02", + "reference": "2f261e55bd6a12057442045bf2c249806abc1d02", "shasum": "" }, "require": { @@ -2338,7 +2332,7 @@ }, "require-dev": { "nette/tester": "~2.0", - "phpstan/phpstan": "^0.12", + "phpstan/phpstan": "^1.0", "tracy/tracy": "^2.3" }, "suggest": { @@ -2397,22 +2391,22 @@ ], "support": { "issues": "https://github.com/nette/utils/issues", - "source": "https://github.com/nette/utils/tree/v3.2.5" + "source": "https://github.com/nette/utils/tree/v3.2.6" }, - "time": "2021-09-20T10:50:11+00:00" + "time": "2021-11-24T15:47:23+00:00" }, { "name": "nikic/php-parser", - "version": "v4.13.1", + "version": "v4.13.2", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "63a79e8daa781cac14e5195e63ed8ae231dd10fd" + "reference": "210577fe3cf7badcc5814d99455df46564f3c077" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/63a79e8daa781cac14e5195e63ed8ae231dd10fd", - "reference": "63a79e8daa781cac14e5195e63ed8ae231dd10fd", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/210577fe3cf7badcc5814d99455df46564f3c077", + "reference": "210577fe3cf7badcc5814d99455df46564f3c077", "shasum": "" }, "require": { @@ -2453,9 +2447,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.13.1" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.13.2" }, - "time": "2021-11-03T20:52:16+00:00" + "time": "2021-11-30T19:35:32+00:00" }, { "name": "opis/closure", @@ -2591,16 +2585,16 @@ }, { "name": "phpoption/phpoption", - "version": "1.8.0", + "version": "1.8.1", "source": { "type": "git", "url": "https://github.com/schmittjoh/php-option.git", - "reference": "5455cb38aed4523f99977c4a12ef19da4bfe2a28" + "reference": "eab7a0df01fe2344d172bff4cd6dbd3f8b84ad15" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/5455cb38aed4523f99977c4a12ef19da4bfe2a28", - "reference": "5455cb38aed4523f99977c4a12ef19da4bfe2a28", + "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/eab7a0df01fe2344d172bff4cd6dbd3f8b84ad15", + "reference": "eab7a0df01fe2344d172bff4cd6dbd3f8b84ad15", "shasum": "" }, "require": { @@ -2608,7 +2602,7 @@ }, "require-dev": { "bamarni/composer-bin-plugin": "^1.4.1", - "phpunit/phpunit": "^6.5.14 || ^7.0.20 || ^8.5.19 || ^9.5.8" + "phpunit/phpunit": "^6.5.14 || ^7.5.20 || ^8.5.19 || ^9.5.8" }, "type": "library", "extra": { @@ -2628,11 +2622,13 @@ "authors": [ { "name": "Johannes M. Schmitt", - "email": "schmittjoh@gmail.com" + "email": "schmittjoh@gmail.com", + "homepage": "https://github.com/schmittjoh" }, { "name": "Graham Campbell", - "email": "hello@gjcampbell.co.uk" + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" } ], "description": "Option Type for PHP", @@ -2644,7 +2640,7 @@ ], "support": { "issues": "https://github.com/schmittjoh/php-option/issues", - "source": "https://github.com/schmittjoh/php-option/tree/1.8.0" + "source": "https://github.com/schmittjoh/php-option/tree/1.8.1" }, "funding": [ { @@ -2656,7 +2652,7 @@ "type": "tidelift" } ], - "time": "2021-08-28T21:27:29+00:00" + "time": "2021-12-04T23:24:31+00:00" }, { "name": "psr/container", @@ -3019,16 +3015,16 @@ }, { "name": "psy/psysh", - "version": "v0.10.9", + "version": "v0.10.12", "source": { "type": "git", "url": "https://github.com/bobthecow/psysh.git", - "reference": "01281336c4ae557fe4a994544f30d3a1bc204375" + "reference": "a0d9981aa07ecfcbea28e4bfa868031cca121e7d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/bobthecow/psysh/zipball/01281336c4ae557fe4a994544f30d3a1bc204375", - "reference": "01281336c4ae557fe4a994544f30d3a1bc204375", + "url": "https://api.github.com/repos/bobthecow/psysh/zipball/a0d9981aa07ecfcbea28e4bfa868031cca121e7d", + "reference": "a0d9981aa07ecfcbea28e4bfa868031cca121e7d", "shasum": "" }, "require": { @@ -3088,9 +3084,9 @@ ], "support": { "issues": "https://github.com/bobthecow/psysh/issues", - "source": "https://github.com/bobthecow/psysh/tree/v0.10.9" + "source": "https://github.com/bobthecow/psysh/tree/v0.10.12" }, - "time": "2021-10-10T13:37:39+00:00" + "time": "2021-11-30T14:05:36+00:00" }, { "name": "ralouphie/getallheaders", @@ -3386,30 +3382,31 @@ "type": "tidelift" } ], + "abandoned": "symfony/mailer", "time": "2021-10-18T15:26:12+00:00" }, { "name": "symfony/console", - "version": "v5.3.10", + "version": "v5.4.2", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "d4e409d9fbcfbf71af0e5a940abb7b0b4bad0bd3" + "reference": "a2c6b7ced2eb7799a35375fb9022519282b5405e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/d4e409d9fbcfbf71af0e5a940abb7b0b4bad0bd3", - "reference": "d4e409d9fbcfbf71af0e5a940abb7b0b4bad0bd3", + "url": "https://api.github.com/repos/symfony/console/zipball/a2c6b7ced2eb7799a35375fb9022519282b5405e", + "reference": "a2c6b7ced2eb7799a35375fb9022519282b5405e", "shasum": "" }, "require": { "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1", + "symfony/deprecation-contracts": "^2.1|^3", "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php73": "^1.8", + "symfony/polyfill-php73": "^1.9", "symfony/polyfill-php80": "^1.16", - "symfony/service-contracts": "^1.1|^2", - "symfony/string": "^5.1" + "symfony/service-contracts": "^1.1|^2|^3", + "symfony/string": "^5.1|^6.0" }, "conflict": { "psr/log": ">=3", @@ -3424,12 +3421,12 @@ }, "require-dev": { "psr/log": "^1|^2", - "symfony/config": "^4.4|^5.0", - "symfony/dependency-injection": "^4.4|^5.0", - "symfony/event-dispatcher": "^4.4|^5.0", - "symfony/lock": "^4.4|^5.0", - "symfony/process": "^4.4|^5.0", - "symfony/var-dumper": "^4.4|^5.0" + "symfony/config": "^4.4|^5.0|^6.0", + "symfony/dependency-injection": "^4.4|^5.0|^6.0", + "symfony/event-dispatcher": "^4.4|^5.0|^6.0", + "symfony/lock": "^4.4|^5.0|^6.0", + "symfony/process": "^4.4|^5.0|^6.0", + "symfony/var-dumper": "^4.4|^5.0|^6.0" }, "suggest": { "psr/log": "For using the console logger", @@ -3469,7 +3466,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.3.10" + "source": "https://github.com/symfony/console/tree/v5.4.2" }, "funding": [ { @@ -3485,25 +3482,24 @@ "type": "tidelift" } ], - "time": "2021-10-26T09:30:15+00:00" + "time": "2021-12-20T16:11:12+00:00" }, { "name": "symfony/css-selector", - "version": "v5.3.4", + "version": "v6.0.2", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", - "reference": "7fb120adc7f600a59027775b224c13a33530dd90" + "reference": "380f86c1a9830226f42a08b5926f18aed4195f25" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/css-selector/zipball/7fb120adc7f600a59027775b224c13a33530dd90", - "reference": "7fb120adc7f600a59027775b224c13a33530dd90", + "url": "https://api.github.com/repos/symfony/css-selector/zipball/380f86c1a9830226f42a08b5926f18aed4195f25", + "reference": "380f86c1a9830226f42a08b5926f18aed4195f25", "shasum": "" }, "require": { - "php": ">=7.2.5", - "symfony/polyfill-php80": "^1.16" + "php": ">=8.0.2" }, "type": "library", "autoload": { @@ -3535,7 +3531,7 @@ "description": "Converts CSS selectors to XPath expressions", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/css-selector/tree/v5.3.4" + "source": "https://github.com/symfony/css-selector/tree/v6.0.2" }, "funding": [ { @@ -3551,29 +3547,29 @@ "type": "tidelift" } ], - "time": "2021-07-21T12:38:00+00:00" + "time": "2021-12-16T22:13:01+00:00" }, { "name": "symfony/deprecation-contracts", - "version": "v2.4.0", + "version": "v3.0.0", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627" + "reference": "c726b64c1ccfe2896cb7df2e1331c357ad1c8ced" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/5f38c8804a9e97d23e0c8d63341088cd8a22d627", - "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/c726b64c1ccfe2896cb7df2e1331c357ad1c8ced", + "reference": "c726b64c1ccfe2896cb7df2e1331c357ad1c8ced", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=8.0.2" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "2.4-dev" + "dev-main": "3.0-dev" }, "thanks": { "name": "symfony/contracts", @@ -3602,7 +3598,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v2.4.0" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.0.0" }, "funding": [ { @@ -3618,32 +3614,35 @@ "type": "tidelift" } ], - "time": "2021-03-23T23:28:01+00:00" + "time": "2021-11-01T23:48:49+00:00" }, { "name": "symfony/error-handler", - "version": "v5.3.7", + "version": "v5.4.2", "source": { "type": "git", "url": "https://github.com/symfony/error-handler.git", - "reference": "3bc60d0fba00ae8d1eaa9eb5ab11a2bbdd1fc321" + "reference": "e0c0dd0f9d4120a20158fc9aec2367d07d38bc56" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/error-handler/zipball/3bc60d0fba00ae8d1eaa9eb5ab11a2bbdd1fc321", - "reference": "3bc60d0fba00ae8d1eaa9eb5ab11a2bbdd1fc321", + "url": "https://api.github.com/repos/symfony/error-handler/zipball/e0c0dd0f9d4120a20158fc9aec2367d07d38bc56", + "reference": "e0c0dd0f9d4120a20158fc9aec2367d07d38bc56", "shasum": "" }, "require": { "php": ">=7.2.5", "psr/log": "^1|^2|^3", - "symfony/var-dumper": "^4.4|^5.0" + "symfony/var-dumper": "^4.4|^5.0|^6.0" }, "require-dev": { - "symfony/deprecation-contracts": "^2.1", - "symfony/http-kernel": "^4.4|^5.0", - "symfony/serializer": "^4.4|^5.0" + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/http-kernel": "^4.4|^5.0|^6.0", + "symfony/serializer": "^4.4|^5.0|^6.0" }, + "bin": [ + "Resources/bin/patch-type-declarations" + ], "type": "library", "autoload": { "psr-4": { @@ -3670,7 +3669,7 @@ "description": "Provides tools to manage errors and ease debugging PHP code", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/error-handler/tree/v5.3.7" + "source": "https://github.com/symfony/error-handler/tree/v5.4.2" }, "funding": [ { @@ -3686,44 +3685,42 @@ "type": "tidelift" } ], - "time": "2021-08-28T15:07:08+00:00" + "time": "2021-12-19T20:02:00+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v5.3.7", + "version": "v6.0.2", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "ce7b20d69c66a20939d8952b617506a44d102130" + "reference": "7093f25359e2750bfe86842c80c4e4a6a852d05c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/ce7b20d69c66a20939d8952b617506a44d102130", - "reference": "ce7b20d69c66a20939d8952b617506a44d102130", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/7093f25359e2750bfe86842c80c4e4a6a852d05c", + "reference": "7093f25359e2750bfe86842c80c4e4a6a852d05c", "shasum": "" }, "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1", - "symfony/event-dispatcher-contracts": "^2", - "symfony/polyfill-php80": "^1.16" + "php": ">=8.0.2", + "symfony/event-dispatcher-contracts": "^2|^3" }, "conflict": { - "symfony/dependency-injection": "<4.4" + "symfony/dependency-injection": "<5.4" }, "provide": { "psr/event-dispatcher-implementation": "1.0", - "symfony/event-dispatcher-implementation": "2.0" + "symfony/event-dispatcher-implementation": "2.0|3.0" }, "require-dev": { "psr/log": "^1|^2|^3", - "symfony/config": "^4.4|^5.0", - "symfony/dependency-injection": "^4.4|^5.0", - "symfony/error-handler": "^4.4|^5.0", - "symfony/expression-language": "^4.4|^5.0", - "symfony/http-foundation": "^4.4|^5.0", - "symfony/service-contracts": "^1.1|^2", - "symfony/stopwatch": "^4.4|^5.0" + "symfony/config": "^5.4|^6.0", + "symfony/dependency-injection": "^5.4|^6.0", + "symfony/error-handler": "^5.4|^6.0", + "symfony/expression-language": "^5.4|^6.0", + "symfony/http-foundation": "^5.4|^6.0", + "symfony/service-contracts": "^1.1|^2|^3", + "symfony/stopwatch": "^5.4|^6.0" }, "suggest": { "symfony/dependency-injection": "", @@ -3755,7 +3752,7 @@ "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/event-dispatcher/tree/v5.3.7" + "source": "https://github.com/symfony/event-dispatcher/tree/v6.0.2" }, "funding": [ { @@ -3771,24 +3768,24 @@ "type": "tidelift" } ], - "time": "2021-08-04T21:20:46+00:00" + "time": "2021-12-21T10:43:13+00:00" }, { "name": "symfony/event-dispatcher-contracts", - "version": "v2.4.0", + "version": "v3.0.0", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher-contracts.git", - "reference": "69fee1ad2332a7cbab3aca13591953da9cdb7a11" + "reference": "aa5422287b75594b90ee9cd807caf8f0df491385" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/69fee1ad2332a7cbab3aca13591953da9cdb7a11", - "reference": "69fee1ad2332a7cbab3aca13591953da9cdb7a11", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/aa5422287b75594b90ee9cd807caf8f0df491385", + "reference": "aa5422287b75594b90ee9cd807caf8f0df491385", "shasum": "" }, "require": { - "php": ">=7.2.5", + "php": ">=8.0.2", "psr/event-dispatcher": "^1" }, "suggest": { @@ -3797,7 +3794,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "2.4-dev" + "dev-main": "3.0-dev" }, "thanks": { "name": "symfony/contracts", @@ -3834,7 +3831,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v2.4.0" + "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.0.0" }, "funding": [ { @@ -3850,24 +3847,25 @@ "type": "tidelift" } ], - "time": "2021-03-23T23:28:01+00:00" + "time": "2021-07-15T12:33:35+00:00" }, { "name": "symfony/finder", - "version": "v5.3.7", + "version": "v5.4.2", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "a10000ada1e600d109a6c7632e9ac42e8bf2fb93" + "reference": "e77046c252be48c48a40816187ed527703c8f76c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/a10000ada1e600d109a6c7632e9ac42e8bf2fb93", - "reference": "a10000ada1e600d109a6c7632e9ac42e8bf2fb93", + "url": "https://api.github.com/repos/symfony/finder/zipball/e77046c252be48c48a40816187ed527703c8f76c", + "reference": "e77046c252be48c48a40816187ed527703c8f76c", "shasum": "" }, "require": { "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1|^3", "symfony/polyfill-php80": "^1.16" }, "type": "library", @@ -3896,7 +3894,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v5.3.7" + "source": "https://github.com/symfony/finder/tree/v5.4.2" }, "funding": [ { @@ -3912,111 +3910,33 @@ "type": "tidelift" } ], - "time": "2021-08-04T21:20:46+00:00" - }, - { - "name": "symfony/http-client-contracts", - "version": "v2.4.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/http-client-contracts.git", - "reference": "7e82f6084d7cae521a75ef2cb5c9457bbda785f4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/http-client-contracts/zipball/7e82f6084d7cae521a75ef2cb5c9457bbda785f4", - "reference": "7e82f6084d7cae521a75ef2cb5c9457bbda785f4", - "shasum": "" - }, - "require": { - "php": ">=7.2.5" - }, - "suggest": { - "symfony/http-client-implementation": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "2.4-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Contracts\\HttpClient\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Generic abstractions related to HTTP clients", - "homepage": "https://symfony.com", - "keywords": [ - "abstractions", - "contracts", - "decoupling", - "interfaces", - "interoperability", - "standards" - ], - "support": { - "source": "https://github.com/symfony/http-client-contracts/tree/v2.4.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-04-11T23:07:08+00:00" + "time": "2021-12-15T11:06:13+00:00" }, { "name": "symfony/http-foundation", - "version": "v5.3.10", + "version": "v5.4.2", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "9f34f02e8a5fdc7a56bafe011cea1ce97300e54c" + "reference": "ce952af52877eaf3eab5d0c08cc0ea865ed37313" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/9f34f02e8a5fdc7a56bafe011cea1ce97300e54c", - "reference": "9f34f02e8a5fdc7a56bafe011cea1ce97300e54c", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/ce952af52877eaf3eab5d0c08cc0ea865ed37313", + "reference": "ce952af52877eaf3eab5d0c08cc0ea865ed37313", "shasum": "" }, "require": { "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1", + "symfony/deprecation-contracts": "^2.1|^3", "symfony/polyfill-mbstring": "~1.1", "symfony/polyfill-php80": "^1.16" }, "require-dev": { "predis/predis": "~1.0", - "symfony/cache": "^4.4|^5.0", - "symfony/expression-language": "^4.4|^5.0", - "symfony/mime": "^4.4|^5.0" + "symfony/cache": "^4.4|^5.0|^6.0", + "symfony/expression-language": "^4.4|^5.0|^6.0", + "symfony/mime": "^4.4|^5.0|^6.0" }, "suggest": { "symfony/mime": "To use the file extension guesser" @@ -4047,7 +3967,7 @@ "description": "Defines an object-oriented layer for the HTTP specification", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-foundation/tree/v5.3.10" + "source": "https://github.com/symfony/http-foundation/tree/v5.4.2" }, "funding": [ { @@ -4063,36 +3983,35 @@ "type": "tidelift" } ], - "time": "2021-10-11T15:41:55+00:00" + "time": "2021-12-28T17:15:56+00:00" }, { "name": "symfony/http-kernel", - "version": "v5.3.10", + "version": "v5.4.2", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "703e4079920468e9522b72cf47fd76ce8d795e86" + "reference": "35b7e9868953e0d1df84320bb063543369e43ef5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/703e4079920468e9522b72cf47fd76ce8d795e86", - "reference": "703e4079920468e9522b72cf47fd76ce8d795e86", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/35b7e9868953e0d1df84320bb063543369e43ef5", + "reference": "35b7e9868953e0d1df84320bb063543369e43ef5", "shasum": "" }, "require": { "php": ">=7.2.5", "psr/log": "^1|^2", - "symfony/deprecation-contracts": "^2.1", - "symfony/error-handler": "^4.4|^5.0", - "symfony/event-dispatcher": "^5.0", - "symfony/http-client-contracts": "^1.1|^2", - "symfony/http-foundation": "^5.3.7", + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/error-handler": "^4.4|^5.0|^6.0", + "symfony/event-dispatcher": "^5.0|^6.0", + "symfony/http-foundation": "^5.3.7|^6.0", "symfony/polyfill-ctype": "^1.8", "symfony/polyfill-php73": "^1.9", "symfony/polyfill-php80": "^1.16" }, "conflict": { - "symfony/browser-kit": "<4.4", + "symfony/browser-kit": "<5.4", "symfony/cache": "<5.0", "symfony/config": "<5.0", "symfony/console": "<4.4", @@ -4112,19 +4031,20 @@ }, "require-dev": { "psr/cache": "^1.0|^2.0|^3.0", - "symfony/browser-kit": "^4.4|^5.0", - "symfony/config": "^5.0", - "symfony/console": "^4.4|^5.0", - "symfony/css-selector": "^4.4|^5.0", - "symfony/dependency-injection": "^5.3", - "symfony/dom-crawler": "^4.4|^5.0", - "symfony/expression-language": "^4.4|^5.0", - "symfony/finder": "^4.4|^5.0", - "symfony/process": "^4.4|^5.0", - "symfony/routing": "^4.4|^5.0", - "symfony/stopwatch": "^4.4|^5.0", - "symfony/translation": "^4.4|^5.0", - "symfony/translation-contracts": "^1.1|^2", + "symfony/browser-kit": "^5.4|^6.0", + "symfony/config": "^5.0|^6.0", + "symfony/console": "^4.4|^5.0|^6.0", + "symfony/css-selector": "^4.4|^5.0|^6.0", + "symfony/dependency-injection": "^5.3|^6.0", + "symfony/dom-crawler": "^4.4|^5.0|^6.0", + "symfony/expression-language": "^4.4|^5.0|^6.0", + "symfony/finder": "^4.4|^5.0|^6.0", + "symfony/http-client-contracts": "^1.1|^2|^3", + "symfony/process": "^4.4|^5.0|^6.0", + "symfony/routing": "^4.4|^5.0|^6.0", + "symfony/stopwatch": "^4.4|^5.0|^6.0", + "symfony/translation": "^4.4|^5.0|^6.0", + "symfony/translation-contracts": "^1.1|^2|^3", "twig/twig": "^2.13|^3.0.4" }, "suggest": { @@ -4159,7 +4079,7 @@ "description": "Provides a structured process for converting a Request into a Response", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-kernel/tree/v5.3.10" + "source": "https://github.com/symfony/http-kernel/tree/v5.4.2" }, "funding": [ { @@ -4175,25 +4095,25 @@ "type": "tidelift" } ], - "time": "2021-10-29T08:36:48+00:00" + "time": "2021-12-29T13:20:26+00:00" }, { "name": "symfony/mime", - "version": "v5.3.8", + "version": "v5.4.2", "source": { "type": "git", "url": "https://github.com/symfony/mime.git", - "reference": "a756033d0a7e53db389618653ae991eba5a19a11" + "reference": "1bfd938cf9562822c05c4d00e8f92134d3c8e42d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/mime/zipball/a756033d0a7e53db389618653ae991eba5a19a11", - "reference": "a756033d0a7e53db389618653ae991eba5a19a11", + "url": "https://api.github.com/repos/symfony/mime/zipball/1bfd938cf9562822c05c4d00e8f92134d3c8e42d", + "reference": "1bfd938cf9562822c05c4d00e8f92134d3c8e42d", "shasum": "" }, "require": { "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1", + "symfony/deprecation-contracts": "^2.1|^3", "symfony/polyfill-intl-idn": "^1.10", "symfony/polyfill-mbstring": "^1.0", "symfony/polyfill-php80": "^1.16" @@ -4207,10 +4127,10 @@ "require-dev": { "egulias/email-validator": "^2.1.10|^3.1", "phpdocumentor/reflection-docblock": "^3.0|^4.0|^5.0", - "symfony/dependency-injection": "^4.4|^5.0", - "symfony/property-access": "^4.4|^5.1", - "symfony/property-info": "^4.4|^5.1", - "symfony/serializer": "^5.2" + "symfony/dependency-injection": "^4.4|^5.0|^6.0", + "symfony/property-access": "^4.4|^5.1|^6.0", + "symfony/property-info": "^4.4|^5.1|^6.0", + "symfony/serializer": "^5.2|^6.0" }, "type": "library", "autoload": { @@ -4242,7 +4162,7 @@ "mime-type" ], "support": { - "source": "https://github.com/symfony/mime/tree/v5.3.8" + "source": "https://github.com/symfony/mime/tree/v5.4.2" }, "funding": [ { @@ -4258,25 +4178,28 @@ "type": "tidelift" } ], - "time": "2021-09-10T12:30:38+00:00" + "time": "2021-12-28T17:15:56+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.23.0", + "version": "v1.24.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce" + "reference": "30885182c981ab175d4d034db0f6f469898070ab" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/46cd95797e9df938fdd2b03693b5fca5e64b01ce", - "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/30885182c981ab175d4d034db0f6f469898070ab", + "reference": "30885182c981ab175d4d034db0f6f469898070ab", "shasum": "" }, "require": { "php": ">=7.1" }, + "provide": { + "ext-ctype": "*" + }, "suggest": { "ext-ctype": "For best performance" }, @@ -4321,7 +4244,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.23.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.24.0" }, "funding": [ { @@ -4337,25 +4260,28 @@ "type": "tidelift" } ], - "time": "2021-02-19T12:13:01+00:00" + "time": "2021-10-20T20:35:02+00:00" }, { "name": "symfony/polyfill-iconv", - "version": "v1.23.0", + "version": "v1.24.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-iconv.git", - "reference": "63b5bb7db83e5673936d6e3b8b3e022ff6474933" + "reference": "f1aed619e28cb077fc83fac8c4c0383578356e40" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/63b5bb7db83e5673936d6e3b8b3e022ff6474933", - "reference": "63b5bb7db83e5673936d6e3b8b3e022ff6474933", + "url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/f1aed619e28cb077fc83fac8c4c0383578356e40", + "reference": "f1aed619e28cb077fc83fac8c4c0383578356e40", "shasum": "" }, "require": { "php": ">=7.1" }, + "provide": { + "ext-iconv": "*" + }, "suggest": { "ext-iconv": "For best performance" }, @@ -4401,7 +4327,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-iconv/tree/v1.23.0" + "source": "https://github.com/symfony/polyfill-iconv/tree/v1.24.0" }, "funding": [ { @@ -4417,20 +4343,20 @@ "type": "tidelift" } ], - "time": "2021-05-27T09:27:20+00:00" + "time": "2022-01-04T09:04:05+00:00" }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.23.1", + "version": "v1.24.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "16880ba9c5ebe3642d1995ab866db29270b36535" + "reference": "81b86b50cf841a64252b439e738e97f4a34e2783" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/16880ba9c5ebe3642d1995ab866db29270b36535", - "reference": "16880ba9c5ebe3642d1995ab866db29270b36535", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/81b86b50cf841a64252b439e738e97f4a34e2783", + "reference": "81b86b50cf841a64252b439e738e97f4a34e2783", "shasum": "" }, "require": { @@ -4482,7 +4408,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.23.1" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.24.0" }, "funding": [ { @@ -4498,20 +4424,20 @@ "type": "tidelift" } ], - "time": "2021-05-27T12:26:48+00:00" + "time": "2021-11-23T21:10:46+00:00" }, { "name": "symfony/polyfill-intl-idn", - "version": "v1.23.0", + "version": "v1.24.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-idn.git", - "reference": "65bd267525e82759e7d8c4e8ceea44f398838e65" + "reference": "749045c69efb97c70d25d7463abba812e91f3a44" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/65bd267525e82759e7d8c4e8ceea44f398838e65", - "reference": "65bd267525e82759e7d8c4e8ceea44f398838e65", + "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/749045c69efb97c70d25d7463abba812e91f3a44", + "reference": "749045c69efb97c70d25d7463abba812e91f3a44", "shasum": "" }, "require": { @@ -4569,7 +4495,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.23.0" + "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.24.0" }, "funding": [ { @@ -4585,11 +4511,11 @@ "type": "tidelift" } ], - "time": "2021-05-27T09:27:20+00:00" + "time": "2021-09-14T14:02:44+00:00" }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.23.0", + "version": "v1.24.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", @@ -4653,7 +4579,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.23.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.24.0" }, "funding": [ { @@ -4673,21 +4599,24 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "v1.23.1", + "version": "v1.24.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6" + "reference": "0abb51d2f102e00a4eefcf46ba7fec406d245825" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9174a3d80210dca8daa7f31fec659150bbeabfc6", - "reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/0abb51d2f102e00a4eefcf46ba7fec406d245825", + "reference": "0abb51d2f102e00a4eefcf46ba7fec406d245825", "shasum": "" }, "require": { "php": ">=7.1" }, + "provide": { + "ext-mbstring": "*" + }, "suggest": { "ext-mbstring": "For best performance" }, @@ -4733,7 +4662,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.23.1" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.24.0" }, "funding": [ { @@ -4749,11 +4678,11 @@ "type": "tidelift" } ], - "time": "2021-05-27T12:26:48+00:00" + "time": "2021-11-30T18:21:41+00:00" }, { "name": "symfony/polyfill-php72", - "version": "v1.23.0", + "version": "v1.24.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php72.git", @@ -4809,7 +4738,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php72/tree/v1.23.0" + "source": "https://github.com/symfony/polyfill-php72/tree/v1.24.0" }, "funding": [ { @@ -4829,16 +4758,16 @@ }, { "name": "symfony/polyfill-php73", - "version": "v1.23.0", + "version": "v1.24.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "fba8933c384d6476ab14fb7b8526e5287ca7e010" + "reference": "cc5db0e22b3cb4111010e48785a97f670b350ca5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/fba8933c384d6476ab14fb7b8526e5287ca7e010", - "reference": "fba8933c384d6476ab14fb7b8526e5287ca7e010", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/cc5db0e22b3cb4111010e48785a97f670b350ca5", + "reference": "cc5db0e22b3cb4111010e48785a97f670b350ca5", "shasum": "" }, "require": { @@ -4888,7 +4817,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.23.0" + "source": "https://github.com/symfony/polyfill-php73/tree/v1.24.0" }, "funding": [ { @@ -4904,20 +4833,20 @@ "type": "tidelift" } ], - "time": "2021-02-19T12:13:01+00:00" + "time": "2021-06-05T21:20:04+00:00" }, { "name": "symfony/polyfill-php80", - "version": "v1.23.1", + "version": "v1.24.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be" + "reference": "57b712b08eddb97c762a8caa32c84e037892d2e9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/1100343ed1a92e3a38f9ae122fc0eb21602547be", - "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/57b712b08eddb97c762a8caa32c84e037892d2e9", + "reference": "57b712b08eddb97c762a8caa32c84e037892d2e9", "shasum": "" }, "require": { @@ -4971,7 +4900,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.23.1" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.24.0" }, "funding": [ { @@ -4987,20 +4916,20 @@ "type": "tidelift" } ], - "time": "2021-07-28T13:41:28+00:00" + "time": "2021-09-13T13:58:33+00:00" }, { "name": "symfony/polyfill-php81", - "version": "v1.23.0", + "version": "v1.24.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php81.git", - "reference": "e66119f3de95efc359483f810c4c3e6436279436" + "reference": "5de4ba2d41b15f9bd0e19b2ab9674135813ec98f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/e66119f3de95efc359483f810c4c3e6436279436", - "reference": "e66119f3de95efc359483f810c4c3e6436279436", + "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/5de4ba2d41b15f9bd0e19b2ab9674135813ec98f", + "reference": "5de4ba2d41b15f9bd0e19b2ab9674135813ec98f", "shasum": "" }, "require": { @@ -5050,7 +4979,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php81/tree/v1.23.0" + "source": "https://github.com/symfony/polyfill-php81/tree/v1.24.0" }, "funding": [ { @@ -5066,20 +4995,20 @@ "type": "tidelift" } ], - "time": "2021-05-21T13:25:03+00:00" + "time": "2021-09-13T13:58:11+00:00" }, { "name": "symfony/process", - "version": "v5.3.7", + "version": "v5.4.2", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "38f26c7d6ed535217ea393e05634cb0b244a1967" + "reference": "2b3ba8722c4aaf3e88011be5e7f48710088fb5e4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/38f26c7d6ed535217ea393e05634cb0b244a1967", - "reference": "38f26c7d6ed535217ea393e05634cb0b244a1967", + "url": "https://api.github.com/repos/symfony/process/zipball/2b3ba8722c4aaf3e88011be5e7f48710088fb5e4", + "reference": "2b3ba8722c4aaf3e88011be5e7f48710088fb5e4", "shasum": "" }, "require": { @@ -5112,7 +5041,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v5.3.7" + "source": "https://github.com/symfony/process/tree/v5.4.2" }, "funding": [ { @@ -5128,25 +5057,25 @@ "type": "tidelift" } ], - "time": "2021-08-04T21:20:46+00:00" + "time": "2021-12-27T21:01:00+00:00" }, { "name": "symfony/routing", - "version": "v5.3.7", + "version": "v5.4.0", "source": { "type": "git", "url": "https://github.com/symfony/routing.git", - "reference": "be865017746fe869007d94220ad3f5297951811b" + "reference": "9eeae93c32ca86746e5d38f3679e9569981038b1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/routing/zipball/be865017746fe869007d94220ad3f5297951811b", - "reference": "be865017746fe869007d94220ad3f5297951811b", + "url": "https://api.github.com/repos/symfony/routing/zipball/9eeae93c32ca86746e5d38f3679e9569981038b1", + "reference": "9eeae93c32ca86746e5d38f3679e9569981038b1", "shasum": "" }, "require": { "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1", + "symfony/deprecation-contracts": "^2.1|^3", "symfony/polyfill-php80": "^1.16" }, "conflict": { @@ -5158,11 +5087,11 @@ "require-dev": { "doctrine/annotations": "^1.12", "psr/log": "^1|^2|^3", - "symfony/config": "^5.3", - "symfony/dependency-injection": "^4.4|^5.0", - "symfony/expression-language": "^4.4|^5.0", - "symfony/http-foundation": "^4.4|^5.0", - "symfony/yaml": "^4.4|^5.0" + "symfony/config": "^5.3|^6.0", + "symfony/dependency-injection": "^4.4|^5.0|^6.0", + "symfony/expression-language": "^4.4|^5.0|^6.0", + "symfony/http-foundation": "^4.4|^5.0|^6.0", + "symfony/yaml": "^4.4|^5.0|^6.0" }, "suggest": { "symfony/config": "For using the all-in-one router or any loader", @@ -5202,7 +5131,7 @@ "url" ], "support": { - "source": "https://github.com/symfony/routing/tree/v5.3.7" + "source": "https://github.com/symfony/routing/tree/v5.4.0" }, "funding": [ { @@ -5218,26 +5147,29 @@ "type": "tidelift" } ], - "time": "2021-08-04T21:42:42+00:00" + "time": "2021-11-23T10:19:22+00:00" }, { "name": "symfony/service-contracts", - "version": "v2.4.0", + "version": "v2.4.1", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "f040a30e04b57fbcc9c6cbcf4dbaa96bd318b9bb" + "reference": "d664541b99d6fb0247ec5ff32e87238582236204" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/f040a30e04b57fbcc9c6cbcf4dbaa96bd318b9bb", - "reference": "f040a30e04b57fbcc9c6cbcf4dbaa96bd318b9bb", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/d664541b99d6fb0247ec5ff32e87238582236204", + "reference": "d664541b99d6fb0247ec5ff32e87238582236204", "shasum": "" }, "require": { "php": ">=7.2.5", "psr/container": "^1.1" }, + "conflict": { + "ext-psr": "<1.1|>=2" + }, "suggest": { "symfony/service-implementation": "" }, @@ -5281,7 +5213,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v2.4.0" + "source": "https://github.com/symfony/service-contracts/tree/v2.4.1" }, "funding": [ { @@ -5297,35 +5229,37 @@ "type": "tidelift" } ], - "time": "2021-04-01T10:43:52+00:00" + "time": "2021-11-04T16:37:19+00:00" }, { "name": "symfony/string", - "version": "v5.3.10", + "version": "v6.0.2", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "d70c35bb20bbca71fc4ab7921e3c6bda1a82a60c" + "reference": "bae261d0c3ac38a1f802b4dfed42094296100631" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/d70c35bb20bbca71fc4ab7921e3c6bda1a82a60c", - "reference": "d70c35bb20bbca71fc4ab7921e3c6bda1a82a60c", + "url": "https://api.github.com/repos/symfony/string/zipball/bae261d0c3ac38a1f802b4dfed42094296100631", + "reference": "bae261d0c3ac38a1f802b4dfed42094296100631", "shasum": "" }, "require": { - "php": ">=7.2.5", + "php": ">=8.0.2", "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-intl-grapheme": "~1.0", "symfony/polyfill-intl-normalizer": "~1.0", - "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php80": "~1.15" + "symfony/polyfill-mbstring": "~1.0" + }, + "conflict": { + "symfony/translation-contracts": "<2.0" }, "require-dev": { - "symfony/error-handler": "^4.4|^5.0", - "symfony/http-client": "^4.4|^5.0", - "symfony/translation-contracts": "^1.1|^2", - "symfony/var-exporter": "^4.4|^5.0" + "symfony/error-handler": "^5.4|^6.0", + "symfony/http-client": "^5.4|^6.0", + "symfony/translation-contracts": "^2.0|^3.0", + "symfony/var-exporter": "^5.4|^6.0" }, "type": "library", "autoload": { @@ -5364,7 +5298,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.3.10" + "source": "https://github.com/symfony/string/tree/v6.0.2" }, "funding": [ { @@ -5380,50 +5314,50 @@ "type": "tidelift" } ], - "time": "2021-10-27T18:21:46+00:00" + "time": "2021-12-16T22:13:01+00:00" }, { "name": "symfony/translation", - "version": "v5.3.10", + "version": "v6.0.2", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "6ef197aea2ac8b9cd63e0da7522b3771714035aa" + "reference": "a16c33f93e2fd62d259222aebf792158e9a28a77" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/6ef197aea2ac8b9cd63e0da7522b3771714035aa", - "reference": "6ef197aea2ac8b9cd63e0da7522b3771714035aa", + "url": "https://api.github.com/repos/symfony/translation/zipball/a16c33f93e2fd62d259222aebf792158e9a28a77", + "reference": "a16c33f93e2fd62d259222aebf792158e9a28a77", "shasum": "" }, "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1", + "php": ">=8.0.2", "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php80": "^1.16", - "symfony/translation-contracts": "^2.3" + "symfony/translation-contracts": "^2.3|^3.0" }, "conflict": { - "symfony/config": "<4.4", - "symfony/dependency-injection": "<5.0", - "symfony/http-kernel": "<5.0", - "symfony/twig-bundle": "<5.0", - "symfony/yaml": "<4.4" + "symfony/config": "<5.4", + "symfony/console": "<5.4", + "symfony/dependency-injection": "<5.4", + "symfony/http-kernel": "<5.4", + "symfony/twig-bundle": "<5.4", + "symfony/yaml": "<5.4" }, "provide": { - "symfony/translation-implementation": "2.3" + "symfony/translation-implementation": "2.3|3.0" }, "require-dev": { "psr/log": "^1|^2|^3", - "symfony/config": "^4.4|^5.0", - "symfony/console": "^4.4|^5.0", - "symfony/dependency-injection": "^5.0", - "symfony/finder": "^4.4|^5.0", - "symfony/http-kernel": "^5.0", - "symfony/intl": "^4.4|^5.0", + "symfony/config": "^5.4|^6.0", + "symfony/console": "^5.4|^6.0", + "symfony/dependency-injection": "^5.4|^6.0", + "symfony/finder": "^5.4|^6.0", + "symfony/http-client-contracts": "^1.1|^2.0|^3.0", + "symfony/http-kernel": "^5.4|^6.0", + "symfony/intl": "^5.4|^6.0", "symfony/polyfill-intl-icu": "^1.21", - "symfony/service-contracts": "^1.1.2|^2", - "symfony/yaml": "^4.4|^5.0" + "symfony/service-contracts": "^1.1.2|^2|^3", + "symfony/yaml": "^5.4|^6.0" }, "suggest": { "psr/log-implementation": "To use logging capability in translator", @@ -5459,7 +5393,7 @@ "description": "Provides tools to internationalize your application", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/translation/tree/v5.3.10" + "source": "https://github.com/symfony/translation/tree/v6.0.2" }, "funding": [ { @@ -5475,24 +5409,24 @@ "type": "tidelift" } ], - "time": "2021-10-10T06:43:24+00:00" + "time": "2021-12-25T20:10:03+00:00" }, { "name": "symfony/translation-contracts", - "version": "v2.4.0", + "version": "v3.0.0", "source": { "type": "git", "url": "https://github.com/symfony/translation-contracts.git", - "reference": "95c812666f3e91db75385749fe219c5e494c7f95" + "reference": "1b6ea5a7442af5a12dba3dbd6d71034b5b234e77" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/95c812666f3e91db75385749fe219c5e494c7f95", - "reference": "95c812666f3e91db75385749fe219c5e494c7f95", + "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/1b6ea5a7442af5a12dba3dbd6d71034b5b234e77", + "reference": "1b6ea5a7442af5a12dba3dbd6d71034b5b234e77", "shasum": "" }, "require": { - "php": ">=7.2.5" + "php": ">=8.0.2" }, "suggest": { "symfony/translation-implementation": "" @@ -5500,7 +5434,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "2.4-dev" + "dev-main": "3.0-dev" }, "thanks": { "name": "symfony/contracts", @@ -5537,7 +5471,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/translation-contracts/tree/v2.4.0" + "source": "https://github.com/symfony/translation-contracts/tree/v3.0.0" }, "funding": [ { @@ -5553,20 +5487,20 @@ "type": "tidelift" } ], - "time": "2021-03-23T23:28:01+00:00" + "time": "2021-09-07T12:43:40+00:00" }, { "name": "symfony/var-dumper", - "version": "v5.3.10", + "version": "v5.4.2", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "875432adb5f5570fff21036fd22aee244636b7d1" + "reference": "1b56c32c3679002b3a42384a580e16e2600f41c1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/875432adb5f5570fff21036fd22aee244636b7d1", - "reference": "875432adb5f5570fff21036fd22aee244636b7d1", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/1b56c32c3679002b3a42384a580e16e2600f41c1", + "reference": "1b56c32c3679002b3a42384a580e16e2600f41c1", "shasum": "" }, "require": { @@ -5580,8 +5514,9 @@ }, "require-dev": { "ext-iconv": "*", - "symfony/console": "^4.4|^5.0", - "symfony/process": "^4.4|^5.0", + "symfony/console": "^4.4|^5.0|^6.0", + "symfony/process": "^4.4|^5.0|^6.0", + "symfony/uid": "^5.1|^6.0", "twig/twig": "^2.13|^3.0.4" }, "suggest": { @@ -5625,7 +5560,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v5.3.10" + "source": "https://github.com/symfony/var-dumper/tree/v5.4.2" }, "funding": [ { @@ -5641,30 +5576,30 @@ "type": "tidelift" } ], - "time": "2021-10-26T09:30:15+00:00" + "time": "2021-12-29T10:10:35+00:00" }, { "name": "tijsverkoyen/css-to-inline-styles", - "version": "2.2.3", + "version": "2.2.4", "source": { "type": "git", "url": "https://github.com/tijsverkoyen/CssToInlineStyles.git", - "reference": "b43b05cf43c1b6d849478965062b6ef73e223bb5" + "reference": "da444caae6aca7a19c0c140f68c6182e337d5b1c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/tijsverkoyen/CssToInlineStyles/zipball/b43b05cf43c1b6d849478965062b6ef73e223bb5", - "reference": "b43b05cf43c1b6d849478965062b6ef73e223bb5", + "url": "https://api.github.com/repos/tijsverkoyen/CssToInlineStyles/zipball/da444caae6aca7a19c0c140f68c6182e337d5b1c", + "reference": "da444caae6aca7a19c0c140f68c6182e337d5b1c", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "php": "^5.5 || ^7.0 || ^8.0", - "symfony/css-selector": "^2.7 || ^3.0 || ^4.0 || ^5.0" + "symfony/css-selector": "^2.7 || ^3.0 || ^4.0 || ^5.0 || ^6.0" }, "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0 || ^7.5" + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0 || ^7.5 || ^8.5.21 || ^9.5.10" }, "type": "library", "extra": { @@ -5692,22 +5627,22 @@ "homepage": "https://github.com/tijsverkoyen/CssToInlineStyles", "support": { "issues": "https://github.com/tijsverkoyen/CssToInlineStyles/issues", - "source": "https://github.com/tijsverkoyen/CssToInlineStyles/tree/2.2.3" + "source": "https://github.com/tijsverkoyen/CssToInlineStyles/tree/2.2.4" }, - "time": "2020-07-13T06:12:54+00:00" + "time": "2021-12-08T09:12:39+00:00" }, { "name": "vlucas/phpdotenv", - "version": "v5.4.0", + "version": "v5.4.1", "source": { "type": "git", "url": "https://github.com/vlucas/phpdotenv.git", - "reference": "d4394d044ed69a8f244f3445bcedf8a0d7fe2403" + "reference": "264dce589e7ce37a7ba99cb901eed8249fbec92f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/d4394d044ed69a8f244f3445bcedf8a0d7fe2403", - "reference": "d4394d044ed69a8f244f3445bcedf8a0d7fe2403", + "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/264dce589e7ce37a7ba99cb901eed8249fbec92f", + "reference": "264dce589e7ce37a7ba99cb901eed8249fbec92f", "shasum": "" }, "require": { @@ -5745,11 +5680,13 @@ "authors": [ { "name": "Graham Campbell", - "email": "hello@gjcampbell.co.uk" + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" }, { "name": "Vance Lucas", - "email": "vance@vancelucas.com" + "email": "vance@vancelucas.com", + "homepage": "https://github.com/vlucas" } ], "description": "Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.", @@ -5760,7 +5697,7 @@ ], "support": { "issues": "https://github.com/vlucas/phpdotenv/issues", - "source": "https://github.com/vlucas/phpdotenv/tree/v5.4.0" + "source": "https://github.com/vlucas/phpdotenv/tree/v5.4.1" }, "funding": [ { @@ -5772,7 +5709,7 @@ "type": "tidelift" } ], - "time": "2021-11-10T01:08:39+00:00" + "time": "2021-12-12T23:22:04+00:00" }, { "name": "voku/portable-ascii", @@ -6032,22 +5969,22 @@ }, { "name": "fakerphp/faker", - "version": "v1.16.0", + "version": "v1.17.0", "source": { "type": "git", "url": "https://github.com/FakerPHP/Faker.git", - "reference": "271d384d216e5e5c468a6b28feedf95d49f83b35" + "reference": "b85e9d44eae8c52cca7aa0939483611f7232b669" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FakerPHP/Faker/zipball/271d384d216e5e5c468a6b28feedf95d49f83b35", - "reference": "271d384d216e5e5c468a6b28feedf95d49f83b35", + "url": "https://api.github.com/repos/FakerPHP/Faker/zipball/b85e9d44eae8c52cca7aa0939483611f7232b669", + "reference": "b85e9d44eae8c52cca7aa0939483611f7232b669", "shasum": "" }, "require": { "php": "^7.1 || ^8.0", "psr/container": "^1.0 || ^2.0", - "symfony/deprecation-contracts": "^2.2" + "symfony/deprecation-contracts": "^2.2 || ^3.0" }, "conflict": { "fzaninotto/faker": "*" @@ -6066,7 +6003,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "v1.16-dev" + "dev-main": "v1.17-dev" } }, "autoload": { @@ -6091,22 +6028,22 @@ ], "support": { "issues": "https://github.com/FakerPHP/Faker/issues", - "source": "https://github.com/FakerPHP/Faker/tree/v1.16.0" + "source": "https://github.com/FakerPHP/Faker/tree/v1.17.0" }, - "time": "2021-09-06T14:53:37+00:00" + "time": "2021-12-05T17:14:47+00:00" }, { "name": "filp/whoops", - "version": "2.14.4", + "version": "2.14.5", "source": { "type": "git", "url": "https://github.com/filp/whoops.git", - "reference": "f056f1fe935d9ed86e698905a957334029899895" + "reference": "a63e5e8f26ebbebf8ed3c5c691637325512eb0dc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filp/whoops/zipball/f056f1fe935d9ed86e698905a957334029899895", - "reference": "f056f1fe935d9ed86e698905a957334029899895", + "url": "https://api.github.com/repos/filp/whoops/zipball/a63e5e8f26ebbebf8ed3c5c691637325512eb0dc", + "reference": "a63e5e8f26ebbebf8ed3c5c691637325512eb0dc", "shasum": "" }, "require": { @@ -6156,7 +6093,7 @@ ], "support": { "issues": "https://github.com/filp/whoops/issues", - "source": "https://github.com/filp/whoops/tree/2.14.4" + "source": "https://github.com/filp/whoops/tree/2.14.5" }, "funding": [ { @@ -6164,7 +6101,7 @@ "type": "github" } ], - "time": "2021-10-03T12:00:00+00:00" + "time": "2022-01-07T12:00:00+00:00" }, { "name": "hamcrest/hamcrest-php", @@ -6306,9 +6243,6 @@ "require": { "php": "^7.1 || ^8.0" }, - "replace": { - "myclabs/deep-copy": "self.version" - }, "require-dev": { "doctrine/collections": "^1.0", "doctrine/common": "^2.6", @@ -6349,16 +6283,16 @@ }, { "name": "nunomaduro/collision", - "version": "v5.10.0", + "version": "v5.11.0", "source": { "type": "git", "url": "https://github.com/nunomaduro/collision.git", - "reference": "3004cfa49c022183395eabc6d0e5207dfe498d00" + "reference": "8b610eef8582ccdc05d8f2ab23305e2d37049461" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nunomaduro/collision/zipball/3004cfa49c022183395eabc6d0e5207dfe498d00", - "reference": "3004cfa49c022183395eabc6d0e5207dfe498d00", + "url": "https://api.github.com/repos/nunomaduro/collision/zipball/8b610eef8582ccdc05d8f2ab23305e2d37049461", + "reference": "8b610eef8582ccdc05d8f2ab23305e2d37049461", "shasum": "" }, "require": { @@ -6420,7 +6354,7 @@ }, "funding": [ { - "url": "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=66BYDWAT92N6L", + "url": "https://www.paypal.com/paypalme/enunomaduro", "type": "custom" }, { @@ -6432,7 +6366,7 @@ "type": "patreon" } ], - "time": "2021-09-20T15:06:32+00:00" + "time": "2022-01-10T16:22:52+00:00" }, { "name": "phar-io/manifest", @@ -6657,16 +6591,16 @@ }, { "name": "phpdocumentor/type-resolver", - "version": "1.5.1", + "version": "1.6.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "a12f7e301eb7258bb68acd89d4aefa05c2906cae" + "reference": "93ebd0014cab80c4ea9f5e297ea48672f1b87706" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/a12f7e301eb7258bb68acd89d4aefa05c2906cae", - "reference": "a12f7e301eb7258bb68acd89d4aefa05c2906cae", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/93ebd0014cab80c4ea9f5e297ea48672f1b87706", + "reference": "93ebd0014cab80c4ea9f5e297ea48672f1b87706", "shasum": "" }, "require": { @@ -6701,22 +6635,22 @@ "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", "support": { "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.5.1" + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.0" }, - "time": "2021-10-02T14:08:47+00:00" + "time": "2022-01-04T19:58:01+00:00" }, { "name": "phpspec/prophecy", - "version": "1.14.0", + "version": "v1.15.0", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e" + "reference": "bbcd7380b0ebf3961ee21409db7b38bc31d69a13" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e", - "reference": "d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/bbcd7380b0ebf3961ee21409db7b38bc31d69a13", + "reference": "bbcd7380b0ebf3961ee21409db7b38bc31d69a13", "shasum": "" }, "require": { @@ -6768,22 +6702,22 @@ ], "support": { "issues": "https://github.com/phpspec/prophecy/issues", - "source": "https://github.com/phpspec/prophecy/tree/1.14.0" + "source": "https://github.com/phpspec/prophecy/tree/v1.15.0" }, - "time": "2021-09-10T09:02:12+00:00" + "time": "2021-12-08T12:19:24+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "9.2.8", + "version": "9.2.10", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "cf04e88a2e3c56fc1a65488afd493325b4c1bc3e" + "reference": "d5850aaf931743067f4bfc1ae4cbd06468400687" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/cf04e88a2e3c56fc1a65488afd493325b4c1bc3e", - "reference": "cf04e88a2e3c56fc1a65488afd493325b4c1bc3e", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/d5850aaf931743067f4bfc1ae4cbd06468400687", + "reference": "d5850aaf931743067f4bfc1ae4cbd06468400687", "shasum": "" }, "require": { @@ -6839,7 +6773,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.8" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.10" }, "funding": [ { @@ -6847,20 +6781,20 @@ "type": "github" } ], - "time": "2021-10-30T08:01:38+00:00" + "time": "2021-12-05T09:12:13+00:00" }, { "name": "phpunit/php-file-iterator", - "version": "3.0.5", + "version": "3.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "aa4be8575f26070b100fccb67faabb28f21f66f8" + "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/aa4be8575f26070b100fccb67faabb28f21f66f8", - "reference": "aa4be8575f26070b100fccb67faabb28f21f66f8", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", + "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", "shasum": "" }, "require": { @@ -6899,7 +6833,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", - "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.5" + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.6" }, "funding": [ { @@ -6907,7 +6841,7 @@ "type": "github" } ], - "time": "2020-09-28T05:57:25+00:00" + "time": "2021-12-02T12:48:52+00:00" }, { "name": "phpunit/php-invoker", @@ -7092,16 +7026,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.5.10", + "version": "9.5.11", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "c814a05837f2edb0d1471d6e3f4ab3501ca3899a" + "reference": "2406855036db1102126125537adb1406f7242fdd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c814a05837f2edb0d1471d6e3f4ab3501ca3899a", - "reference": "c814a05837f2edb0d1471d6e3f4ab3501ca3899a", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/2406855036db1102126125537adb1406f7242fdd", + "reference": "2406855036db1102126125537adb1406f7242fdd", "shasum": "" }, "require": { @@ -7179,11 +7113,11 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.10" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.11" }, "funding": [ { - "url": "https://phpunit.de/donate.html", + "url": "https://phpunit.de/sponsors.html", "type": "custom" }, { @@ -7191,7 +7125,7 @@ "type": "github" } ], - "time": "2021-09-25T07:38:51+00:00" + "time": "2021-12-25T07:07:57+00:00" }, { "name": "roave/security-advisories", @@ -7199,12 +7133,12 @@ "source": { "type": "git", "url": "https://github.com/Roave/SecurityAdvisories.git", - "reference": "bac54e18ee767f065d88b81c8517fb21cd6414ab" + "reference": "11696ae4d8970456cbd1919c17e6bb2ddb63553a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/bac54e18ee767f065d88b81c8517fb21cd6414ab", - "reference": "bac54e18ee767f065d88b81c8517fb21cd6414ab", + "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/11696ae4d8970456cbd1919c17e6bb2ddb63553a", + "reference": "11696ae4d8970456cbd1919c17e6bb2ddb63553a", "shasum": "" }, "conflict": { @@ -7216,17 +7150,20 @@ "amphp/artax": "<1.0.6|>=2,<2.0.6", "amphp/http": "<1.0.1", "amphp/http-client": ">=4,<4.4", + "anchorcms/anchor-cms": "<=0.12.7", "api-platform/core": ">=2.2,<2.2.10|>=2.3,<2.3.6", + "area17/twill": "<1.2.5|>=2,<2.5.3", "asymmetricrypt/asymmetricrypt": ">=0,<9.9.99", "aws/aws-sdk-php": ">=3,<3.2.1", "bagisto/bagisto": "<0.1.5", "barrelstrength/sprout-base-email": "<1.2.7", "barrelstrength/sprout-forms": "<3.9", - "baserproject/basercms": "<=4.5", + "baserproject/basercms": "<4.5.4", "billz/raspap-webgui": "<=2.6.6", "bk2k/bootstrap-package": ">=7.1,<7.1.2|>=8,<8.0.8|>=9,<9.0.4|>=9.1,<9.1.3|>=10,<10.0.10|>=11,<11.0.3", "bolt/bolt": "<3.7.2", "bolt/core": "<4.1.13", + "bottelet/flarepoint": "<2.2.1", "brightlocal/phpwhois": "<=4.2.5", "buddypress/buddypress": "<7.2.1", "bugsnag/bugsnag-laravel": ">=2,<2.0.2", @@ -7240,9 +7177,11 @@ "cesnet/simplesamlphp-module-proxystatistics": "<3.1", "codeception/codeception": "<3.1.3|>=4,<4.1.22", "codeigniter/framework": "<=3.0.6", + "codeigniter4/framework": "<4.1.6", "codiad/codiad": "<=2.8.4", "composer/composer": "<1.10.23|>=2-alpha.1,<2.1.9", "concrete5/concrete5": "<8.5.5", + "concrete5/core": "<8.5.7", "contao-components/mediaelement": ">=2.14.2,<2.21.1", "contao/core": ">=2,<3.5.39", "contao/core-bundle": ">=4,<4.4.56|>=4.5,<4.9.18|>=4.10,<4.11.7|= 4.10.0", @@ -7256,7 +7195,7 @@ "doctrine/annotations": ">=1,<1.2.7", "doctrine/cache": ">=1,<1.3.2|>=1.4,<1.4.2", "doctrine/common": ">=2,<2.4.3|>=2.5,<2.5.1", - "doctrine/dbal": ">=2,<2.0.8|>=2.1,<2.1.2", + "doctrine/dbal": ">=2,<2.0.8|>=2.1,<2.1.2|>=3,<3.1.4", "doctrine/doctrine-bundle": "<1.5.2", "doctrine/doctrine-module": "<=0.7.1", "doctrine/mongodb-odm": ">=1,<1.0.2", @@ -7268,6 +7207,7 @@ "drupal/drupal": ">=7,<7.80|>=8,<8.9.16|>=9,<9.1.12|>=9.2,<9.2.4", "dweeves/magmi": "<=0.7.24", "ecodev/newsletter": "<=4", + "elgg/elgg": "<3.3.24|>=4,<4.0.5", "endroid/qr-code-bundle": "<3.4.2", "enshrined/svg-sanitize": "<0.13.1", "erusev/parsedown": "<1.7.2", @@ -7277,17 +7217,18 @@ "ezsystems/ezdemo-ls-extension": ">=5.4,<5.4.2.1", "ezsystems/ezfind-ls": ">=5.3,<5.3.6.1|>=5.4,<5.4.11.1|>=2017.12,<2017.12.0.1", "ezsystems/ezplatform": "<=1.13.6|>=2,<=2.5.24", - "ezsystems/ezplatform-admin-ui": ">=1.3,<1.3.5|>=1.4,<1.4.6", + "ezsystems/ezplatform-admin-ui": ">=1.3,<1.3.5|>=1.4,<1.4.6|>=1.5,<=1.5.25", "ezsystems/ezplatform-admin-ui-assets": ">=4,<4.2.1|>=5,<5.0.1|>=5.1,<5.1.1", "ezsystems/ezplatform-kernel": "<=1.2.5|>=1.3,<=1.3.1", "ezsystems/ezplatform-rest": ">=1.2,<=1.2.2|>=1.3,<1.3.8", + "ezsystems/ezplatform-richtext": ">=2.3,<=2.3.7", "ezsystems/ezplatform-user": ">=1,<1.0.1", "ezsystems/ezpublish-kernel": "<=6.13.8.1|>=7,<=7.5.15.1", "ezsystems/ezpublish-legacy": "<=2017.12.7.3|>=2018.6,<=2019.3.5.1", "ezsystems/platform-ui-assets-bundle": ">=4.2,<4.2.3", "ezsystems/repository-forms": ">=2.3,<2.3.2.1", "ezyang/htmlpurifier": "<4.1.1", - "facade/ignition": "<2.4.2|>=2.5,<2.5.2", + "facade/ignition": "<1.16.15|>=2,<2.4.2|>=2.5,<2.5.2", "feehi/cms": "<=2.1.1", "feehi/feehicms": "<=0.1.3", "firebase/php-jwt": "<2", @@ -7298,54 +7239,60 @@ "fooman/tcpdf": "<6.2.22", "forkcms/forkcms": "<=5.9.2", "fossar/tcpdf-parser": "<6.2.22", - "francoisjacquet/rosariosis": "<6.5.1", + "francoisjacquet/rosariosis": "<8.1.1", "friendsofsymfony/oauth2-php": "<1.3", "friendsofsymfony/rest-bundle": ">=1.2,<1.2.2", "friendsofsymfony/user-bundle": ">=1.2,<1.3.5", "friendsoftypo3/mediace": ">=7.6.2,<7.6.5", "froala/wysiwyg-editor": "<3.2.7", "fuel/core": "<1.8.1", + "gaoming13/wechat-php-sdk": "<=1.10.2", "getgrav/grav": "<=1.7.24", - "getkirby/cms": "<=3.5.6", + "getkirby/cms": "<3.5.8", "getkirby/panel": "<2.5.14", "gilacms/gila": "<=1.11.4", "globalpayments/php-sdk": "<2", "gos/web-socket-bundle": "<1.10.4|>=2,<2.6.1|>=3,<3.3", "gree/jose": "<=2.2", "gregwar/rst": "<1.0.3", - "grumpydictator/firefly-iii": "<=5.6.2", + "grumpydictator/firefly-iii": "<5.6.5", "guzzlehttp/guzzle": ">=4-rc.2,<4.2.4|>=5,<5.3.1|>=6,<6.2.1", "helloxz/imgurl": "<=2.31", + "hillelcoren/invoice-ninja": "<5.3.35", "hjue/justwriting": "<=1", + "hov/jobfair": "<1.0.13|>=2,<2.0.2", "ibexa/post-install": "<=1.0.4", "icecoder/icecoder": "<=8", "illuminate/auth": ">=4,<4.0.99|>=4.1,<=4.1.31|>=4.2,<=4.2.22|>=5,<=5.0.35|>=5.1,<=5.1.46|>=5.2,<=5.2.45|>=5.3,<=5.3.31|>=5.4,<=5.4.36|>=5.5,<5.5.10", "illuminate/cookie": ">=4,<=4.0.11|>=4.1,<=4.1.99999|>=4.2,<=4.2.99999|>=5,<=5.0.99999|>=5.1,<=5.1.99999|>=5.2,<=5.2.99999|>=5.3,<=5.3.99999|>=5.4,<=5.4.99999|>=5.5,<=5.5.49|>=5.6,<=5.6.99999|>=5.7,<=5.7.99999|>=5.8,<=5.8.99999|>=6,<6.18.31|>=7,<7.22.4", - "illuminate/database": "<6.20.26|>=7,<8.40", + "illuminate/database": "<6.20.26|>=7,<7.30.5|>=8,<8.40", "illuminate/encryption": ">=4,<=4.0.11|>=4.1,<=4.1.31|>=4.2,<=4.2.22|>=5,<=5.0.35|>=5.1,<=5.1.46|>=5.2,<=5.2.45|>=5.3,<=5.3.31|>=5.4,<=5.4.36|>=5.5,<5.5.40|>=5.6,<5.6.15", - "illuminate/view": ">=7,<7.1.2", + "illuminate/view": "<6.20.42|>=7,<7.30.6|>=8,<8.75", "impresscms/impresscms": "<=1.4.2", "in2code/femanager": "<5.5.1|>=6,<6.3.1", "intelliants/subrion": "<=4.2.1", "ivankristianto/phpwhois": "<=4.3", + "jackalope/jackalope-doctrine-dbal": "<1.7.4", "james-heinrich/getid3": "<1.9.21", "joomla/archive": "<1.1.10", "joomla/session": "<1.3.1", "jsmitty12/phpwhois": "<5.1", "kazist/phpwhois": "<=4.2.6", + "kevinpapst/kimai2": "<1.16.7", "kitodo/presentation": "<3.1.2", "klaviyo/magento2-extension": ">=1,<3", "kreait/firebase-php": ">=3.2,<3.8.1", "la-haute-societe/tcpdf": "<6.2.22", "laminas/laminas-http": "<2.14.2", - "laravel/framework": "<6.20.26|>=7,<8.40", + "laravel/framework": "<6.20.42|>=7,<7.30.6|>=8,<8.75", "laravel/socialite": ">=1,<1.0.99|>=2,<2.0.10", + "latte/latte": "<2.10.8", "lavalite/cms": "<=5.8", "lcobucci/jwt": ">=3.4,<3.4.6|>=4,<4.0.4|>=4.1,<4.1.5", "league/commonmark": "<0.18.3", "league/flysystem": "<1.1.4|>=2,<2.1.1", "lexik/jwt-authentication-bundle": "<2.10.7|>=2.11,<2.11.3", - "librenms/librenms": "<=21.10.2", + "librenms/librenms": "<=21.11", "limesurvey/limesurvey": "<3.27.19", "livewire/livewire": ">2.2.4,<2.2.6", "lms/routes": "<2.1.1", @@ -7362,13 +7309,14 @@ "mittwald/typo3_forum": "<1.2.1", "modx/revolution": "<2.8", "monolog/monolog": ">=1.8,<1.12", - "moodle/moodle": "<3.5.17|>=3.7,<3.7.9|>=3.8,<3.8.8|>=3.9,<3.9.5|>=3.10-beta,<3.10.2", + "moodle/moodle": "<3.7.9|>=3.8,<3.8.8|>=3.9,<3.9.5|>=3.10-beta,<3.10.2", "namshi/jose": "<2.2", "neoan3-apps/template": "<1.1.1", "neos/flow": ">=1,<1.0.4|>=1.1,<1.1.1|>=2,<2.0.1|>=2.3,<2.3.16|>=3,<3.0.12|>=3.1,<3.1.10|>=3.2,<3.2.13|>=3.3,<3.3.13|>=4,<4.0.6", "neos/form": ">=1.2,<4.3.3|>=5,<5.0.9|>=5.1,<5.1.3", "neos/neos": ">=1.1,<1.1.3|>=1.2,<1.2.13|>=2,<2.0.4|>=2.3,<2.9.99|>=3,<3.0.20|>=3.1,<3.1.18|>=3.2,<3.2.14|>=3.3,<3.3.23|>=4,<4.0.17|>=4.1,<4.1.16|>=4.2,<4.2.12|>=4.3,<4.3.3", "neos/swiftmailer": ">=4.1,<4.1.99|>=5.4,<5.4.5", + "netgen/tagsbundle": ">=3.4,<3.4.11|>=4,<4.0.15", "nette/application": ">=2,<2.0.19|>=2.1,<2.1.13|>=2.2,<2.2.10|>=2.3,<2.3.14|>=2.4,<2.4.16|>=3,<3.0.6", "nette/nette": ">=2,<2.0.19|>=2.1,<2.1.13", "nilsteampassnet/teampass": "<=2.1.27.36", @@ -7386,8 +7334,8 @@ "openid/php-openid": "<2.3", "openmage/magento-lts": "<19.4.15|>=20,<20.0.13", "orchid/platform": ">=9,<9.4.4", - "oro/crm": ">=1.7,<1.7.4", - "oro/platform": ">=1.7,<1.7.4", + "oro/crm": ">=1.7,<1.7.4|>=3.1,<4.1.17|>=4.2,<4.2.7", + "oro/platform": ">=1.7,<1.7.4|>=3.1,<3.1.21|>=4.1,<4.1.14|>=4.2,<4.2.8", "padraic/humbug_get_contents": "<1.1.2", "pagarme/pagarme-php": ">=0,<3", "pagekit/pagekit": "<=1.0.18", @@ -7395,6 +7343,7 @@ "passbolt/passbolt_api": "<2.11", "paypal/merchant-sdk-php": "<3.12", "pear/archive_tar": "<1.4.14", + "pegasus/google-for-jobs": "<1.5.1|>=2,<2.1.1", "personnummer/personnummer": "<3.0.2", "phanan/koel": "<5.1.4", "phpfastcache/phpfastcache": "<6.1.5|>=7,<7.1.2|>=8,<8.0.7", @@ -7404,15 +7353,17 @@ "phpoffice/phpexcel": "<1.8.2", "phpoffice/phpspreadsheet": "<1.16", "phpseclib/phpseclib": "<2.0.31|>=3,<3.0.7", + "phpservermon/phpservermon": "<=3.5.2", "phpunit/phpunit": ">=4.8.19,<4.8.28|>=5.0.10,<5.6.3", "phpwhois/phpwhois": "<=4.2.5", "phpxmlrpc/extras": "<0.6.1", - "pimcore/pimcore": "<10.1.3", - "pocketmine/pocketmine-mp": "<3.15.4", + "pimcore/pimcore": "<10.2.7", + "pocketmine/pocketmine-mp": "<4.0.5", "pressbooks/pressbooks": "<5.18", "prestashop/autoupgrade": ">=4,<4.10.1", "prestashop/contactform": ">1.0.1,<4.3", "prestashop/gamification": "<2.3.2", + "prestashop/prestashop": ">=1.7.5,<=1.7.8.1", "prestashop/productcomments": ">=4,<4.2.1", "prestashop/ps_emailsubscription": "<2.6.1", "prestashop/ps_facetedsearch": "<3.4.1", @@ -7420,10 +7371,11 @@ "privatebin/privatebin": "<1.2.2|>=1.3,<1.3.2", "propel/propel": ">=2-alpha.1,<=2-alpha.7", "propel/propel1": ">=1,<=1.7.1", - "pterodactyl/panel": "<0.7.19|>=1-rc.0,<=1-rc.6|>=1,<1.6.3", + "pterodactyl/panel": "<1.6.6", "pusher/pusher-php-server": "<2.2.1", "pwweb/laravel-core": "<=0.3.6-beta", "rainlab/debugbar-plugin": "<3.1", + "remdex/livehelperchat": "<3.91", "rmccue/requests": ">=1.6,<1.8", "robrichards/xmlseclibs": "<3.0.4", "sabberworm/php-css-parser": ">=1,<1.0.1|>=2,<2.0.1|>=3,<3.0.1|>=4,<4.0.1|>=5,<5.0.9|>=5.1,<5.1.3|>=5.2,<5.2.1|>=6,<6.0.2|>=7,<7.0.4|>=8,<8.0.1|>=8.1,<8.1.1|>=8.2,<8.2.1|>=8.3,<8.3.1", @@ -7431,12 +7383,12 @@ "scheb/two-factor-bundle": ">=0,<3.26|>=4,<4.11", "sensiolabs/connect": "<4.2.3", "serluck/phpwhois": "<=4.2.6", - "shopware/core": "<=6.4.3", - "shopware/platform": "<=6.4.3", + "shopware/core": "<=6.4.6", + "shopware/platform": "<=6.4.6", "shopware/production": "<=6.3.5.2", - "shopware/shopware": "<5.7.6", - "showdoc/showdoc": "<=2.9.8", - "silverstripe/admin": "<4.8.1", + "shopware/shopware": "<5.7.7", + "showdoc/showdoc": "<2.10", + "silverstripe/admin": ">=1,<1.8.1", "silverstripe/assets": ">=1,<1.4.7|>=1.5,<1.5.2", "silverstripe/cms": "<4.3.6|>=4.4,<4.4.4", "silverstripe/comments": ">=1.3,<1.9.99|>=2,<2.9.99|>=3,<3.1.1", @@ -7455,16 +7407,16 @@ "simplito/elliptic-php": "<1.0.6", "slim/slim": "<2.6", "smarty/smarty": "<3.1.39", - "snipe/snipe-it": "<5.3", + "snipe/snipe-it": "<5.3.5", "socalnick/scn-social-auth": "<1.15.2", "socialiteproviders/steam": "<1.1", "spoonity/tcpdf": "<6.2.22", "squizlabs/php_codesniffer": ">=1,<2.8.1|>=3,<3.0.1", - "ssddanbrown/bookstack": "<0.29.2", + "ssddanbrown/bookstack": "<21.12.1", "stormpath/sdk": ">=0,<9.9.99", "studio-42/elfinder": "<2.1.59", "subrion/cms": "<=4.2.1", - "sulu/sulu": "<1.6.43|>=2,<2.0.10|>=2.1,<2.1.1", + "sulu/sulu": "= 2.4.0-RC1|<1.6.44|>=2,<2.2.18|>=2.3,<2.3.8", "swiftmailer/swiftmailer": ">=4,<5.4.5", "sylius/admin-bundle": ">=1,<1.0.17|>=1.1,<1.1.9|>=1.2,<1.2.2", "sylius/grid": ">=1,<1.1.19|>=1.2,<1.2.18|>=1.3,<1.3.13|>=1.4,<1.4.5|>=1.5,<1.5.1", @@ -7482,7 +7434,7 @@ "symfony/form": ">=2.3,<2.3.35|>=2.4,<2.6.12|>=2.7,<2.7.50|>=2.8,<2.8.49|>=3,<3.4.20|>=4,<4.0.15|>=4.1,<4.1.9|>=4.2,<4.2.1", "symfony/framework-bundle": ">=2,<2.3.18|>=2.4,<2.4.8|>=2.5,<2.5.2|>=2.7,<2.7.51|>=2.8,<2.8.50|>=3,<3.4.26|>=4,<4.1.12|>=4.2,<4.2.7", "symfony/http-foundation": ">=2,<2.8.52|>=3,<3.4.35|>=4,<4.2.12|>=4.3,<4.3.8|>=4.4,<4.4.7|>=5,<5.0.7", - "symfony/http-kernel": ">=2,<2.8.52|>=3,<3.4.35|>=4,<4.2.12|>=4.3,<4.4.13|>=5,<5.1.5", + "symfony/http-kernel": ">=2,<2.8.52|>=3,<3.4.35|>=4,<4.2.12|>=4.3,<4.4.13|>=5,<5.1.5|>=5.2,<5.3.12", "symfony/intl": ">=2.7,<2.7.38|>=2.8,<2.8.31|>=3,<3.2.14|>=3.3,<3.3.13", "symfony/maker-bundle": ">=1.27,<1.29.2|>=1.30,<1.31.1", "symfony/mime": ">=4.3,<4.3.8", @@ -7492,13 +7444,13 @@ "symfony/proxy-manager-bridge": ">=2.7,<2.7.51|>=2.8,<2.8.50|>=3,<3.4.26|>=4,<4.1.12|>=4.2,<4.2.7", "symfony/routing": ">=2,<2.0.19", "symfony/security": ">=2,<2.7.51|>=2.8,<3.4.49|>=4,<4.4.24|>=5,<5.2.8", - "symfony/security-bundle": ">=2,<2.7.48|>=2.8,<2.8.41|>=3,<3.3.17|>=3.4,<3.4.11|>=4,<4.0.11", + "symfony/security-bundle": ">=2,<2.7.48|>=2.8,<2.8.41|>=3,<3.3.17|>=3.4,<3.4.11|>=4,<4.0.11|>=5.3,<5.3.12", "symfony/security-core": ">=2.4,<2.6.13|>=2.7,<2.7.9|>=2.7.30,<2.7.32|>=2.8,<3.4.49|>=4,<4.4.24|>=5,<5.2.9", "symfony/security-csrf": ">=2.4,<2.7.48|>=2.8,<2.8.41|>=3,<3.3.17|>=3.4,<3.4.11|>=4,<4.0.11", "symfony/security-guard": ">=2.8,<3.4.48|>=4,<4.4.23|>=5,<5.2.8", "symfony/security-http": ">=2.3,<2.3.41|>=2.4,<2.7.51|>=2.8,<3.4.48|>=4,<4.4.23|>=5,<5.2.8|>=5.3,<5.3.2", - "symfony/serializer": ">=2,<2.0.11", - "symfony/symfony": ">=2,<3.4.49|>=4,<4.4.24|>=5,<5.2.9|>=5.3,<5.3.2", + "symfony/serializer": ">=2,<2.0.11|>=4.1,<4.4.35|>=5,<5.3.12", + "symfony/symfony": ">=2,<3.4.49|>=4,<4.4.35|>=5,<5.3.12", "symfony/translation": ">=2,<2.0.17", "symfony/validator": ">=2,<2.0.24|>=2.1,<2.1.12|>=2.2,<2.2.5|>=2.3,<2.3.3", "symfony/var-exporter": ">=4.2,<4.2.12|>=4.3,<4.3.8", @@ -7512,6 +7464,7 @@ "theonedemon/phpwhois": "<=4.2.5", "tinymce/tinymce": "<5.10", "titon/framework": ">=0,<9.9.99", + "topthink/framework": "<6.0.9", "topthink/think": "<=6.0.9", "topthink/thinkphp": "<=3.2.3", "tribalsystems/zenario": "<8.8.53370", @@ -7527,6 +7480,8 @@ "typo3/swiftmailer": ">=4.1,<4.1.99|>=5.4,<5.4.5", "typo3fluid/fluid": ">=2,<2.0.8|>=2.1,<2.1.7|>=2.2,<2.2.4|>=2.3,<2.3.7|>=2.4,<2.4.4|>=2.5,<2.5.11|>=2.6,<2.6.10", "ua-parser/uap-php": "<3.8", + "unisharp/laravel-filemanager": "<=2.3", + "userfrosting/userfrosting": ">=0.3.1,<4.6.3", "usmanhalalit/pixie": "<1.0.3|>=2,<2.0.2", "vanilla/safecurl": "<0.9.2", "verot/class.upload.php": "<=1.0.3|>=2,<=2.0.4", @@ -7538,6 +7493,7 @@ "wikimedia/parsoid": "<0.12.2", "willdurand/js-translation-bundle": "<2.1.1", "wp-cli/wp-cli": "<2.5", + "yetiforce/yetiforce-crm": "<=6.3", "yidashi/yii2cmf": "<=2", "yii2mod/yii2-cms": "<1.9.2", "yiisoft/yii": ">=1.1.14,<1.1.15", @@ -7611,7 +7567,7 @@ "type": "tidelift" } ], - "time": "2021-11-10T17:18:39+00:00" + "time": "2022-01-08T00:53:14+00:00" }, { "name": "sebastian/cli-parser", @@ -8640,5 +8596,5 @@ "ext-json": "*" }, "platform-dev": [], - "plugin-api-version": "2.1.0" + "plugin-api-version": "2.2.0" } From 852f543dfbbcfc9538c5c34fc4cd7e7c864543ca Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Tue, 11 Jan 2022 12:38:03 +0000 Subject: [PATCH 02/73] Update README - Remove files we aren't using - Tweak the Docker setup - Update the README with Docker changes and correct table layouts --- .docker/mysql/Dockerfile | 2 +- .dockerignore | 2 +- README.md | 295 +++++++++++++++++++-------------------- docker-compose.yml | 3 +- testing.sqlite | 0 webpack.mix.js | 15 -- 6 files changed, 151 insertions(+), 166 deletions(-) delete mode 100644 testing.sqlite delete mode 100644 webpack.mix.js diff --git a/.docker/mysql/Dockerfile b/.docker/mysql/Dockerfile index 70feb0c5..15556add 100644 --- a/.docker/mysql/Dockerfile +++ b/.docker/mysql/Dockerfile @@ -1 +1 @@ -FROM mysql:8 +FROM mysql:8.0 diff --git a/.dockerignore b/.dockerignore index 22d0d82f..48b8bf90 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1 @@ -vendor +vendor/ diff --git a/README.md b/README.md index f7926fd1..5e35cce6 100644 --- a/README.md +++ b/README.md @@ -34,13 +34,13 @@ directory and run the below. ### Environment -* $ `docker network create costs-to-expect-network` * -* $ `docker-compose build` -* $ `docker-compose up` +* $ `docker network create costs.network` * +* $ `docker compose build` +* $ `docker compose up` *We include a network for local development purposes, I need the Costs to Expect Website and App to communicate with a local API. You probably don't need this -so remove the network section from the docker-compose file and don't create the +so remove the network section from the docker compose file and don't create the network.* ### API @@ -50,7 +50,7 @@ Docker services, `api` and `mysql`, we will need to exec into the `api` service set up our app. Firstly, we need to check we are trying to access the right location, -execute `docker-compose exec api ls`. You should see a list of the files and +execute `docker compose exec api ls`. You should see a list of the files and directories at the project root. Next, we need to configure the API by setting out local .ENV file our .env, @@ -58,10 +58,9 @@ installing all dependencies and running our migrations. * Copy the `.env.example` file and name the copy `.env`. Set all the empty values, all drivers have been set to our defaults, sessions, cache, and the queue default to the database driver. -* `docker-compose exec api composer install` -* `docker-compose exec api php artisan key:generate` -* `docker-compose exec api php artisan migrate` -* `docker-compose exec api php artisan queue:work` +* `docker compose exec api php artisan key:generate` +* `docker compose exec api php artisan migrate` +* `docker compose exec api php artisan queue:work` * Run an OPTIONS request on `http://[your.domail.local:8080]/v2/resource_types`, you will see an OPTIONS response, alternatively a GET request to `http://[your.domail.local:8080]/v1` will show all the defined routes. * You can create a user by POSTing to `http://[your.domail.local:8080]/v2/auth/register`. @@ -90,20 +89,20 @@ conditional caching, specifically including an Etag header and returning a 304 r Responses will include multiple headers, the table below details the intention behind each of our custom headers. -| Header | Purpose | -| :--- | :--- | -| X-Total-Count | Pagination: Total number of result | -| X-Count | Pagination: Number of results returned | -| X-Limit | Pagination: Limit value applied to request after validation | -| X-Offset | Pagination: Offset value applied to request after validation | -| X-Offset | Pagination: Offset value applied to request after validation | -| X-Link-Previous | Pagination: URI for previous result set if relevant | -| X-Link-Next | Pagination: URI for next result set if relevant | -| X-Link-Next | Pagination: URI for next result set if relevant | -| X-Last-Updated | The last time the collection was updated | -| X-Sort | Sort options applied to request after validation | -| X-Search | Search options applied to request after validation | -| X-Parameters | Request parameters applied to request after validation | +| Header | Purpose | +|:----------------|:-------------------------------------------------------------| +| X-Total-Count | Pagination: Total number of result | +| X-Count | Pagination: Number of results returned | +| X-Limit | Pagination: Limit value applied to request after validation | +| X-Offset | Pagination: Offset value applied to request after validation | +| X-Offset | Pagination: Offset value applied to request after validation | +| X-Link-Previous | Pagination: URI for previous result set if relevant | +| X-Link-Next | Pagination: URI for next result set if relevant | +| X-Link-Next | Pagination: URI for next result set if relevant | +| X-Last-Updated | The last time the collection was updated | +| X-Sort | Sort options applied to request after validation | +| X-Search | Search options applied to request after validation | +| X-Parameters | Request parameters applied to request after validation | ## Routes @@ -111,103 +110,103 @@ Access to a route will be limited based upon a users permitted resource types. When you create a resource type you have full access to everything below it, additionally, the same is true if you are assigned as a permitted user to a resource type. -| HTTP Verb(s) | Route | -| :--- | :--- | -| GET/HEAD | v2/ | -| OPTIONS | v2/ | -| GET/HEAD | v2/auth/check | -| POST | v2/auth/create-password | -| POST | v2/auth/create-new-password | -| POST | v2/auth/forgot-password | -| POST | v2/auth/login | -| POST | v2/auth/register | -| POST | v2/auth/update-password | -| POST | v2/auth/update-profile | -| GET/HEAD | v2/auth/user | -| GET/HEAD | v2/changelog | -| OPTIONS | v2/changelog | -| GET/HEAD | v2/currencies | -| OPTIONS | v2/currencies | -| GET/HEAD | v2/currencies/{currency_id} | -| OPTIONS | v2/currencies/{currency_id} | -| GET/HEAD | v2/item-types | -| OPTIONS | v2/item-types | -| GET/HEAD | v2/item-types/{item_type_id} | -| OPTIONS | v2/item-types/{item_type_id} | -| GET/HEAD | v2/item-types/{item_type_id}/item-subtypes | -| OPTIONS | v2/item-types/{item_type_id}/item-subtypes | -| GET/HEAD | v2/item-types/{item_type_id}/item-subtypes/{item_subtype_id} | -| OPTIONS | v2/item-types/{item_type_id}/item-subtypes/{item_subtype_id} | -| GET/HEAD | v2/resource-types | -| OPTIONS | v2/resource-types | -| POST | v2/resource-types | -| GET/HEAD | v2/resource-types/{resource_type_id} | -| OPTIONS | v2/resource-types/{resource_type_id} | -| PATCH | v2/resource-types/{resource_type_id} | -| DELETE | v2/resource-types/{resource_type_id} | -| GET/HEAD | v2/resource-types/{resource_type_id}/categories | -| OPTIONS | v2/resource-types/{resource_type_id}/categories | -| POST | v2/resource-types/{resource_type_id}/categories | -| PATCH | v2/resource-types/{resource_type_id}/categories/{category_id} | -| DELETE | v2/resource-types/{resource_type_id}/categories/{category_id} | -| GET/HEAD | v2/resource-types/{resource_type_id}/categories/{category_id} | -| OPTIONS | v2/resource-types/{resource_type_id}/categories/{category_id} | -| GET/HEAD | v2/resource-types/{resource_type_id}/categories/{category_id}/subcategories | -| OPTIONS | v2/resource-types/{resource_type_id}/categories/{category_id}/subcategories | -| POST | v2/resource-types/{resource_type_id}/categories/{category_id}/subcategories | -| GET/HEAD | v2/resource-types/{resource_type_id}/categories/{category_id}/subcategories/{subcategory_id} | -| OPTIONS | v2/resource-types/{resource_type_id}/categories/{category_id}/subcategories/{subcategory_id} | -| PATCH | v2/resource-types/{resource_type_id}/categories/{category_id}/subcategories/{subcategory_id} | -| DELETE | v2/resource-types/{resource_type_id}/categories/{category_id}/subcategories/{subcategory_id} | -| GET/HEAD | v2/resource-types/{resource_type_id}/items | -| OPTIONS | v2/resource-types/{resource_type_id}/items | -| GET/HEAD | v2/resource-types/{resource_type_id}/partial-transfers | -| OPTIONS | v2/resource-types/{resource_type_id}/partial-transfers | -| GET/HEAD | v2/resource-types/{resource_type_id}/partial-transfers/{item_partial_transfer_id} | -| OPTIONS | v2/resource-types/{resource_type_id}/partial-transfers/{item_partial_transfer_id} | -| DELETE | v2/resource-types/{resource_type_id}/partial-transfers/{item_partial_transfer_id} | -| GET/HEAD | v2/resource-types/{resource_type_id}/permitted-users | -| OPTIONS | v2/resource-types/{resource_type_id}/permitted-users | -| GET/HEAD | v2/resource-types/{resource_type_id}/resources | -| OPTIONS | v2/resource-types/{resource_type_id}/resources | -| POST | v2/resource-types/{resource_type_id}/resources | -| GET/HEAD | v2/resource-types/{resource_type_id}/resources/{resource_id} | -| OPTIONS | v2/resource-types/{resource_type_id}/resources/{resource_id} | -| PATCH | v2/resource-types/{resource_type_id}/resources/{resource_id} | -| DELETE | v2/resource-types/{resource_type_id}/resources/{resource_id} | -| GET/HEAD | v2/resource-types/{resource_type_id}/resources/{resource_id}/items | -| OPTIONS | v2/resource-types/{resource_type_id}/resources/{resource_id}/items | -| POST | v2/resource-types/{resource_type_id}/resources/{resource_id}/items | -| GET/HEAD | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id} | -| OPTIONS | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id} | -| PATCH | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id} | -| DELETE | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id} | -| GET/HEAD | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/categories | -| OPTIONS | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/categories | -| POST | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/categories | -| GET/HEAD | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/categories/{item_category_id} | -| OPTIONS | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/categories/{item_category_id} | -| DELETE | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/categories/{item_category_id} | -| GET/HEAD | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/categories/{item_category_id}/subcategories | -| OPTIONS | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/categories/{item_category_id}/subcategories | -| POST | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/categories/{item_category_id}/subcategories | -| GET/HEAD | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/categories/{item_category_id}/subcategories/{item_subcategory_id} | -| OPTIONS | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/categories/{item_category_id}/subcategories/{item_subcategory_id} | -| DELETE | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/categories/{item_category_id}/subcategories/{item_subcategory_id} | -| OPTIONS | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/partial-transfer | -| POST | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/partial-transfer | -| OPTIONS | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/transfer | -| POST | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/transfer | -| GET/HEAD | v2/resource-types/{resource_type_id}/transfers | -| OPTIONS | v2/resource-types/{resource_type_id}/transfers | -| GET/HEAD | v2/resource-types/{resource_type_id}/transfers/{item_transfer_id} | -| OPTIONS | v2/resource-types/{resource_type_id}/transfers/{item_transfer_id} | -| GET/HEAD | v2/request/error-log | -| OPTIONS | v2/request/error-log | -| POST | v2/request/error-log | -| GET/HEAD | v2/tools/cache | -| OPTIONS | v2/tools/cache | -| DELETE | v2/tools/cache | +| HTTP Verb(s) | Route | +|:-------------|:-----------------------------------------------------------------------------------------------------------------------------------------------| +| GET/HEAD | v2/ | +| OPTIONS | v2/ | +| GET/HEAD | v2/auth/check | +| POST | v2/auth/create-password | +| POST | v2/auth/create-new-password | +| POST | v2/auth/forgot-password | +| POST | v2/auth/login | +| POST | v2/auth/register | +| POST | v2/auth/update-password | +| POST | v2/auth/update-profile | +| GET/HEAD | v2/auth/user | +| GET/HEAD | v2/changelog | +| OPTIONS | v2/changelog | +| GET/HEAD | v2/currencies | +| OPTIONS | v2/currencies | +| GET/HEAD | v2/currencies/{currency_id} | +| OPTIONS | v2/currencies/{currency_id} | +| GET/HEAD | v2/item-types | +| OPTIONS | v2/item-types | +| GET/HEAD | v2/item-types/{item_type_id} | +| OPTIONS | v2/item-types/{item_type_id} | +| GET/HEAD | v2/item-types/{item_type_id}/item-subtypes | +| OPTIONS | v2/item-types/{item_type_id}/item-subtypes | +| GET/HEAD | v2/item-types/{item_type_id}/item-subtypes/{item_subtype_id} | +| OPTIONS | v2/item-types/{item_type_id}/item-subtypes/{item_subtype_id} | +| GET/HEAD | v2/resource-types | +| OPTIONS | v2/resource-types | +| POST | v2/resource-types | +| GET/HEAD | v2/resource-types/{resource_type_id} | +| OPTIONS | v2/resource-types/{resource_type_id} | +| PATCH | v2/resource-types/{resource_type_id} | +| DELETE | v2/resource-types/{resource_type_id} | +| GET/HEAD | v2/resource-types/{resource_type_id}/categories | +| OPTIONS | v2/resource-types/{resource_type_id}/categories | +| POST | v2/resource-types/{resource_type_id}/categories | +| PATCH | v2/resource-types/{resource_type_id}/categories/{category_id} | +| DELETE | v2/resource-types/{resource_type_id}/categories/{category_id} | +| GET/HEAD | v2/resource-types/{resource_type_id}/categories/{category_id} | +| OPTIONS | v2/resource-types/{resource_type_id}/categories/{category_id} | +| GET/HEAD | v2/resource-types/{resource_type_id}/categories/{category_id}/subcategories | +| OPTIONS | v2/resource-types/{resource_type_id}/categories/{category_id}/subcategories | +| POST | v2/resource-types/{resource_type_id}/categories/{category_id}/subcategories | +| GET/HEAD | v2/resource-types/{resource_type_id}/categories/{category_id}/subcategories/{subcategory_id} | +| OPTIONS | v2/resource-types/{resource_type_id}/categories/{category_id}/subcategories/{subcategory_id} | +| PATCH | v2/resource-types/{resource_type_id}/categories/{category_id}/subcategories/{subcategory_id} | +| DELETE | v2/resource-types/{resource_type_id}/categories/{category_id}/subcategories/{subcategory_id} | +| GET/HEAD | v2/resource-types/{resource_type_id}/items | +| OPTIONS | v2/resource-types/{resource_type_id}/items | +| GET/HEAD | v2/resource-types/{resource_type_id}/partial-transfers | +| OPTIONS | v2/resource-types/{resource_type_id}/partial-transfers | +| GET/HEAD | v2/resource-types/{resource_type_id}/partial-transfers/{item_partial_transfer_id} | +| OPTIONS | v2/resource-types/{resource_type_id}/partial-transfers/{item_partial_transfer_id} | +| DELETE | v2/resource-types/{resource_type_id}/partial-transfers/{item_partial_transfer_id} | +| GET/HEAD | v2/resource-types/{resource_type_id}/permitted-users | +| OPTIONS | v2/resource-types/{resource_type_id}/permitted-users | +| GET/HEAD | v2/resource-types/{resource_type_id}/resources | +| OPTIONS | v2/resource-types/{resource_type_id}/resources | +| POST | v2/resource-types/{resource_type_id}/resources | +| GET/HEAD | v2/resource-types/{resource_type_id}/resources/{resource_id} | +| OPTIONS | v2/resource-types/{resource_type_id}/resources/{resource_id} | +| PATCH | v2/resource-types/{resource_type_id}/resources/{resource_id} | +| DELETE | v2/resource-types/{resource_type_id}/resources/{resource_id} | +| GET/HEAD | v2/resource-types/{resource_type_id}/resources/{resource_id}/items | +| OPTIONS | v2/resource-types/{resource_type_id}/resources/{resource_id}/items | +| POST | v2/resource-types/{resource_type_id}/resources/{resource_id}/items | +| GET/HEAD | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id} | +| OPTIONS | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id} | +| PATCH | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id} | +| DELETE | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id} | +| GET/HEAD | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/categories | +| OPTIONS | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/categories | +| POST | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/categories | +| GET/HEAD | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/categories/{item_category_id} | +| OPTIONS | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/categories/{item_category_id} | +| DELETE | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/categories/{item_category_id} | +| GET/HEAD | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/categories/{item_category_id}/subcategories | +| OPTIONS | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/categories/{item_category_id}/subcategories | +| POST | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/categories/{item_category_id}/subcategories | +| GET/HEAD | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/categories/{item_category_id}/subcategories/{item_subcategory_id} | +| OPTIONS | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/categories/{item_category_id}/subcategories/{item_subcategory_id} | +| DELETE | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/categories/{item_category_id}/subcategories/{item_subcategory_id} | +| OPTIONS | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/partial-transfer | +| POST | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/partial-transfer | +| OPTIONS | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/transfer | +| POST | v2/resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}/transfer | +| GET/HEAD | v2/resource-types/{resource_type_id}/transfers | +| OPTIONS | v2/resource-types/{resource_type_id}/transfers | +| GET/HEAD | v2/resource-types/{resource_type_id}/transfers/{item_transfer_id} | +| OPTIONS | v2/resource-types/{resource_type_id}/transfers/{item_transfer_id} | +| GET/HEAD | v2/request/error-log | +| OPTIONS | v2/request/error-log | +| POST | v2/request/error-log | +| GET/HEAD | v2/tools/cache | +| OPTIONS | v2/tools/cache | +| DELETE | v2/tools/cache | ## Summary routes @@ -219,20 +218,20 @@ parameters to breakdown the data, one example being Review the OPTIONS request for each summary route to see the supported parameters, these should largely match the matching non-summary route. -| HTTP Verb(s) | Route | -| :--- | :--- | -| GET/HEAD | v2/summary/resource-types | -| OPTIONS | v2/summary/resource-types | -| GET/HEAD | v2/summary/resource-types/{resource_type_id}/categories | -| OPTIONS | v2/summary/resource-types/{resource_type_id}/categories | -| GET/HEAD | v2/summary/resource-types/{resource_type_id}/categories/{category_id}/subcategories | -| OPTIONS | v2/summary/resource-types/{resource_type_id}/categories/{category_id}/subcategories | -| GET/HEAD | v2/summary/resource-types/{resource_type_id}/items | -| OPTIONS | v2/summary/resource-types/{resource_type_id}/items | -| GET/HEAD | v2/summary/resource-types/{resource_type_id}/resources | -| OPTIONS | v2/summary/resource-types/{resource_type_id}/resources | -| GET/HEAD | v2/summary/resource-types/{resource_type_id}/resources/{resource_id}/items | -| OPTIONS | v2/summary/resource-types/{resource_type_id}/resources/{resource_id}/items | +| HTTP Verb(s) | Route | +|:-------------|:------------------------------------------------------------------------------------| +| GET/HEAD | v2/summary/resource-types | +| OPTIONS | v2/summary/resource-types | +| GET/HEAD | v2/summary/resource-types/{resource_type_id}/categories | +| OPTIONS | v2/summary/resource-types/{resource_type_id}/categories | +| GET/HEAD | v2/summary/resource-types/{resource_type_id}/categories/{category_id}/subcategories | +| OPTIONS | v2/summary/resource-types/{resource_type_id}/categories/{category_id}/subcategories | +| GET/HEAD | v2/summary/resource-types/{resource_type_id}/items | +| OPTIONS | v2/summary/resource-types/{resource_type_id}/items | +| GET/HEAD | v2/summary/resource-types/{resource_type_id}/resources | +| OPTIONS | v2/summary/resource-types/{resource_type_id}/resources | +| GET/HEAD | v2/summary/resource-types/{resource_type_id}/resources/{resource_id}/items | +| OPTIONS | v2/summary/resource-types/{resource_type_id}/resources/{resource_id}/items | ## Tests @@ -242,17 +241,17 @@ You can see our progress in the table below. We are hoping to add tests in each not too concerned about missing anything as we still have all our tests in Postman, we won't disable our test monitor until our local test suite is as complete as the Postman request tests. -| Controller | Progress | -| :--- | :--- | -| Authentication | Complete (34 Tests/62 Assertions) | -| CategoryManage | Not started | -| ItemCategoryManage | Not started | -| ItemManage | Not started | -| ItemPartialTransferManage | Not started | -| ItemSubcategoryManage | Not started | -| ItemTransferManage | Not started | -| RequestManage | Not started | -| ResourceManage | In Progress (3 Tests/8 Assertions) | -| ResourceTypeManage | Complete (14 Tests/30 Assertions) | -| SubcategoryManage | Not started | -| ToolManage | Not started | +| Controller | Progress | +|:--------------------------|:-----------------------------------| +| Authentication | Complete (34 Tests/62 Assertions) | +| CategoryManage | Not started | +| ItemCategoryManage | Not started | +| ItemManage | Not started | +| ItemPartialTransferManage | Not started | +| ItemSubcategoryManage | Not started | +| ItemTransferManage | Not started | +| RequestManage | Not started | +| ResourceManage | In Progress (3 Tests/8 Assertions) | +| ResourceTypeManage | Complete (14 Tests/30 Assertions) | +| SubcategoryManage | Not started | +| ToolManage | Not started | diff --git a/docker-compose.yml b/docker-compose.yml index d6880fd5..a2c4fbbf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,9 +10,9 @@ services: - 8080:80 volumes: - .:/var/www/html - # - /.docker/api/php/vendor # Uncomment to use local vendor directory for development env_file: .env environment: + TZ: UTC DB_HOST: ${DB_HOST} DB_DATABASE: ${DB_DATABASE} DB_USERNAME: ${DB_USERNAME} @@ -27,6 +27,7 @@ services: - 3308:3306 env_file: .env environment: + TZ: UTC MYSQL_DATABASE: ${DB_DATABASE} MYSQL_USER: ${DB_USERNAME} MYSQL_PASSWORD: ${DB_PASSWORD} diff --git a/testing.sqlite b/testing.sqlite deleted file mode 100644 index e69de29b..00000000 diff --git a/webpack.mix.js b/webpack.mix.js deleted file mode 100644 index 72fdbb16..00000000 --- a/webpack.mix.js +++ /dev/null @@ -1,15 +0,0 @@ -let mix = require('laravel-mix'); - -/* - |-------------------------------------------------------------------------- - | Mix Asset Management - |-------------------------------------------------------------------------- - | - | Mix provides a clean, fluent API for defining some Webpack build steps - | for your Laravel application. By default, we are compiling the Sass - | file for the application as well as bundling up all the JS files. - | - */ - -mix.js('resources/assets/js/app.js', 'public/js') - .sass('resources/assets/sass/app.scss', 'public/css'); From 9770f48e4675f5f6151536bdfbdf0bb27b582db3 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Tue, 11 Jan 2022 14:38:17 +0000 Subject: [PATCH 03/73] Refactoring - Method injection - Log errors --- app/Http/Controllers/Authentication.php | 85 ++++++++++++--------- app/Http/Controllers/ResourceTypeManage.php | 46 +++++------ app/Http/Controllers/ResourceTypeView.php | 12 +-- app/User.php | 4 + 4 files changed, 75 insertions(+), 72 deletions(-) diff --git a/app/Http/Controllers/Authentication.php b/app/Http/Controllers/Authentication.php index c0371259..8c96756c 100644 --- a/app/Http/Controllers/Authentication.php +++ b/app/Http/Controllers/Authentication.php @@ -5,11 +5,14 @@ use App\Notifications\ForgotPassword; use App\Notifications\Registered; use App\User; +use Exception; use Illuminate\Http; +use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Hash; +use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Validator; use Illuminate\Support\Str; @@ -20,10 +23,10 @@ public function check(): Http\JsonResponse return response()->json(['auth' => Auth::guard('api')->check()]); } - public function createPassword(): Http\JsonResponse + public function createPassword(Request $request): Http\JsonResponse { - $email = Str::replaceFirst(' ', '+', urldecode(request()->query('email'))); - $token = request()->query('token'); + $email = Str::replaceFirst(' ', '+', urldecode($request->query('email'))); + $token = $request->query('token'); $tokens = DB::table('password_creates') ->where('email', '=', $email) @@ -39,7 +42,7 @@ public function createPassword(): Http\JsonResponse } $validator = Validator::make( - request()->only(['password', 'password_confirmation']), + $request->only(['password', 'password_confirmation']), [ 'password' => [ 'required', @@ -68,26 +71,27 @@ public function createPassword(): Http\JsonResponse ->first(); if ($user !== null) { - $user->password = Hash::make(request()->input('password')); + $user->password = Hash::make($request->input('password')); $user->save(); DB::table('password_creates') - ->where('email', '=', request()->input(['email'])) + ->where('email', '=', $request->input(['email'])) ->delete(); return response()->json([], 204); } return response()->json(['message' => 'Unable to fetch your account to create password, please try again later'], 404); - } catch (\Exception $e) { + } catch (Exception $e) { + Log::error($e->getMessage()); return response()->json(['message' => 'Unable to create password, please try again later'], 500); } } - public function createNewPassword(): Http\JsonResponse + public function createNewPassword(Request $request): Http\JsonResponse { - $email = Str::replaceFirst(' ', '+', urldecode(request()->query('email'))); - $token = request()->query('token'); + $email = Str::replaceFirst(' ', '+', urldecode($request->query('email'))); + $token = $request->query('token'); $tokens = DB::table('password_resets') ->where('email', '=', $email) @@ -103,7 +107,7 @@ public function createNewPassword(): Http\JsonResponse } $validator = Validator::make( - request()->only(['password', 'password_confirmation']), + $request->only(['password', 'password_confirmation']), [ 'password' => [ 'required', @@ -132,26 +136,27 @@ public function createNewPassword(): Http\JsonResponse ->first(); if ($user !== null) { - $user->password = Hash::make(request()->input('password')); + $user->password = Hash::make($request->input('password')); $user->save(); DB::table('password_resets') - ->where('email', '=', request()->input(['email'])) + ->where('email', '=', $request->input(['email'])) ->delete(); return response()->json([], 204); } return response()->json(['message' => 'Unable to fetch your account to create password, please try again later'], 500); - } catch (\Exception $e) { + } catch (Exception $e) { + Log::error($e->getMessage()); return response()->json(['message' => 'Unable to create password, please try again later'], 500); } } - public function forgotPassword(): Http\JsonResponse + public function forgotPassword(Request $request): Http\JsonResponse { $validator = Validator::make( - request()->only(['email']), + $request->only(['email']), [ 'email' => 'required|email', ] @@ -167,7 +172,7 @@ public function forgotPassword(): Http\JsonResponse ); } - $email = request()->input('email'); + $email = $request->input('email'); $user = User::with([]) ->where('email', '=', $email) @@ -187,10 +192,11 @@ public function forgotPassword(): Http\JsonResponse ] ); - if (app()->environment() === 'production' && request()->query('send') === null) { + if (app()->environment() === 'production' && $request->query('send') === null) { $user->notify(new ForgotPassword($user, $create_token)); } - } catch (\Exception $e) { + } catch (Exception $e) { + Log::error($e->getMessage()); return response()->json(['error' => 'Unable to process your forgot password request, please try again later'], 500); } @@ -214,7 +220,7 @@ public function forgotPassword(): Http\JsonResponse return response()->json(['message' => 'Unable to fetch your user account, please try again later'], 404); } - public function login(): Http\JsonResponse + public function login(Request $request): Http\JsonResponse { if ( Auth::attempt( @@ -227,7 +233,7 @@ public function login(): Http\JsonResponse $user = Auth::user(); if ($user !== null) { - $token = request()->user()->createToken('costs-to-expect-api'); + $token = $request->user()->createToken('costs-to-expect-api'); return response()->json( [ 'id' => $this->hash->user()->encode($user->id), @@ -244,10 +250,10 @@ public function login(): Http\JsonResponse return response()->json(['message' => 'Unauthorised, credentials invalid'], 401); } - public function register(): Http\JsonResponse + public function register(Request $request): Http\JsonResponse { $validator = Validator::make( - request()->all(), + $request->all(), [ 'name' => 'required', 'email' => 'required|email', @@ -265,11 +271,11 @@ public function register(): Http\JsonResponse } try { - $email = request()->input('email'); + $email = $request->input('email'); $user = new User(); - $user->name = request()->input('name'); - $user->email = request()->input('email'); + $user->name = $request->input('name'); + $user->email = $request->input('email'); $user->password = Hash::make(Str::random(20)); $user->save(); @@ -285,11 +291,12 @@ public function register(): Http\JsonResponse ] ); - if (app()->environment() === 'production' && request()->query('send') === null) { + if ($request->query('send') === null && app()->environment() === 'production') { $user->notify(new Registered($user, $create_token)); } - } catch (\Exception $e) { + } catch (Exception $e) { + Log::error($e->getMessage()); return response()->json(['error' => 'Unable to create the account, please try again later'], 500); } @@ -310,10 +317,10 @@ public function register(): Http\JsonResponse ); } - public function updatePassword(): Http\JsonResponse + public function updatePassword(Request $request): Http\JsonResponse { $validator = Validator::make( - request()->only(['password', 'password_confirmation']), + $request->only(['password', 'password_confirmation']), [ 'password' => [ 'required', @@ -339,7 +346,7 @@ public function updatePassword(): Http\JsonResponse $user = auth()->guard('api')->user(); if ($user !== null) { - $user->password = Hash::make(request()->input('password')); + $user->password = Hash::make($request->input('password')); $user->save(); return response()->json([], 204); @@ -348,10 +355,10 @@ public function updatePassword(): Http\JsonResponse return response()->json(['message' => 'Unauthorised, credentials invalid'], 401); } - public function updateProfile(): Http\JsonResponse + public function updateProfile(Request $request): Http\JsonResponse { $validator = Validator::make( - request()->only(['name', 'email']), + $request->only(['name', 'email']), [ 'name' => [ 'sometimes' @@ -377,11 +384,11 @@ public function updateProfile(): Http\JsonResponse if ($user !== null) { $fields = []; - if (request()->input('name') !== null) { - $fields['name'] = request()->input('name'); + if ($request->input('name') !== null) { + $fields['name'] = $request->input('name'); } - if (request()->input('email') !== null) { - $fields['email'] = request()->input('email'); + if ($request->input('email') !== null) { + $fields['email'] = $request->input('email'); } if (count($fields) === 0) { @@ -394,7 +401,9 @@ public function updateProfile(): Http\JsonResponse } $user->save(); - } catch (\Exception $e) { + + } catch (Exception $e) { + Log::error($e->getMessage()); return response()->json(['message' => 'Unable to update your profile, please try again'], 401); } diff --git a/app/Http/Controllers/ResourceTypeManage.php b/app/Http/Controllers/ResourceTypeManage.php index d3bb518a..0d5e8eea 100644 --- a/app/Http/Controllers/ResourceTypeManage.php +++ b/app/Http/Controllers/ResourceTypeManage.php @@ -14,7 +14,9 @@ use Exception; use Illuminate\Database\QueryException; use Illuminate\Http\JsonResponse; +use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Log; /** * Manage resource types @@ -27,12 +29,7 @@ class ResourceTypeManage extends Controller { protected bool $allow_entire_collection = true; - /** - * Create a new resource type - * - * @return JsonResponse - */ - public function create(): JsonResponse + public function create(Request $request): JsonResponse { $validator = (new ResourceTypeValidator)->create([ 'user_id' => $this->user_id @@ -49,12 +46,12 @@ public function create(): JsonResponse ->setUserId($this->user_id); try { - $resource_type = DB::transaction(function() { + $resource_type = DB::transaction(function() use($request) { $resource_type = new ResourceType([ - 'name' => request()->input('name'), - 'description' => request()->input('description'), - 'data' => request()->input('data'), - 'public' => request()->input('public', 0) + 'name' => $request->input('name'), + 'description' => $request->input('description'), + 'data' => $request->input('data'), + 'public' => $request->input('public', 0) ]); $resource_type->save(); @@ -65,7 +62,7 @@ public function create(): JsonResponse ]); $permitted_users->save(); - $item_type_id = $this->hash->decode('item-type', request()->input('item_type_id')); + $item_type_id = $this->hash->decode('item-type', $request->input('item_type_id')); if ($item_type_id === false) { return \App\Response\Responses::unableToDecode(); @@ -83,6 +80,7 @@ public function create(): JsonResponse ClearCache::dispatch($cache_job_payload->payload()); } catch (Exception $e) { + Log::error($e->getMessage()); return \App\Response\Responses::failedToSaveModelForCreate(); } @@ -92,14 +90,8 @@ public function create(): JsonResponse ); } - /** - * Delete the requested resource type - * - * @param string $resource_type_id - * - * @return JsonResponse - */ public function delete( + Request $request, string $resource_type_id ): JsonResponse { @@ -147,8 +139,10 @@ public function delete( return \App\Response\Responses::successNoContent(); } catch (QueryException $e) { + Log::error($e->getMessage()); return \App\Response\Responses::foreignKeyConstraintError(); } catch (Exception $e) { + Log::error($e->getMessage()); return \App\Response\Responses::notFound(trans('entities.resource-type')); } } else { @@ -156,14 +150,8 @@ public function delete( } } - /** - * Update the selected category - * - * @param string $resource_type_id - * - * @return JsonResponse - */ public function update( + Request $request, string $resource_type_id ): JsonResponse { @@ -177,7 +165,7 @@ public function update( return \App\Response\Responses::failedToSelectModelForUpdateOrDelete(); } - if (count(request()->all()) === 0) { + if (count($request->all()) === 0) { return \App\Response\Responses::nothingToPatch(); } @@ -186,7 +174,7 @@ public function update( 'user_id' => $this->user_id ]); - if ($validator->fails()) { + if ($validator !== null && $validator->fails()) { return \App\Request\BodyValidation::returnValidationErrors($validator); } @@ -201,7 +189,7 @@ public function update( return Responses::invalidFieldsInRequest($invalid_fields); } - foreach (request()->all() as $key => $value) { + foreach ($request->all() as $key => $value) { $resource_type->$key = $value; } diff --git a/app/Http/Controllers/ResourceTypeView.php b/app/Http/Controllers/ResourceTypeView.php index b8139124..09a45c35 100644 --- a/app/Http/Controllers/ResourceTypeView.php +++ b/app/Http/Controllers/ResourceTypeView.php @@ -10,8 +10,10 @@ use App\Request\Parameter; use App\Response\Header; use App\Response\Pagination as UtilityPagination; +use App\Response\Responses; use App\Transformers\ResourceType as ResourceTypeTransformer; use Illuminate\Http\JsonResponse; +use Illuminate\Http\Request; use Illuminate\Support\Facades\Config; /** @@ -25,13 +27,13 @@ class ResourceTypeView extends Controller { protected bool $allow_entire_collection = true; - public function index(): JsonResponse + public function index(Request $request): JsonResponse { $cache_control = new \App\Cache\Control( true, $this->user_id); $cache_control->setTtlOneWeek(); $cache_collection = new \App\Cache\Collection(); - $cache_collection->setFromCache($cache_control->getByKey(request()->getRequestUri())); + $cache_collection->setFromCache($cache_control->getByKey($request->getRequestUri())); if ($cache_control->isRequestCacheable() === false || $cache_collection->valid() === false) { @@ -48,7 +50,7 @@ public function index(): JsonResponse $search_parameters ); - $pagination = new UtilityPagination(request()->path(), $total); + $pagination = new UtilityPagination($request->path(), $total); $pagination_parameters = $pagination ->allowPaginationOverride($this->allow_entire_collection) ->setSearchParameters($search_parameters) @@ -88,7 +90,7 @@ static function ($resource_type) { } $cache_collection->create($total, $collection, $pagination_parameters, $headers->headers()); - $cache_control->putByKey(request()->getRequestUri(), $cache_collection->content()); + $cache_control->putByKey($request->getRequestUri(), $cache_collection->content()); } return response()->json($cache_collection->collection(), 200, $cache_collection->headers()); @@ -104,7 +106,7 @@ public function show($resource_type_id): JsonResponse ); if ($resource_type === null) { - return \App\Response\Responses::notFound(trans('entities.resource-type')); + return Responses::notFound(trans('entities.resource-type')); } $resources = []; diff --git a/app/User.php b/app/User.php index da353bc3..fa7bf7d5 100644 --- a/app/User.php +++ b/app/User.php @@ -9,6 +9,10 @@ /** * @mixin QueryBuilder + * @property string $name + * @property string $email + * @property string $password + * @property string $remember_token */ class User extends Authenticatable { From e9fec86c5e9ea1833ba461443211173588c7e606 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Tue, 11 Jan 2022 15:33:12 +0000 Subject: [PATCH 04/73] Writing tests - Logout route - Return 403 when not accessible. - Tests --- app/Http/Controllers/Authentication.php | 7 + app/Response/Responses.php | 2 +- routes/api/auth.php | 5 + .../Http/Controllers/ResourceManageTest.php | 143 ++++++++++++++---- tests/TestCase.php | 46 +++++- 5 files changed, 174 insertions(+), 29 deletions(-) diff --git a/app/Http/Controllers/Authentication.php b/app/Http/Controllers/Authentication.php index 8c96756c..6f9dc1ba 100644 --- a/app/Http/Controllers/Authentication.php +++ b/app/Http/Controllers/Authentication.php @@ -250,6 +250,13 @@ public function login(Request $request): Http\JsonResponse return response()->json(['message' => 'Unauthorised, credentials invalid'], 401); } + public function logout(Request $request): Http\JsonResponse + { + Auth::logout(); + + return response()->json(['message' => 'Account signed out'], 200); + } + public function register(Request $request): Http\JsonResponse { $validator = Validator::make( diff --git a/app/Response/Responses.php b/app/Response/Responses.php index 470303cd..78a7198c 100644 --- a/app/Response/Responses.php +++ b/app/Response/Responses.php @@ -83,7 +83,7 @@ public static function notFoundOrNotAccessible(?string $type = null, ?Exception response()->json( $response, - 404 + ($type !== null ? 404 : 403) )->send(); exit; } diff --git a/routes/api/auth.php b/routes/api/auth.php index f8f688e5..7f8344ba 100644 --- a/routes/api/auth.php +++ b/routes/api/auth.php @@ -29,6 +29,11 @@ function () { [Authentication::class, 'login'] )->name('auth.login'); + Route::get( + 'auth/logout', + [Authentication::class, 'logout'] + )->name('auth.logout'); + if (Config::get('api.app.config.registrations') === true) { Route::post( diff --git a/tests/Feature/Http/Controllers/ResourceManageTest.php b/tests/Feature/Http/Controllers/ResourceManageTest.php index 462cb9aa..42bf1ba7 100644 --- a/tests/Feature/Http/Controllers/ResourceManageTest.php +++ b/tests/Feature/Http/Controllers/ResourceManageTest.php @@ -3,6 +3,7 @@ namespace Tests\Feature\Http\Controllers; use App\User; +use Illuminate\Support\Facades\Auth; use Tests\TestCase; class ResourceManageTest extends TestCase @@ -12,25 +13,35 @@ public function create_resource_fails_data_field_not_valid_json(): void { $this->actingAs(User::find(1)); - $response = $this->postResourceType( + $id = $this->helperCreateResourceType(); + + $response = $this->postResource( + $id, [ - 'name' => $this->faker->text(255), - 'description' => $this->faker->text, - 'item_type_id' => 'OqZwKX16bW', - 'public' => false + 'name' => $this->faker->text(200), + 'description' => $this->faker->text(200), + 'data' => '{"field"=>true}', + 'item_subtype_id' => 'a56kbWV82n' ] ); - $response->assertStatus(201); - $id = $response->json('id'); + $response->assertStatus(422); + } + + /** @test */ + public function create_resource_fails_item_subtype_invalid(): void + { + $this->actingAs(User::find(1)); + + $id = $this->helperCreateResourceType(); $response = $this->postResource( $id, [ 'name' => $this->faker->text(200), 'description' => $this->faker->text(200), - 'data' => '{"field"=>true}', - 'item_subtype_id' => 'a56kbWV82n' + 'data' => '{"field"=>"data"}', + 'item_subtype_id' => 'a56kbW' ] ); @@ -38,52 +49,117 @@ public function create_resource_fails_data_field_not_valid_json(): void } /** @test */ - public function create_resource_success(): void + public function create_resource_fails_no_description_in_payload(): void { $this->actingAs(User::find(1)); - $response = $this->postResourceType( + $id = $this->helperCreateResourceType(); + + $response = $this->postResource( + $id, [ - 'name' => $this->faker->text(255), - 'description' => $this->faker->text, - 'item_type_id' => 'OqZwKX16bW', - 'public' => false + 'name' => $this->faker->text(200), + 'data' => '{"field"=>"data"}', + 'item_subtype_id' => 'a56kbW' ] ); - $response->assertStatus(201); - $id = $response->json('id'); + $response->assertStatus(422); + } + + /** @test */ + public function create_resource_fails_no_name_in_payload(): void + { + $this->actingAs(User::find(1)); + + $id = $this->helperCreateResourceType(); $response = $this->postResource( $id, [ - 'name' => $this->faker->text(200), + 'description' => $this->faker->text(200), + 'data' => '{"field"=>"data"}', + 'item_subtype_id' => 'a56kbW' + ] + ); + + $response->assertStatus(422); + } + + /** @test */ + public function create_resource_fails_no_payload(): void + { + $this->actingAs(User::find(1)); + + $id = $this->helperCreateResourceType(); + + $response = $this->postResource( + $id, + [] + ); + + $response->assertStatus(422); + } + + /** @test */ + public function create_resource_fails_non_unique_name(): void + { + $this->actingAs(User::find(1)); + + $id = $this->helperCreateResourceType(); + + $name = $this->faker->text(200); + + $response = $this->postResource( + $id, + [ + 'name' => $name, 'description' => $this->faker->text(200), 'item_subtype_id' => 'a56kbWV82n' ] ); $response->assertStatus(201); - $this->assertJsonIsResource($response->content()); + + // Create again with non-unique name for resource type + $response = $this->postResource( + $id, + [ + 'name' => $name, + 'description' => $this->faker->text(200), + 'item_subtype_id' => 'a56kbWV82n' + ] + ); + + $response->assertStatus(422); } /** @test */ - public function create_resource_success_include_data_field(): void + public function create_resource_success(): void { $this->actingAs(User::find(1)); - $response = $this->postResourceType( + $id = $this->helperCreateResourceType(); + + $response = $this->postResource( + $id, [ - 'name' => $this->faker->text(255), - 'description' => $this->faker->text, - 'data' => '{"field":true}', - 'item_type_id' => 'OqZwKX16bW', - 'public' => false + 'name' => $this->faker->text(200), + 'description' => $this->faker->text(200), + 'item_subtype_id' => 'a56kbWV82n' ] ); $response->assertStatus(201); - $id = $response->json('id'); + $this->assertJsonIsResource($response->content()); + } + + /** @test */ + public function create_resource_success_include_data_field(): void + { + $this->actingAs(User::find(1)); + + $id = $this->helperCreateResourceType(); $response = $this->postResource( $id, @@ -98,4 +174,17 @@ public function create_resource_success_include_data_field(): void $response->assertStatus(201); $this->assertJsonIsResource($response->content()); } + + /** @test */ + public function delete_resource_success(): void + { + $this->actingAs(User::find(1)); + + $resource_type_id = $this->helperCreateResourceType(); + $id = $this->helperCreateResource($resource_type_id); + + $response = $this->deleteResourceType($id); + + $response->assertStatus(204); + } } diff --git a/tests/TestCase.php b/tests/TestCase.php index fbe3df75..79f7459b 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -54,10 +54,17 @@ protected function assertJsonMatchesSchema($content, $schema_file): void self::assertTrue($result->isValid()); } + protected function deleteResource(string $resource_type_id, $resource_id): TestResponse + { + return $this->delete( + route('resource.delete', ['resource_type_id' => $resource_type_id, 'resource_is' => $resource_id]), [] + ); + } + protected function deleteResourceType(string $resource_type_id): TestResponse { return $this->delete( - route('resource-type.update', ['resource_type_id' => $resource_type_id]), [] + route('resource-type.delete', ['resource_type_id' => $resource_type_id]), [] ); } @@ -81,4 +88,41 @@ protected function postResourceType(array $payload): TestResponse { return $this->post(route('resource-type.create'), $payload); } + + protected function helperCreateResourceType(): string + { + $response = $this->postResourceType( + [ + 'name' => $this->faker->text(255), + 'description' => $this->faker->text, + 'data' => '{"field":true}', + 'item_type_id' => 'OqZwKX16bW', + 'public' => false + ] + ); + + if ($response->assertStatus(201)) { + return $response->json('id'); + } + + $this->fail('Unable to create the resource type'); + } + + protected function helperCreateResource(string $resource_type_id): string + { + $response = $this->postResource( + $resource_type_id, + [ + 'name' => $this->faker->text(200), + 'description' => $this->faker->text(200), + 'item_subtype_id' => 'a56kbWV82n' + ] + ); + + if ($response->assertStatus(201)) { + return $response->json('id'); + } + + $this->fail('Unable to create the resource'); + } } From caf69224a999dc377d6a1c8f2e94f87f01f8213e Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Tue, 11 Jan 2022 16:56:25 +0000 Subject: [PATCH 05/73] Tests - Added resource tests --- README.md | 30 +++--- routes/api/private-routes.php | 18 ++-- routes/api/public-routes.php | 32 +++--- .../Http/Controllers/ResourceManageTest.php | 102 +++++++++++++++++- .../Controllers/ResourceTypeManageTest.php | 8 +- tests/TestCase.php | 16 ++- 6 files changed, 162 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index 5e35cce6..e875a2f9 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,7 @@ additionally, the same is true if you are assigned as a permitted user to a reso | POST | v2/auth/create-new-password | | POST | v2/auth/forgot-password | | POST | v2/auth/login | +| GET | v2/auth/logout | | POST | v2/auth/register | | POST | v2/auth/update-password | | POST | v2/auth/update-profile | @@ -241,17 +242,18 @@ You can see our progress in the table below. We are hoping to add tests in each not too concerned about missing anything as we still have all our tests in Postman, we won't disable our test monitor until our local test suite is as complete as the Postman request tests. -| Controller | Progress | -|:--------------------------|:-----------------------------------| -| Authentication | Complete (34 Tests/62 Assertions) | -| CategoryManage | Not started | -| ItemCategoryManage | Not started | -| ItemManage | Not started | -| ItemPartialTransferManage | Not started | -| ItemSubcategoryManage | Not started | -| ItemTransferManage | Not started | -| RequestManage | Not started | -| ResourceManage | In Progress (3 Tests/8 Assertions) | -| ResourceTypeManage | Complete (14 Tests/30 Assertions) | -| SubcategoryManage | Not started | -| ToolManage | Not started | +| Controller | Progress | +|:--------------------------|:--------------------------------------| +| Authentication | Complete (34 Tests/62 Assertions) | +| CategoryManage | Not started | +| ItemCategoryManage | Not started | +| ItemManage | Not started | +| ItemPartialTransferManage | Not started | +| ItemSubcategoryManage | Not started | +| ItemTransferManage | Not started | +| RequestManage | Not started | +| ResourceManage | Complete (13 Tests/35 Assertions) | +| ResourceTypeManage | Complete (14 Tests/30 Assertions) | +| SubcategoryManage | Not started | +| ToolManage | Not started | +| Total | In Progress (61 Tests/127 Assertions) | diff --git a/routes/api/private-routes.php b/routes/api/private-routes.php index c0142778..bbf038f2 100644 --- a/routes/api/private-routes.php +++ b/routes/api/private-routes.php @@ -1,5 +1,7 @@ name('resource-type.create'); Route::post( @@ -34,7 +36,7 @@ static function () { Route::post( 'resource-types/{resource_type_id}/resources', - 'ResourceManage@create' + [ResourceManage::class, 'create'] )->name('resource.create'); Route::post( @@ -64,7 +66,7 @@ static function () { Route::delete( 'resource-types/{resource_type_id}', - 'ResourceTypeManage@delete' + [ResourceTypeManage::class, 'delete'] )->name('resource-type.delete'); Route::delete( @@ -84,8 +86,8 @@ static function () { Route::delete( 'resource-types/{resource_type_id}/resources/{resource_id}', - 'ResourceManage@delete' - ); + [ResourceManage::class, 'delete'] + )->name('resource.delete'); Route::delete( 'resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}', @@ -104,7 +106,7 @@ static function () { Route::patch( 'resource-types/{resource_type_id}', - 'ResourceTypeManage@update' + [ResourceTypeManage::class, 'update'] )->name('resource-type.update'); Route::patch( @@ -119,8 +121,8 @@ static function () { Route::patch( 'resource-types/{resource_type_id}/resources/{resource_id}', - 'ResourceManage@update' - ); + [ResourceManage::class, 'update'] + )->name('resource.update'); Route::patch( 'resource-types/{resource_type_id}/resources/{resource_id}/items/{item_id}', diff --git a/routes/api/public-routes.php b/routes/api/public-routes.php index a351a457..7215d71a 100644 --- a/routes/api/public-routes.php +++ b/routes/api/public-routes.php @@ -115,23 +115,23 @@ static function () { Route::get( 'resource-types', - 'ResourceTypeView@index' - ); + [\App\Http\Controllers\ResourceTypeView::class, 'index'] + )->name('resource-type.list'); Route::options( 'resource-types', - 'ResourceTypeView@optionsIndex' - )->name('resource-type.list'); + [\App\Http\Controllers\ResourceTypeView::class, 'optionsIndex'] + )->name('resource-type.list.options'); Route::get( 'resource-types/{resource_type_id}', - 'ResourceTypeView@show' - ); + [\App\Http\Controllers\ResourceTypeView::class, 'show'] + )->name('resource-type.show'); Route::options( 'resource-types/{resource_type_id}', - 'ResourceTypeView@optionsShow' - ); + [\App\Http\Controllers\ResourceTypeView::class, 'optionsShow'] + )->name('resource-type.show.options'); Route::get( 'resource-types/{resource_type_id}/categories', @@ -215,23 +215,23 @@ static function () { Route::get( 'resource-types/{resource_type_id}/resources', - 'ResourceView@index' - ); + [\App\Http\Controllers\ResourceView::class, 'index'] + )->name('resource.list'); Route::options( 'resource-types/{resource_type_id}/resources', - 'ResourceView@optionsIndex' - ); + [\App\Http\Controllers\ResourceTypeView::class, 'optionsIndex'] + )->name('resource.list.options'); Route::get( 'resource-types/{resource_type_id}/resources/{resource_id}', - 'ResourceView@show' - ); + [\App\Http\Controllers\ResourceTypeView::class, 'show'] + )->name('resource.show'); Route::options( 'resource-types/{resource_type_id}/resources/{resource_id}', - 'ResourceView@optionsShow' - ); + [\App\Http\Controllers\ResourceTypeView::class, 'optionsShow'] + )->name('resource.show.options'); Route::get( 'resource-types/{resource_type_id}/resources/{resource_id}/items', diff --git a/tests/Feature/Http/Controllers/ResourceManageTest.php b/tests/Feature/Http/Controllers/ResourceManageTest.php index 42bf1ba7..0d5e011a 100644 --- a/tests/Feature/Http/Controllers/ResourceManageTest.php +++ b/tests/Feature/Http/Controllers/ResourceManageTest.php @@ -183,7 +183,107 @@ public function delete_resource_success(): void $resource_type_id = $this->helperCreateResourceType(); $id = $this->helperCreateResource($resource_type_id); - $response = $this->deleteResourceType($id); + $response = $this->deleteResource($resource_type_id, $id); + + $response->assertStatus(204); + } + + /** @test */ + public function update_resource_fails_extra_fields_in_payload(): void + { + $this->actingAs(User::find(1)); + + $resource_type_id = $this->helperCreateResourceType(); + $resource_id = $this->helperCreateResource($resource_type_id); + + $response = $this->patchResource( + $resource_type_id, + $resource_id, + [ + 'extra' => $this->faker->text(100) + ] + ); + + $response->assertStatus(400); + } + + /** @test */ + public function update_resource_fails_non_payload(): void + { + $this->actingAs(User::find(1)); + + $resource_type_id = $this->helperCreateResourceType(); + $resource_id = $this->helperCreateResource($resource_type_id); + + $response = $this->patchResource( + $resource_type_id, + $resource_id, + [] + ); + + $response->assertStatus(400); + } + + /** @test */ + public function update_resource_fails_non_unique_name(): void + { + $this->actingAs(User::find(1)); + + $resource_type_id = $this->helperCreateResourceType(); + + // Create first resource + $name = $this->faker->text(200); + $response = $this->postResource( + $resource_type_id, + [ + 'name' => $name, + 'description' => $this->faker->text(200), + 'item_subtype_id' => 'a56kbWV82n' + ] + ); + + $response->assertStatus(201); + + // Create second resource + $response = $this->postResource( + $resource_type_id, + [ + 'name' => $this->faker->text(200), + 'description' => $this->faker->text(200), + 'item_subtype_id' => 'a56kbWV82n' + ] + ); + + $response->assertStatus(201); + $resource_id = $response->json('id'); + + // Set name of second resource to first name + $response = $this->patchResource( + $resource_type_id, + $resource_id, + [ + 'name' => $name + ] + ); + + $response->assertStatus(422); + } + + /** @test */ + public function update_resource_success(): void + { + $this->actingAs(User::find(1)); + + $resource_type_id = $this->helperCreateResourceType(); + $resource_id = $this->helperCreateResource($resource_type_id); + + $response = $this->patchResource( + $resource_type_id, + $resource_id, + [ + 'name' => $this->faker->text(25) + ] + ); $response->assertStatus(204); } diff --git a/tests/Feature/Http/Controllers/ResourceTypeManageTest.php b/tests/Feature/Http/Controllers/ResourceTypeManageTest.php index 93de75a4..732aaace 100644 --- a/tests/Feature/Http/Controllers/ResourceTypeManageTest.php +++ b/tests/Feature/Http/Controllers/ResourceTypeManageTest.php @@ -149,7 +149,7 @@ public function create_resource_type_success_include_data_field(): void $response = $this->postResourceType( [ - 'name' => $this->faker->text(255), + 'name' => $this->faker->text(10), 'description' => $this->faker->text, 'data' => '{"field": "value"}', 'item_type_id' => 'OqZwKX16bW', @@ -168,7 +168,7 @@ public function delete_resource_type_success(): void $response = $this->postResourceType( [ - 'name' => $this->faker->text(255), + 'name' => $this->faker->text(10), 'description' => $this->faker->text, 'item_type_id' => 'OqZwKX16bW', 'public' => false @@ -192,7 +192,7 @@ public function update_resource_type_fails_extra_fields_in_payload(): void $response = $this->postResourceType( [ - 'name' => $this->faker->text(255), + 'name' => $this->faker->text(10), 'description' => $this->faker->text, 'item_type_id' => 'OqZwKX16bW', 'public' => false @@ -221,7 +221,7 @@ public function update_resource_type_fails_no_payload(): void $response = $this->postResourceType( [ - 'name' => $this->faker->text(255), + 'name' => $this->faker->text(10), 'description' => $this->faker->text, 'item_type_id' => 'OqZwKX16bW', 'public' => false diff --git a/tests/TestCase.php b/tests/TestCase.php index 79f7459b..86fbe380 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -57,7 +57,7 @@ protected function assertJsonMatchesSchema($content, $schema_file): void protected function deleteResource(string $resource_type_id, $resource_id): TestResponse { return $this->delete( - route('resource.delete', ['resource_type_id' => $resource_type_id, 'resource_is' => $resource_id]), [] + route('resource.delete', ['resource_type_id' => $resource_type_id, 'resource_id' => $resource_id]), [] ); } @@ -76,6 +76,20 @@ protected function patchResourceType(string $resource_type_id, array $payload): ); } + protected function patchResource(string $resource_type_id, string $resource_id, array $payload): TestResponse + { + return $this->patch( + route( + 'resource.update', + [ + 'resource_type_id' => $resource_type_id, + 'resource_id' => $resource_id + ] + ), + $payload + ); + } + protected function postResource(string $resource_type_id, array $payload): TestResponse { return $this->post( From 54961c95611b7429015204782677e34761553467 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Wed, 12 Jan 2022 10:19:12 +0000 Subject: [PATCH 06/73] OPTIONS request for create-new-password - Added an options request for /auth/create-new-password - Updated README with new route --- README.md | 1 + app/Http/Controllers/Authentication.php | 10 ++++++- app/Option/CreateNewPassword.php | 20 ++++++++++++++ .../api/auth/create-new-password/fields.php | 27 +++++++++++++++++++ .../en/auth/create-new-password/fields.php | 11 ++++++++ resources/lang/en/route-descriptions.php | 2 ++ routes/api/auth.php | 5 ++++ 7 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 app/Option/CreateNewPassword.php create mode 100644 config/api/auth/create-new-password/fields.php create mode 100644 resources/lang/en/auth/create-new-password/fields.php diff --git a/README.md b/README.md index e875a2f9..7859d217 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,7 @@ additionally, the same is true if you are assigned as a permitted user to a reso | GET/HEAD | v2/ | | OPTIONS | v2/ | | GET/HEAD | v2/auth/check | +| OPTIONS | v2/auth/create-password | | POST | v2/auth/create-password | | POST | v2/auth/create-new-password | | POST | v2/auth/forgot-password | diff --git a/app/Http/Controllers/Authentication.php b/app/Http/Controllers/Authentication.php index 6f9dc1ba..5fb920da 100644 --- a/app/Http/Controllers/Authentication.php +++ b/app/Http/Controllers/Authentication.php @@ -4,6 +4,7 @@ use App\Notifications\ForgotPassword; use App\Notifications\Registered; +use App\Option\CreateNewPassword; use App\User; use Exception; use Illuminate\Http; @@ -88,6 +89,13 @@ public function createPassword(Request $request): Http\JsonResponse } } + public function optionsCreateNewPassword(): Http\JsonResponse + { + $response = new CreateNewPassword([]); + + return $response->create()->response(); + } + public function createNewPassword(Request $request): Http\JsonResponse { $email = Str::replaceFirst(' ', '+', urldecode($request->query('email'))); @@ -250,7 +258,7 @@ public function login(Request $request): Http\JsonResponse return response()->json(['message' => 'Unauthorised, credentials invalid'], 401); } - public function logout(Request $request): Http\JsonResponse + public function logout(): Http\JsonResponse { Auth::logout(); diff --git a/app/Option/CreateNewPassword.php b/app/Option/CreateNewPassword.php new file mode 100644 index 00000000..1ea1e653 --- /dev/null +++ b/app/Option/CreateNewPassword.php @@ -0,0 +1,20 @@ +verbs['POST'] = $post->setFields(Config::get('api.auth.create-new-password.fields')) + ->setAuthenticationRequirement() + ->setDescription('route-descriptions.auth_create_new_password_POST') + ->option(); + + return $this; + } +} diff --git a/config/api/auth/create-new-password/fields.php b/config/api/auth/create-new-password/fields.php new file mode 100644 index 00000000..602977b5 --- /dev/null +++ b/config/api/auth/create-new-password/fields.php @@ -0,0 +1,27 @@ + [ + 'field' => 'password', + 'title' => 'auth/create-new-password/fields.title-password', + 'description' => 'auth/create-new-password/fields.description-password', + 'type' => 'string', + 'validation' => [ + 'min-length' => 12 + ], + 'required' => true + ], + 'password_confirmation' => [ + 'field' => 'description', + 'title' => 'category/fields.title-description', + 'description' => 'category/fields.description-description', + 'type' => 'string', + 'validation' => [ + 'matches' => 'password', + 'min-length' => 12 + ], + 'required' => true + ] +]; diff --git a/resources/lang/en/auth/create-new-password/fields.php b/resources/lang/en/auth/create-new-password/fields.php new file mode 100644 index 00000000..7689ac85 --- /dev/null +++ b/resources/lang/en/auth/create-new-password/fields.php @@ -0,0 +1,11 @@ + 'Password', + 'description-password' => 'Enter your password', + + 'title-password_confirmation' => 'Password confirmation', + 'description-password_confirmation' => 'Enter your password again' +]; diff --git a/resources/lang/en/route-descriptions.php b/resources/lang/en/route-descriptions.php index d313f1ee..c685d708 100644 --- a/resources/lang/en/route-descriptions.php +++ b/resources/lang/en/route-descriptions.php @@ -3,6 +3,8 @@ declare(strict_types=1); return [ + 'auth_create_new_password_POST' => 'Create the password for your account', + 'api_GET_index' => 'Return all the API routes', 'api_GET_changelog' => 'Return the complete API changelog', diff --git a/routes/api/auth.php b/routes/api/auth.php index 7f8344ba..9d310da9 100644 --- a/routes/api/auth.php +++ b/routes/api/auth.php @@ -19,6 +19,11 @@ function () { [Authentication::class, 'createNewPassword'] )->name('auth.create-new-password'); + Route::options( + 'auth/create-new-password', + [Authentication::class, 'optionsCreateNewPassword'] + ); + Route::post( 'auth/forgot-password', [Authentication::class, 'forgotPassword'] From b377ae705a69bc3bccebe5fd2d1c4f102fb5e254 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Wed, 12 Jan 2022 10:28:07 +0000 Subject: [PATCH 07/73] OPTIONS request - Added an OPTIONS request for /auth/create-password - Updated the README --- README.md | 3 ++- app/Http/Controllers/Authentication.php | 12 +++++++-- app/Option/CreateNewPassword.php | 2 +- app/Option/CreatePassword.php | 20 ++++++++++++++ config/api/auth/create-password/fields.php | 27 +++++++++++++++++++ .../lang/en/auth/create-password/fields.php | 11 ++++++++ resources/lang/en/route-descriptions.php | 3 ++- routes/api/auth.php | 5 ++++ 8 files changed, 78 insertions(+), 5 deletions(-) create mode 100644 app/Option/CreatePassword.php create mode 100644 config/api/auth/create-password/fields.php create mode 100644 resources/lang/en/auth/create-password/fields.php diff --git a/README.md b/README.md index 7859d217..cffc167f 100644 --- a/README.md +++ b/README.md @@ -116,7 +116,8 @@ additionally, the same is true if you are assigned as a permitted user to a reso | OPTIONS | v2/ | | GET/HEAD | v2/auth/check | | OPTIONS | v2/auth/create-password | -| POST | v2/auth/create-password | +| POST | v2/auth/create-password | +| OPTIONS | v2/auth/create-new-password | | POST | v2/auth/create-new-password | | POST | v2/auth/forgot-password | | POST | v2/auth/login | diff --git a/app/Http/Controllers/Authentication.php b/app/Http/Controllers/Authentication.php index 5fb920da..4471b0d3 100644 --- a/app/Http/Controllers/Authentication.php +++ b/app/Http/Controllers/Authentication.php @@ -5,6 +5,7 @@ use App\Notifications\ForgotPassword; use App\Notifications\Registered; use App\Option\CreateNewPassword; +use App\Option\CreatePassword; use App\User; use Exception; use Illuminate\Http; @@ -89,9 +90,9 @@ public function createPassword(Request $request): Http\JsonResponse } } - public function optionsCreateNewPassword(): Http\JsonResponse + public function optionsCreatePassword(): Http\JsonResponse { - $response = new CreateNewPassword([]); + $response = new CreatePassword([]); return $response->create()->response(); } @@ -161,6 +162,13 @@ public function createNewPassword(Request $request): Http\JsonResponse } } + public function optionsCreateNewPassword(): Http\JsonResponse + { + $response = new CreateNewPassword([]); + + return $response->create()->response(); + } + public function forgotPassword(Request $request): Http\JsonResponse { $validator = Validator::make( diff --git a/app/Option/CreateNewPassword.php b/app/Option/CreateNewPassword.php index 1ea1e653..18b0f317 100644 --- a/app/Option/CreateNewPassword.php +++ b/app/Option/CreateNewPassword.php @@ -10,7 +10,7 @@ class CreateNewPassword extends Response public function create() { $post = new \App\Method\PostRequest(); - $this->verbs['POST'] = $post->setFields(Config::get('api.auth.create-new-password.fields')) + $this->verbs['POST'] = $post->setFields(Config::get('api.auth.create-password.fields')) ->setAuthenticationRequirement() ->setDescription('route-descriptions.auth_create_new_password_POST') ->option(); diff --git a/app/Option/CreatePassword.php b/app/Option/CreatePassword.php new file mode 100644 index 00000000..dac831c6 --- /dev/null +++ b/app/Option/CreatePassword.php @@ -0,0 +1,20 @@ +verbs['POST'] = $post->setFields(Config::get('api.auth.create-password.fields')) + ->setAuthenticationRequirement() + ->setDescription('route-descriptions.auth_create_password_POST') + ->option(); + + return $this; + } +} diff --git a/config/api/auth/create-password/fields.php b/config/api/auth/create-password/fields.php new file mode 100644 index 00000000..602977b5 --- /dev/null +++ b/config/api/auth/create-password/fields.php @@ -0,0 +1,27 @@ + [ + 'field' => 'password', + 'title' => 'auth/create-new-password/fields.title-password', + 'description' => 'auth/create-new-password/fields.description-password', + 'type' => 'string', + 'validation' => [ + 'min-length' => 12 + ], + 'required' => true + ], + 'password_confirmation' => [ + 'field' => 'description', + 'title' => 'category/fields.title-description', + 'description' => 'category/fields.description-description', + 'type' => 'string', + 'validation' => [ + 'matches' => 'password', + 'min-length' => 12 + ], + 'required' => true + ] +]; diff --git a/resources/lang/en/auth/create-password/fields.php b/resources/lang/en/auth/create-password/fields.php new file mode 100644 index 00000000..7689ac85 --- /dev/null +++ b/resources/lang/en/auth/create-password/fields.php @@ -0,0 +1,11 @@ + 'Password', + 'description-password' => 'Enter your password', + + 'title-password_confirmation' => 'Password confirmation', + 'description-password_confirmation' => 'Enter your password again' +]; diff --git a/resources/lang/en/route-descriptions.php b/resources/lang/en/route-descriptions.php index c685d708..5f340ca5 100644 --- a/resources/lang/en/route-descriptions.php +++ b/resources/lang/en/route-descriptions.php @@ -3,7 +3,8 @@ declare(strict_types=1); return [ - 'auth_create_new_password_POST' => 'Create the password for your account', + 'auth_create_new_password_POST' => 'Create a new password for your account, `token` and `email` are request parameters', + 'auth_create_password_POST' => 'Create the password for your account, `token` and `email` are request parameters', 'api_GET_index' => 'Return all the API routes', 'api_GET_changelog' => 'Return the complete API changelog', diff --git a/routes/api/auth.php b/routes/api/auth.php index 9d310da9..4b60c0fa 100644 --- a/routes/api/auth.php +++ b/routes/api/auth.php @@ -50,6 +50,11 @@ function () { 'auth/create-password', [Authentication::class, 'createPassword'] )->name('auth.create-password'); + + Route::options( + 'auth/create-password', + [Authentication::class, 'optionsCreatePassword'] + ); } } ); From e2e956c81a8b48f73504f5e11f82dae55edb37e9 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Wed, 12 Jan 2022 10:47:25 +0000 Subject: [PATCH 08/73] OPTIONS request - Added an OPTIONS request for /auth/forgot-password. - Updated the README. - Corrected localisations --- README.md | 1 + app/Http/Controllers/Authentication.php | 7 +++++++ app/Option/ForgotPassword.php | 20 +++++++++++++++++++ .../api/auth/create-new-password/fields.php | 4 ++-- config/api/auth/create-password/fields.php | 8 ++++---- config/api/auth/forgot-password/fields.php | 13 ++++++++++++ .../lang/en/auth/forgot-password/fields.php | 8 ++++++++ resources/lang/en/route-descriptions.php | 1 + routes/api/auth.php | 5 +++++ 9 files changed, 61 insertions(+), 6 deletions(-) create mode 100644 app/Option/ForgotPassword.php create mode 100644 config/api/auth/forgot-password/fields.php create mode 100644 resources/lang/en/auth/forgot-password/fields.php diff --git a/README.md b/README.md index cffc167f..06b24d41 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,7 @@ additionally, the same is true if you are assigned as a permitted user to a reso | POST | v2/auth/create-password | | OPTIONS | v2/auth/create-new-password | | POST | v2/auth/create-new-password | +| OPTIONS | v2/auth/forgot-password | | POST | v2/auth/forgot-password | | POST | v2/auth/login | | GET | v2/auth/logout | diff --git a/app/Http/Controllers/Authentication.php b/app/Http/Controllers/Authentication.php index 4471b0d3..7252e834 100644 --- a/app/Http/Controllers/Authentication.php +++ b/app/Http/Controllers/Authentication.php @@ -236,6 +236,13 @@ public function forgotPassword(Request $request): Http\JsonResponse return response()->json(['message' => 'Unable to fetch your user account, please try again later'], 404); } + public function optionsForgotPassword(): Http\JsonResponse + { + $response = new \App\Option\ForgotPassword([]); + + return $response->create()->response(); + } + public function login(Request $request): Http\JsonResponse { if ( diff --git a/app/Option/ForgotPassword.php b/app/Option/ForgotPassword.php new file mode 100644 index 00000000..d2edfa20 --- /dev/null +++ b/app/Option/ForgotPassword.php @@ -0,0 +1,20 @@ +verbs['POST'] = $post->setFields(Config::get('api.auth.forgot-password.fields')) + ->setAuthenticationRequirement() + ->setDescription('route-descriptions.auth_forgot_password_POST') + ->option(); + + return $this; + } +} diff --git a/config/api/auth/create-new-password/fields.php b/config/api/auth/create-new-password/fields.php index 602977b5..2dea40fd 100644 --- a/config/api/auth/create-new-password/fields.php +++ b/config/api/auth/create-new-password/fields.php @@ -15,8 +15,8 @@ ], 'password_confirmation' => [ 'field' => 'description', - 'title' => 'category/fields.title-description', - 'description' => 'category/fields.description-description', + 'title' => 'auth/create-new-password/fields.title-password_confirmation', + 'description' => 'auth/create-new-password/fields.description-password_confirmation', 'type' => 'string', 'validation' => [ 'matches' => 'password', diff --git a/config/api/auth/create-password/fields.php b/config/api/auth/create-password/fields.php index 602977b5..6041c350 100644 --- a/config/api/auth/create-password/fields.php +++ b/config/api/auth/create-password/fields.php @@ -5,8 +5,8 @@ return [ 'password' => [ 'field' => 'password', - 'title' => 'auth/create-new-password/fields.title-password', - 'description' => 'auth/create-new-password/fields.description-password', + 'title' => 'auth/create-password/fields.title-password', + 'description' => 'auth/create-password/fields.description-password', 'type' => 'string', 'validation' => [ 'min-length' => 12 @@ -15,8 +15,8 @@ ], 'password_confirmation' => [ 'field' => 'description', - 'title' => 'category/fields.title-description', - 'description' => 'category/fields.description-description', + 'title' => 'auth/create-password/fields.title-password_confirmation', + 'description' => 'auth/create-password/fields.description-password_confirmation', 'type' => 'string', 'validation' => [ 'matches' => 'password', diff --git a/config/api/auth/forgot-password/fields.php b/config/api/auth/forgot-password/fields.php new file mode 100644 index 00000000..b32cc607 --- /dev/null +++ b/config/api/auth/forgot-password/fields.php @@ -0,0 +1,13 @@ + [ + 'field' => 'email', + 'title' => 'auth/forgot-password/fields.title-password', + 'description' => 'auth/forgot-password/fields.description-password', + 'type' => 'email', + 'required' => true + ] +]; diff --git a/resources/lang/en/auth/forgot-password/fields.php b/resources/lang/en/auth/forgot-password/fields.php new file mode 100644 index 00000000..745c2dda --- /dev/null +++ b/resources/lang/en/auth/forgot-password/fields.php @@ -0,0 +1,8 @@ + 'Email', + 'description-email' => 'Enter your email', +]; diff --git a/resources/lang/en/route-descriptions.php b/resources/lang/en/route-descriptions.php index 5f340ca5..1ac83e10 100644 --- a/resources/lang/en/route-descriptions.php +++ b/resources/lang/en/route-descriptions.php @@ -5,6 +5,7 @@ return [ 'auth_create_new_password_POST' => 'Create a new password for your account, `token` and `email` are request parameters', 'auth_create_password_POST' => 'Create the password for your account, `token` and `email` are request parameters', + 'auth_forgot_password_POST' => 'Start the reset password process', 'api_GET_index' => 'Return all the API routes', 'api_GET_changelog' => 'Return the complete API changelog', diff --git a/routes/api/auth.php b/routes/api/auth.php index 4b60c0fa..10a505be 100644 --- a/routes/api/auth.php +++ b/routes/api/auth.php @@ -29,6 +29,11 @@ function () { [Authentication::class, 'forgotPassword'] )->name('auth.forgot-password'); + Route::options( + 'auth/forgot-password', + [Authentication::class, 'optionsForgotPassword'] + ); + Route::post( 'auth/login', [Authentication::class, 'login'] From 831823bf4d0c2788940d8a544655c0269397dc15 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Wed, 12 Jan 2022 11:07:25 +0000 Subject: [PATCH 09/73] OPTIONS - Added an OPTIONS request for /auth/login --- README.md | 1 + app/Http/Controllers/Authentication.php | 8 ++++++++ app/Option/Login.php | 20 ++++++++++++++++++++ config/api/auth/login/fields.php | 23 +++++++++++++++++++++++ resources/lang/en/auth/login/fields.php | 11 +++++++++++ resources/lang/en/route-descriptions.php | 1 + routes/api/auth.php | 4 ++++ 7 files changed, 68 insertions(+) create mode 100644 app/Option/Login.php create mode 100644 config/api/auth/login/fields.php create mode 100644 resources/lang/en/auth/login/fields.php diff --git a/README.md b/README.md index 06b24d41..0b1c7a33 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,7 @@ additionally, the same is true if you are assigned as a permitted user to a reso | POST | v2/auth/create-new-password | | OPTIONS | v2/auth/forgot-password | | POST | v2/auth/forgot-password | +| OPTIONS | v2/auth/login | | POST | v2/auth/login | | GET | v2/auth/logout | | POST | v2/auth/register | diff --git a/app/Http/Controllers/Authentication.php b/app/Http/Controllers/Authentication.php index 7252e834..5577745a 100644 --- a/app/Http/Controllers/Authentication.php +++ b/app/Http/Controllers/Authentication.php @@ -6,6 +6,7 @@ use App\Notifications\Registered; use App\Option\CreateNewPassword; use App\Option\CreatePassword; +use App\Option\Login; use App\User; use Exception; use Illuminate\Http; @@ -273,6 +274,13 @@ public function login(Request $request): Http\JsonResponse return response()->json(['message' => 'Unauthorised, credentials invalid'], 401); } + public function optionsLogin(): Http\JsonResponse + { + $response = new Login([]); + + return $response->create()->response(); + } + public function logout(): Http\JsonResponse { Auth::logout(); diff --git a/app/Option/Login.php b/app/Option/Login.php new file mode 100644 index 00000000..7319eebf --- /dev/null +++ b/app/Option/Login.php @@ -0,0 +1,20 @@ +verbs['POST'] = $post->setFields(Config::get('api.auth.login.fields')) + ->setAuthenticationRequirement() + ->setDescription('route-descriptions.auth_login_POST') + ->option(); + + return $this; + } +} diff --git a/config/api/auth/login/fields.php b/config/api/auth/login/fields.php new file mode 100644 index 00000000..db39574b --- /dev/null +++ b/config/api/auth/login/fields.php @@ -0,0 +1,23 @@ + [ + 'field' => 'email', + 'title' => 'auth/login/fields.title-email', + 'description' => 'auth/login/fields.description-email', + 'type' => 'email', + 'required' => true + ], + 'password' => [ + 'field' => 'password', + 'title' => 'auth/login/fields.title-password', + 'description' => 'auth/login/fields.description-password', + 'type' => 'email', + 'validation' => [ + 'min-length' => 12 + ], + 'required' => true + ] +]; diff --git a/resources/lang/en/auth/login/fields.php b/resources/lang/en/auth/login/fields.php new file mode 100644 index 00000000..f8277e92 --- /dev/null +++ b/resources/lang/en/auth/login/fields.php @@ -0,0 +1,11 @@ + 'Email', + 'description-email' => 'Enter your email address', + + 'title-password' => 'Password', + 'description-password' => 'Enter your password' +]; diff --git a/resources/lang/en/route-descriptions.php b/resources/lang/en/route-descriptions.php index 1ac83e10..2ae81a4e 100644 --- a/resources/lang/en/route-descriptions.php +++ b/resources/lang/en/route-descriptions.php @@ -6,6 +6,7 @@ 'auth_create_new_password_POST' => 'Create a new password for your account, `token` and `email` are request parameters', 'auth_create_password_POST' => 'Create the password for your account, `token` and `email` are request parameters', 'auth_forgot_password_POST' => 'Start the reset password process', + 'auth_login_POST' => 'Login to the API', 'api_GET_index' => 'Return all the API routes', 'api_GET_changelog' => 'Return the complete API changelog', diff --git a/routes/api/auth.php b/routes/api/auth.php index 10a505be..e6c622d7 100644 --- a/routes/api/auth.php +++ b/routes/api/auth.php @@ -39,6 +39,10 @@ function () { [Authentication::class, 'login'] )->name('auth.login'); + Route::options( + 'auth/login', + [Authentication::class, 'optionsLogin']); + Route::get( 'auth/logout', [Authentication::class, 'logout'] From a313958f83d0587b59cf4061a2c964afc1405433 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Wed, 12 Jan 2022 11:13:19 +0000 Subject: [PATCH 10/73] OPTIONS request - Added an OPTIONS request for /auth/register - Updated the README --- README.md | 1 + app/Http/Controllers/Authentication.php | 8 ++++++++ app/Option/Register.php | 20 +++++++++++++++++++ config/api/auth/login/fields.php | 2 +- config/api/auth/register/fields.php | 23 ++++++++++++++++++++++ resources/lang/en/auth/register/fields.php | 11 +++++++++++ resources/lang/en/route-descriptions.php | 1 + routes/api/auth.php | 7 ++++++- 8 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 app/Option/Register.php create mode 100644 config/api/auth/register/fields.php create mode 100644 resources/lang/en/auth/register/fields.php diff --git a/README.md b/README.md index 0b1c7a33..4b233a67 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,7 @@ additionally, the same is true if you are assigned as a permitted user to a reso | OPTIONS | v2/auth/login | | POST | v2/auth/login | | GET | v2/auth/logout | +| OPTIONS | v2/auth/register | | POST | v2/auth/register | | POST | v2/auth/update-password | | POST | v2/auth/update-profile | diff --git a/app/Http/Controllers/Authentication.php b/app/Http/Controllers/Authentication.php index 5577745a..700012ba 100644 --- a/app/Http/Controllers/Authentication.php +++ b/app/Http/Controllers/Authentication.php @@ -7,6 +7,7 @@ use App\Option\CreateNewPassword; use App\Option\CreatePassword; use App\Option\Login; +use App\Option\Register; use App\User; use Exception; use Illuminate\Http; @@ -355,6 +356,13 @@ public function register(Request $request): Http\JsonResponse ); } + public function optionsRegister(): Http\JsonResponse + { + $response = new Register([]); + + return $response->create()->response(); + } + public function updatePassword(Request $request): Http\JsonResponse { $validator = Validator::make( diff --git a/app/Option/Register.php b/app/Option/Register.php new file mode 100644 index 00000000..61470783 --- /dev/null +++ b/app/Option/Register.php @@ -0,0 +1,20 @@ +verbs['POST'] = $post->setFields(Config::get('api.auth.register.fields')) + ->setAuthenticationRequirement() + ->setDescription('route-descriptions.auth_register_POST') + ->option(); + + return $this; + } +} diff --git a/config/api/auth/login/fields.php b/config/api/auth/login/fields.php index db39574b..3fc5bb9d 100644 --- a/config/api/auth/login/fields.php +++ b/config/api/auth/login/fields.php @@ -14,7 +14,7 @@ 'field' => 'password', 'title' => 'auth/login/fields.title-password', 'description' => 'auth/login/fields.description-password', - 'type' => 'email', + 'type' => 'string', 'validation' => [ 'min-length' => 12 ], diff --git a/config/api/auth/register/fields.php b/config/api/auth/register/fields.php new file mode 100644 index 00000000..04eb9995 --- /dev/null +++ b/config/api/auth/register/fields.php @@ -0,0 +1,23 @@ + [ + 'field' => 'email', + 'title' => 'auth/register/fields.title-email', + 'description' => 'auth/register/fields.description-email', + 'type' => 'email', + 'required' => true + ], + 'password' => [ + 'field' => 'password', + 'title' => 'auth/register/fields.title-password', + 'description' => 'auth/register/fields.description-password', + 'type' => 'string', + 'validation' => [ + 'min-length' => 12 + ], + 'required' => true + ] +]; diff --git a/resources/lang/en/auth/register/fields.php b/resources/lang/en/auth/register/fields.php new file mode 100644 index 00000000..f8277e92 --- /dev/null +++ b/resources/lang/en/auth/register/fields.php @@ -0,0 +1,11 @@ + 'Email', + 'description-email' => 'Enter your email address', + + 'title-password' => 'Password', + 'description-password' => 'Enter your password' +]; diff --git a/resources/lang/en/route-descriptions.php b/resources/lang/en/route-descriptions.php index 2ae81a4e..00a750f7 100644 --- a/resources/lang/en/route-descriptions.php +++ b/resources/lang/en/route-descriptions.php @@ -7,6 +7,7 @@ 'auth_create_password_POST' => 'Create the password for your account, `token` and `email` are request parameters', 'auth_forgot_password_POST' => 'Start the reset password process', 'auth_login_POST' => 'Login to the API', + 'auth_register_POST' => 'Register with the API', 'api_GET_index' => 'Return all the API routes', 'api_GET_changelog' => 'Return the complete API changelog', diff --git a/routes/api/auth.php b/routes/api/auth.php index e6c622d7..3983b30b 100644 --- a/routes/api/auth.php +++ b/routes/api/auth.php @@ -52,9 +52,14 @@ function () { if (Config::get('api.app.config.registrations') === true) { Route::post( 'auth/register', - 'Authentication@register' + [Authentication::class, 'register'] )->name('auth.register'); + Route::options( + 'auth/register', + [Authentication::class, 'optionsRegister'] + ); + Route::post( 'auth/create-password', [Authentication::class, 'createPassword'] From 2a85563307ac0460587aab8557f3a829740cabc2 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Wed, 12 Jan 2022 11:27:33 +0000 Subject: [PATCH 11/73] OPTIONS request - Added an OPTIONS request for /auth/update-password - Updated the README --- README.md | 1 + app/Http/Controllers/Authentication.php | 8 ++++++ app/Option/UpdatePassword.php | 21 +++++++++++++++ config/api/auth/update-password/fields.php | 27 +++++++++++++++++++ .../lang/en/auth/update-password/fields.php | 11 ++++++++ resources/lang/en/route-descriptions.php | 1 + routes/api/auth.php | 4 +++ 7 files changed, 73 insertions(+) create mode 100644 app/Option/UpdatePassword.php create mode 100644 config/api/auth/update-password/fields.php create mode 100644 resources/lang/en/auth/update-password/fields.php diff --git a/README.md b/README.md index 4b233a67..ee911361 100644 --- a/README.md +++ b/README.md @@ -126,6 +126,7 @@ additionally, the same is true if you are assigned as a permitted user to a reso | GET | v2/auth/logout | | OPTIONS | v2/auth/register | | POST | v2/auth/register | +| OPTIONS | v2/auth/update-password | | POST | v2/auth/update-password | | POST | v2/auth/update-profile | | GET/HEAD | v2/auth/user | diff --git a/app/Http/Controllers/Authentication.php b/app/Http/Controllers/Authentication.php index 700012ba..58ce478d 100644 --- a/app/Http/Controllers/Authentication.php +++ b/app/Http/Controllers/Authentication.php @@ -8,6 +8,7 @@ use App\Option\CreatePassword; use App\Option\Login; use App\Option\Register; +use App\Option\UpdatePassword; use App\User; use Exception; use Illuminate\Http; @@ -401,6 +402,13 @@ public function updatePassword(Request $request): Http\JsonResponse return response()->json(['message' => 'Unauthorised, credentials invalid'], 401); } + public function optionsUpdatePassword(): Http\JsonResponse + { + $response = new UpdatePassword(['view'=> $this->user_id !== null, 'manage'=> $this->user_id !== null]); + + return $response->create()->response(); + } + public function updateProfile(Request $request): Http\JsonResponse { $validator = Validator::make( diff --git a/app/Option/UpdatePassword.php b/app/Option/UpdatePassword.php new file mode 100644 index 00000000..aba13ce8 --- /dev/null +++ b/app/Option/UpdatePassword.php @@ -0,0 +1,21 @@ +verbs['POST'] = $post->setFields(Config::get('api.auth.update-password.fields')) + ->setAuthenticationRequirement(true) + ->setAuthenticationStatus($this->permissions['manage']) + ->setDescription('route-descriptions.auth_update_password_POST') + ->option(); + + return $this; + } +} diff --git a/config/api/auth/update-password/fields.php b/config/api/auth/update-password/fields.php new file mode 100644 index 00000000..aa9c21be --- /dev/null +++ b/config/api/auth/update-password/fields.php @@ -0,0 +1,27 @@ + [ + 'field' => 'password', + 'title' => 'auth/update-password/fields.title-password', + 'description' => 'auth/update-password/fields.description-password', + 'type' => 'string', + 'validation' => [ + 'min-length' => 12 + ], + 'required' => true + ], + 'password_confirmation' => [ + 'field' => 'description', + 'title' => 'auth/update-password/fields.title-password_confirmation', + 'description' => 'auth/update-password/fields.description-password_confirmation', + 'type' => 'string', + 'validation' => [ + 'matches' => 'password', + 'min-length' => 12 + ], + 'required' => true + ] +]; diff --git a/resources/lang/en/auth/update-password/fields.php b/resources/lang/en/auth/update-password/fields.php new file mode 100644 index 00000000..7689ac85 --- /dev/null +++ b/resources/lang/en/auth/update-password/fields.php @@ -0,0 +1,11 @@ + 'Password', + 'description-password' => 'Enter your password', + + 'title-password_confirmation' => 'Password confirmation', + 'description-password_confirmation' => 'Enter your password again' +]; diff --git a/resources/lang/en/route-descriptions.php b/resources/lang/en/route-descriptions.php index 00a750f7..da98a4e4 100644 --- a/resources/lang/en/route-descriptions.php +++ b/resources/lang/en/route-descriptions.php @@ -8,6 +8,7 @@ 'auth_forgot_password_POST' => 'Start the reset password process', 'auth_login_POST' => 'Login to the API', 'auth_register_POST' => 'Register with the API', + 'auth_update_password_POST' => 'Update your account password', 'api_GET_index' => 'Return all the API routes', 'api_GET_changelog' => 'Return the complete API changelog', diff --git a/routes/api/auth.php b/routes/api/auth.php index 3983b30b..4396c9fb 100644 --- a/routes/api/auth.php +++ b/routes/api/auth.php @@ -48,6 +48,10 @@ function () { [Authentication::class, 'logout'] )->name('auth.logout'); + Route::options( + 'auth/update-password', + [Authentication::class, 'optionsUpdatePassword'] + ); if (Config::get('api.app.config.registrations') === true) { Route::post( From 3ad8a8e7c3fd303127e8ccd13cd21352b9d6635a Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Wed, 12 Jan 2022 11:40:06 +0000 Subject: [PATCH 12/73] Options request - Added an OPTIONS request for /auth/update-profile - Updated the README --- README.md | 1 + app/Http/Controllers/Authentication.php | 8 +++++++ app/Option/UpdateProfile.php | 21 +++++++++++++++++ config/api/auth/update-profile/fields.php | 23 +++++++++++++++++++ .../lang/en/auth/update-profile/fields.php | 11 +++++++++ resources/lang/en/route-descriptions.php | 1 + routes/api/auth.php | 5 ++++ 7 files changed, 70 insertions(+) create mode 100644 app/Option/UpdateProfile.php create mode 100644 config/api/auth/update-profile/fields.php create mode 100644 resources/lang/en/auth/update-profile/fields.php diff --git a/README.md b/README.md index ee911361..77dd1bd1 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,7 @@ additionally, the same is true if you are assigned as a permitted user to a reso | POST | v2/auth/register | | OPTIONS | v2/auth/update-password | | POST | v2/auth/update-password | +| OPTIONS | v2/auth/update-profile | | POST | v2/auth/update-profile | | GET/HEAD | v2/auth/user | | GET/HEAD | v2/changelog | diff --git a/app/Http/Controllers/Authentication.php b/app/Http/Controllers/Authentication.php index 58ce478d..4cb3d03c 100644 --- a/app/Http/Controllers/Authentication.php +++ b/app/Http/Controllers/Authentication.php @@ -9,6 +9,7 @@ use App\Option\Login; use App\Option\Register; use App\Option\UpdatePassword; +use App\Option\UpdateProfile; use App\User; use Exception; use Illuminate\Http; @@ -402,6 +403,13 @@ public function updatePassword(Request $request): Http\JsonResponse return response()->json(['message' => 'Unauthorised, credentials invalid'], 401); } + public function optionsUpdateProfile(): Http\JsonResponse + { + $response = new UpdateProfile(['view'=> $this->user_id !== null, 'manage'=> $this->user_id !== null]); + + return $response->create()->response(); + } + public function optionsUpdatePassword(): Http\JsonResponse { $response = new UpdatePassword(['view'=> $this->user_id !== null, 'manage'=> $this->user_id !== null]); diff --git a/app/Option/UpdateProfile.php b/app/Option/UpdateProfile.php new file mode 100644 index 00000000..c709ff28 --- /dev/null +++ b/app/Option/UpdateProfile.php @@ -0,0 +1,21 @@ +verbs['POST'] = $post->setFields(Config::get('api.auth.update-profile.fields')) + ->setAuthenticationRequirement(true) + ->setAuthenticationStatus($this->permissions['manage']) + ->setDescription('route-descriptions.auth_update_profile_POST') + ->option(); + + return $this; + } +} diff --git a/config/api/auth/update-profile/fields.php b/config/api/auth/update-profile/fields.php new file mode 100644 index 00000000..e83b39f8 --- /dev/null +++ b/config/api/auth/update-profile/fields.php @@ -0,0 +1,23 @@ + [ + 'field' => 'email', + 'title' => 'auth/update-profile/fields.title-email', + 'description' => 'auth/update-profile/fields.description-email', + 'type' => 'email', + 'required' => false + ], + 'password' => [ + 'field' => 'password', + 'title' => 'auth/update-profile/fields.title-password', + 'description' => 'auth/update-profile/fields.description-password', + 'type' => 'string', + 'validation' => [ + 'min-length' => 12 + ], + 'required' => false + ] +]; diff --git a/resources/lang/en/auth/update-profile/fields.php b/resources/lang/en/auth/update-profile/fields.php new file mode 100644 index 00000000..f8277e92 --- /dev/null +++ b/resources/lang/en/auth/update-profile/fields.php @@ -0,0 +1,11 @@ + 'Email', + 'description-email' => 'Enter your email address', + + 'title-password' => 'Password', + 'description-password' => 'Enter your password' +]; diff --git a/resources/lang/en/route-descriptions.php b/resources/lang/en/route-descriptions.php index da98a4e4..4f5d94ac 100644 --- a/resources/lang/en/route-descriptions.php +++ b/resources/lang/en/route-descriptions.php @@ -9,6 +9,7 @@ 'auth_login_POST' => 'Login to the API', 'auth_register_POST' => 'Register with the API', 'auth_update_password_POST' => 'Update your account password', + 'auth_update_profile_POST' => 'Update your account profile', 'api_GET_index' => 'Return all the API routes', 'api_GET_changelog' => 'Return the complete API changelog', diff --git a/routes/api/auth.php b/routes/api/auth.php index 4396c9fb..e8e7d7c5 100644 --- a/routes/api/auth.php +++ b/routes/api/auth.php @@ -53,6 +53,11 @@ function () { [Authentication::class, 'optionsUpdatePassword'] ); + Route::options( + 'auth/update-profile', + [Authentication::class, 'optionsUpdateProfile'] + ); + if (Config::get('api.app.config.registrations') === true) { Route::post( 'auth/register', From 3c117711af5410587fd52e045f2e24747a14da1b Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Wed, 12 Jan 2022 11:50:45 +0000 Subject: [PATCH 13/73] OPTIONS request - Added an OPTIONS request for /auth/user - Updated the README --- README.md | 1 + app/Http/Controllers/Authentication.php | 7 +++++++ app/Option/User.php | 20 ++++++++++++++++++++ resources/lang/en/route-descriptions.php | 1 + routes/api/auth.php | 5 +++++ 5 files changed, 34 insertions(+) create mode 100644 app/Option/User.php diff --git a/README.md b/README.md index 77dd1bd1..4d26e003 100644 --- a/README.md +++ b/README.md @@ -131,6 +131,7 @@ additionally, the same is true if you are assigned as a permitted user to a reso | OPTIONS | v2/auth/update-profile | | POST | v2/auth/update-profile | | GET/HEAD | v2/auth/user | +| OPTIONS | v2/auth/user | | GET/HEAD | v2/changelog | | OPTIONS | v2/changelog | | GET/HEAD | v2/currencies | diff --git a/app/Http/Controllers/Authentication.php b/app/Http/Controllers/Authentication.php index 4cb3d03c..0beddc91 100644 --- a/app/Http/Controllers/Authentication.php +++ b/app/Http/Controllers/Authentication.php @@ -490,4 +490,11 @@ public function user(): Http\JsonResponse return response()->json(['message' => 'Unauthorised, credentials invalid'], 401); } + + public function optionsUser(): Http\JsonResponse + { + $response = new \App\Option\User(['view'=> $this->user_id !== null]); + + return $response->create()->response(); + } } diff --git a/app/Option/User.php b/app/Option/User.php new file mode 100644 index 00000000..e9732aff --- /dev/null +++ b/app/Option/User.php @@ -0,0 +1,20 @@ +verbs['GET'] = $get->setSortableParameters([])-> + setSearchableParameters([])-> + setDescription('route-descriptions.auth_user_GET')-> + setAuthenticationRequirement(true)-> + setAuthenticationStatus($this->permissions['view'])-> + option(); + + return $this; + } +} diff --git a/resources/lang/en/route-descriptions.php b/resources/lang/en/route-descriptions.php index 4f5d94ac..9fe3789f 100644 --- a/resources/lang/en/route-descriptions.php +++ b/resources/lang/en/route-descriptions.php @@ -10,6 +10,7 @@ 'auth_register_POST' => 'Register with the API', 'auth_update_password_POST' => 'Update your account password', 'auth_update_profile_POST' => 'Update your account profile', + 'auth_user_GET' => 'Return the account details for the signed-in user', 'api_GET_index' => 'Return all the API routes', 'api_GET_changelog' => 'Return the complete API changelog', diff --git a/routes/api/auth.php b/routes/api/auth.php index e8e7d7c5..4b5e020b 100644 --- a/routes/api/auth.php +++ b/routes/api/auth.php @@ -58,6 +58,11 @@ function () { [Authentication::class, 'optionsUpdateProfile'] ); + Route::options( + 'auth/user', + [Authentication::class, 'optionsUser'] + ); + if (Config::get('api.app.config.registrations') === true) { Route::post( 'auth/register', From 270e8a83ad0e204d70de6c4e76cf39d1e10e2ad3 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Wed, 12 Jan 2022 12:00:17 +0000 Subject: [PATCH 14/73] OPTIONS request - Added an OPTIONS request for /auth/check - Updated the README --- README.md | 1 + app/Http/Controllers/Authentication.php | 7 +++++++ app/Option/Check.php | 19 +++++++++++++++++++ resources/lang/en/route-descriptions.php | 1 + routes/api/auth.php | 5 +++++ 5 files changed, 33 insertions(+) create mode 100644 app/Option/Check.php diff --git a/README.md b/README.md index 4d26e003..5086b8bc 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,7 @@ additionally, the same is true if you are assigned as a permitted user to a reso | GET/HEAD | v2/ | | OPTIONS | v2/ | | GET/HEAD | v2/auth/check | +| OPTIONS | v2/auth/check | | OPTIONS | v2/auth/create-password | | POST | v2/auth/create-password | | OPTIONS | v2/auth/create-new-password | diff --git a/app/Http/Controllers/Authentication.php b/app/Http/Controllers/Authentication.php index 0beddc91..d611dbc6 100644 --- a/app/Http/Controllers/Authentication.php +++ b/app/Http/Controllers/Authentication.php @@ -29,6 +29,13 @@ public function check(): Http\JsonResponse return response()->json(['auth' => Auth::guard('api')->check()]); } + public function optionsCheck(): Http\JsonResponse + { + $response = new \App\Option\Check([]); + + return $response->create()->response(); + } + public function createPassword(Request $request): Http\JsonResponse { $email = Str::replaceFirst(' ', '+', urldecode($request->query('email'))); diff --git a/app/Option/Check.php b/app/Option/Check.php new file mode 100644 index 00000000..b31e8ad7 --- /dev/null +++ b/app/Option/Check.php @@ -0,0 +1,19 @@ +verbs['GET'] = $get->setSortableParameters([])-> + setSearchableParameters([])-> + setDescription('route-descriptions.auth_check_GET')-> + setAuthenticationRequirement(false)-> + option(); + + return $this; + } +} diff --git a/resources/lang/en/route-descriptions.php b/resources/lang/en/route-descriptions.php index 9fe3789f..d85393fc 100644 --- a/resources/lang/en/route-descriptions.php +++ b/resources/lang/en/route-descriptions.php @@ -11,6 +11,7 @@ 'auth_update_password_POST' => 'Update your account password', 'auth_update_profile_POST' => 'Update your account profile', 'auth_user_GET' => 'Return the account details for the signed-in user', + 'auth_check_GET' => 'Check to see if the user is authenticated', 'api_GET_index' => 'Return all the API routes', 'api_GET_changelog' => 'Return the complete API changelog', diff --git a/routes/api/auth.php b/routes/api/auth.php index 4b5e020b..99f70a66 100644 --- a/routes/api/auth.php +++ b/routes/api/auth.php @@ -63,6 +63,11 @@ function () { [Authentication::class, 'optionsUser'] ); + Route::options( + 'auth/check', + [Authentication::class, 'optionsCheck'] + ); + if (Config::get('api.app.config.registrations') === true) { Route::post( 'auth/register', From 1ae1e5e948f5a304682831c528471ead81c7d311 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Wed, 12 Jan 2022 16:55:29 +0000 Subject: [PATCH 15/73] Tests - Added tests for ResourceTypeView --- README.md | 1 + .../Controllers/ResourceTypeManageTest.php | 14 ++-- tests/TestCase.php | 10 +++ .../Http/Controllers/ResourceTypeViewTest.php | 67 +++++++++++++++++++ 4 files changed, 85 insertions(+), 7 deletions(-) create mode 100644 tests/View/Http/Controllers/ResourceTypeViewTest.php diff --git a/README.md b/README.md index 5086b8bc..baa92b06 100644 --- a/README.md +++ b/README.md @@ -263,6 +263,7 @@ our local test suite is as complete as the Postman request tests. | RequestManage | Not started | | ResourceManage | Complete (13 Tests/35 Assertions) | | ResourceTypeManage | Complete (14 Tests/30 Assertions) | +| ResourceTypeView | In Progress (3 Tests) | | SubcategoryManage | Not started | | ToolManage | Not started | | Total | In Progress (61 Tests/127 Assertions) | diff --git a/tests/Feature/Http/Controllers/ResourceTypeManageTest.php b/tests/Feature/Http/Controllers/ResourceTypeManageTest.php index 732aaace..14e4b6c7 100644 --- a/tests/Feature/Http/Controllers/ResourceTypeManageTest.php +++ b/tests/Feature/Http/Controllers/ResourceTypeManageTest.php @@ -87,7 +87,7 @@ public function create_resource_type_fails_non_unique_name(): void { $this->actingAs(User::find(1)); - $name = $this->faker->text(10); + $name = $this->faker->text(255); $response = $this->postResourceType( [ @@ -149,7 +149,7 @@ public function create_resource_type_success_include_data_field(): void $response = $this->postResourceType( [ - 'name' => $this->faker->text(10), + 'name' => $this->faker->text(255), 'description' => $this->faker->text, 'data' => '{"field": "value"}', 'item_type_id' => 'OqZwKX16bW', @@ -168,7 +168,7 @@ public function delete_resource_type_success(): void $response = $this->postResourceType( [ - 'name' => $this->faker->text(10), + 'name' => $this->faker->text(255), 'description' => $this->faker->text, 'item_type_id' => 'OqZwKX16bW', 'public' => false @@ -192,7 +192,7 @@ public function update_resource_type_fails_extra_fields_in_payload(): void $response = $this->postResourceType( [ - 'name' => $this->faker->text(10), + 'name' => $this->faker->text(255), 'description' => $this->faker->text, 'item_type_id' => 'OqZwKX16bW', 'public' => false @@ -221,7 +221,7 @@ public function update_resource_type_fails_no_payload(): void $response = $this->postResourceType( [ - 'name' => $this->faker->text(10), + 'name' => $this->faker->text(255), 'description' => $this->faker->text, 'item_type_id' => 'OqZwKX16bW', 'public' => false @@ -246,7 +246,7 @@ public function update_resource_type_fails_non_unique_name(): void { $this->actingAs(User::find(1)); - $name = $this->faker->text(15); + $name = $this->faker->text(255); // Create the first resource type $response = $this->postResourceType( @@ -264,7 +264,7 @@ public function update_resource_type_fails_non_unique_name(): void // Create the second resource type $response = $this->postResourceType( [ - 'name' => $this->faker->text(15), + 'name' => $this->faker->text(255), 'description' => $this->faker->text(255), 'item_type_id' => 'OqZwKX16bW', 'public' => false diff --git a/tests/TestCase.php b/tests/TestCase.php index 86fbe380..a58a3211 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -122,6 +122,16 @@ protected function helperCreateResourceType(): string $this->fail('Unable to create the resource type'); } + protected function fetchResourceType(array $parameters = []): TestResponse + { + return $this->get(route('resource-type.show', $parameters)); + } + + protected function fetchResourceTypes(array $parameters = []): TestResponse + { + return $this->get(route('resource-type.list', $parameters)); + } + protected function helperCreateResource(string $resource_type_id): string { $response = $this->postResource( diff --git a/tests/View/Http/Controllers/ResourceTypeViewTest.php b/tests/View/Http/Controllers/ResourceTypeViewTest.php new file mode 100644 index 00000000..71b21a16 --- /dev/null +++ b/tests/View/Http/Controllers/ResourceTypeViewTest.php @@ -0,0 +1,67 @@ +actingAs(User::find(1)); + + $response = $this->fetchResourceTypes(); + + $response->assertStatus(200); + + foreach ($response->json() as $item) { + try { + $json = json_encode($item, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + $this->fail('Unable to encode the JSON string'); + } + + $this->assertJsonIsResourceType($json); + } + } + + /** @test */ + public function collection_pagination(): void + { + $this->actingAs(User::find(1)); + + $response = $this->fetchResourceTypes(['offset'=>1, 'limit'=> 1]); + + $response->assertStatus(200); + $response->assertHeader('X-Offset', 1); + $response->assertHeader('X-Limit', 1); + + foreach ($response->json() as $item) { + try { + $json = json_encode($item, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + $this->fail('Unable to encode the JSON string'); + } + + $this->assertJsonIsResourceType($json); + } + } + + /** @test */ + public function item(): void + { + $this->actingAs(User::find(1)); + + $response = $this->fetchResourceTypes(['offset'=>0, 'limit'=> 1]); + $response->assertStatus(200); + + $resource_type_id = $response->json()[0]['id']; + + $response = $this->fetchResourceType(['resource_type_id'=> $resource_type_id]); + $response->assertStatus(200); + + $this->assertJsonIsResourceType($response->content()); + } +} From edf2f692b4a0c52256dcd2d26ed6e41d89593896 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Thu, 13 Jan 2022 22:48:46 +0000 Subject: [PATCH 16/73] Dependencies - Updated dependencies --- composer.lock | 152 +++++++++++++++++++++++++------------------------- 1 file changed, 76 insertions(+), 76 deletions(-) diff --git a/composer.lock b/composer.lock index 26d16c15..b45419dd 100644 --- a/composer.lock +++ b/composer.lock @@ -579,32 +579,28 @@ }, { "name": "doctrine/lexer", - "version": "1.2.1", + "version": "1.2.2", "source": { "type": "git", "url": "https://github.com/doctrine/lexer.git", - "reference": "e864bbf5904cb8f5bb334f99209b48018522f042" + "reference": "9c50f840f257bbb941e6f4a0e94ccf5db5c3f76c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/lexer/zipball/e864bbf5904cb8f5bb334f99209b48018522f042", - "reference": "e864bbf5904cb8f5bb334f99209b48018522f042", + "url": "https://api.github.com/repos/doctrine/lexer/zipball/9c50f840f257bbb941e6f4a0e94ccf5db5c3f76c", + "reference": "9c50f840f257bbb941e6f4a0e94ccf5db5c3f76c", "shasum": "" }, "require": { - "php": "^7.2 || ^8.0" + "php": "^7.1 || ^8.0" }, "require-dev": { - "doctrine/coding-standard": "^6.0", - "phpstan/phpstan": "^0.11.8", - "phpunit/phpunit": "^8.2" + "doctrine/coding-standard": "^9.0", + "phpstan/phpstan": "1.3", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "vimeo/psalm": "^4.11" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, "autoload": { "psr-4": { "Doctrine\\Common\\Lexer\\": "lib/Doctrine/Common/Lexer" @@ -639,7 +635,7 @@ ], "support": { "issues": "https://github.com/doctrine/lexer/issues", - "source": "https://github.com/doctrine/lexer/tree/1.2.1" + "source": "https://github.com/doctrine/lexer/tree/1.2.2" }, "funding": [ { @@ -655,20 +651,20 @@ "type": "tidelift" } ], - "time": "2020-05-25T17:44:05+00:00" + "time": "2022-01-12T08:27:12+00:00" }, { "name": "dragonmantank/cron-expression", - "version": "v3.2.3", + "version": "v3.2.4", "source": { "type": "git", "url": "https://github.com/dragonmantank/cron-expression.git", - "reference": "47c53bbb260d3c398fba9bfa9683dcf67add2579" + "reference": "9545dea2a1d92b60c8b3d06f02025c83e999bde0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/dragonmantank/cron-expression/zipball/47c53bbb260d3c398fba9bfa9683dcf67add2579", - "reference": "47c53bbb260d3c398fba9bfa9683dcf67add2579", + "url": "https://api.github.com/repos/dragonmantank/cron-expression/zipball/9545dea2a1d92b60c8b3d06f02025c83e999bde0", + "reference": "9545dea2a1d92b60c8b3d06f02025c83e999bde0", "shasum": "" }, "require": { @@ -708,7 +704,7 @@ ], "support": { "issues": "https://github.com/dragonmantank/cron-expression/issues", - "source": "https://github.com/dragonmantank/cron-expression/tree/v3.2.3" + "source": "https://github.com/dragonmantank/cron-expression/tree/v3.2.4" }, "funding": [ { @@ -716,7 +712,7 @@ "type": "github" } ], - "time": "2022-01-06T05:35:07+00:00" + "time": "2022-01-13T04:09:37+00:00" }, { "name": "egulias/email-validator", @@ -1301,16 +1297,16 @@ }, { "name": "laravel/framework", - "version": "v8.78.1", + "version": "v8.79.0", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "16359b5ebafba6579b397d7505b082a6d1bb2e31" + "reference": "8091f07558ff4a890435ff9d25fa9aca0189ad63" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/16359b5ebafba6579b397d7505b082a6d1bb2e31", - "reference": "16359b5ebafba6579b397d7505b082a6d1bb2e31", + "url": "https://api.github.com/repos/laravel/framework/zipball/8091f07558ff4a890435ff9d25fa9aca0189ad63", + "reference": "8091f07558ff4a890435ff9d25fa9aca0189ad63", "shasum": "" }, "require": { @@ -1342,7 +1338,7 @@ "symfony/routing": "^5.4", "symfony/var-dumper": "^5.4", "tijsverkoyen/css-to-inline-styles": "^2.2.2", - "vlucas/phpdotenv": "^5.2", + "vlucas/phpdotenv": "^5.4.1", "voku/portable-ascii": "^1.4.8" }, "conflict": { @@ -1399,6 +1395,7 @@ "symfony/cache": "^5.4" }, "suggest": { + "ably/ably-php": "Required to use the Ably broadcast driver (^1.0).", "aws/aws-sdk-php": "Required to use the SQS queue driver, DynamoDb failed job storage and SES mail driver (^3.198.1).", "brianium/paratest": "Required to run tests in parallel (^6.0).", "doctrine/dbal": "Required to rename columns and drop SQLite columns (^2.13.3|^3.1.4).", @@ -1469,24 +1466,24 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2022-01-05T14:52:50+00:00" + "time": "2022-01-12T16:12:41+00:00" }, { "name": "laravel/helpers", - "version": "v1.4.1", + "version": "v1.5.0", "source": { "type": "git", "url": "https://github.com/laravel/helpers.git", - "reference": "febb10d8daaf86123825de2cb87f789a3371f0ac" + "reference": "c28b0ccd799d58564c41a62395ac9511a1e72931" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/helpers/zipball/febb10d8daaf86123825de2cb87f789a3371f0ac", - "reference": "febb10d8daaf86123825de2cb87f789a3371f0ac", + "url": "https://api.github.com/repos/laravel/helpers/zipball/c28b0ccd799d58564c41a62395ac9511a1e72931", + "reference": "c28b0ccd799d58564c41a62395ac9511a1e72931", "shasum": "" }, "require": { - "illuminate/support": "~5.8.0|^6.0|^7.0|^8.0", + "illuminate/support": "~5.8.0|^6.0|^7.0|^8.0|^9.0", "php": "^7.1.3|^8.0" }, "require-dev": { @@ -1514,7 +1511,7 @@ }, { "name": "Dries Vints", - "email": "dries.vints@gmail.com" + "email": "dries@laravel.com" } ], "description": "Provides backwards compatibility for helpers in the latest Laravel release.", @@ -1523,34 +1520,34 @@ "laravel" ], "support": { - "source": "https://github.com/laravel/helpers/tree/v1.4.1" + "source": "https://github.com/laravel/helpers/tree/v1.5.0" }, - "time": "2021-02-16T15:27:11+00:00" + "time": "2022-01-12T15:58:51+00:00" }, { "name": "laravel/sanctum", - "version": "v2.13.0", + "version": "v2.14.0", "source": { "type": "git", "url": "https://github.com/laravel/sanctum.git", - "reference": "b4c07d0014b78430a3c827064217f811f0708eaa" + "reference": "0647a87140c7522e75826cffcadb3ad6e01f71e9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/sanctum/zipball/b4c07d0014b78430a3c827064217f811f0708eaa", - "reference": "b4c07d0014b78430a3c827064217f811f0708eaa", + "url": "https://api.github.com/repos/laravel/sanctum/zipball/0647a87140c7522e75826cffcadb3ad6e01f71e9", + "reference": "0647a87140c7522e75826cffcadb3ad6e01f71e9", "shasum": "" }, "require": { "ext-json": "*", - "illuminate/contracts": "^6.9|^7.0|^8.0", - "illuminate/database": "^6.9|^7.0|^8.0", - "illuminate/support": "^6.9|^7.0|^8.0", + "illuminate/contracts": "^6.9|^7.0|^8.0|^9.0", + "illuminate/database": "^6.9|^7.0|^8.0|^9.0", + "illuminate/support": "^6.9|^7.0|^8.0|^9.0", "php": "^7.2|^8.0" }, "require-dev": { "mockery/mockery": "^1.0", - "orchestra/testbench": "^4.0|^5.0|^6.0", + "orchestra/testbench": "^4.0|^5.0|^6.0|^7.0", "phpunit/phpunit": "^8.0|^9.3" }, "type": "library", @@ -1589,7 +1586,7 @@ "issues": "https://github.com/laravel/sanctum/issues", "source": "https://github.com/laravel/sanctum" }, - "time": "2021-12-14T17:49:47+00:00" + "time": "2022-01-12T15:07:43+00:00" }, { "name": "laravel/serializable-closure", @@ -1652,32 +1649,32 @@ }, { "name": "laravel/tinker", - "version": "v2.6.3", + "version": "v2.7.0", "source": { "type": "git", "url": "https://github.com/laravel/tinker.git", - "reference": "a9ddee4761ec8453c584e393b393caff189a3e42" + "reference": "5f2f9815b7631b9f586a3de7933c25f9327d4073" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/tinker/zipball/a9ddee4761ec8453c584e393b393caff189a3e42", - "reference": "a9ddee4761ec8453c584e393b393caff189a3e42", + "url": "https://api.github.com/repos/laravel/tinker/zipball/5f2f9815b7631b9f586a3de7933c25f9327d4073", + "reference": "5f2f9815b7631b9f586a3de7933c25f9327d4073", "shasum": "" }, "require": { - "illuminate/console": "^6.0|^7.0|^8.0", - "illuminate/contracts": "^6.0|^7.0|^8.0", - "illuminate/support": "^6.0|^7.0|^8.0", + "illuminate/console": "^6.0|^7.0|^8.0|^9.0", + "illuminate/contracts": "^6.0|^7.0|^8.0|^9.0", + "illuminate/support": "^6.0|^7.0|^8.0|^9.0", "php": "^7.2.5|^8.0", - "psy/psysh": "^0.10.4", - "symfony/var-dumper": "^4.3.4|^5.0" + "psy/psysh": "^0.10.4|^0.11.1", + "symfony/var-dumper": "^4.3.4|^5.0|^6.0" }, "require-dev": { "mockery/mockery": "~1.3.3|^1.4.2", "phpunit/phpunit": "^8.5.8|^9.3.3" }, "suggest": { - "illuminate/database": "The Illuminate Database package (^6.0|^7.0|^8.0)." + "illuminate/database": "The Illuminate Database package (^6.0|^7.0|^8.0|^9.0)." }, "type": "library", "extra": { @@ -1714,9 +1711,9 @@ ], "support": { "issues": "https://github.com/laravel/tinker/issues", - "source": "https://github.com/laravel/tinker/tree/v2.6.3" + "source": "https://github.com/laravel/tinker/tree/v2.7.0" }, - "time": "2021-12-07T16:41:42+00:00" + "time": "2022-01-10T08:52:49+00:00" }, { "name": "league/commonmark", @@ -3015,29 +3012,29 @@ }, { "name": "psy/psysh", - "version": "v0.10.12", + "version": "v0.11.1", "source": { "type": "git", "url": "https://github.com/bobthecow/psysh.git", - "reference": "a0d9981aa07ecfcbea28e4bfa868031cca121e7d" + "reference": "570292577277f06f590635381a7f761a6cf4f026" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/bobthecow/psysh/zipball/a0d9981aa07ecfcbea28e4bfa868031cca121e7d", - "reference": "a0d9981aa07ecfcbea28e4bfa868031cca121e7d", + "url": "https://api.github.com/repos/bobthecow/psysh/zipball/570292577277f06f590635381a7f761a6cf4f026", + "reference": "570292577277f06f590635381a7f761a6cf4f026", "shasum": "" }, "require": { "ext-json": "*", "ext-tokenizer": "*", - "nikic/php-parser": "~4.0|~3.0|~2.0|~1.3", - "php": "^8.0 || ^7.0 || ^5.5.9", - "symfony/console": "~5.0|~4.0|~3.0|^2.4.2|~2.3.10", - "symfony/var-dumper": "~5.0|~4.0|~3.0|~2.7" + "nikic/php-parser": "^4.0 || ^3.1", + "php": "^8.0 || ^7.0.8", + "symfony/console": "^6.0 || ^5.0 || ^4.0 || ^3.4", + "symfony/var-dumper": "^6.0 || ^5.0 || ^4.0 || ^3.4" }, "require-dev": { "bamarni/composer-bin-plugin": "^1.2", - "hoa/console": "3.17.*" + "hoa/console": "3.17.05.02" }, "suggest": { "ext-pcntl": "Enabling the PCNTL extension makes PsySH a lot happier :)", @@ -3052,7 +3049,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "0.10.x-dev" + "dev-main": "0.11.x-dev" } }, "autoload": { @@ -3084,9 +3081,9 @@ ], "support": { "issues": "https://github.com/bobthecow/psysh/issues", - "source": "https://github.com/bobthecow/psysh/tree/v0.10.12" + "source": "https://github.com/bobthecow/psysh/tree/v0.11.1" }, - "time": "2021-11-30T14:05:36+00:00" + "time": "2022-01-03T13:58:38+00:00" }, { "name": "ralouphie/getallheaders", @@ -6243,6 +6240,9 @@ "require": { "php": "^7.1 || ^8.0" }, + "replace": { + "myclabs/deep-copy": "self.version" + }, "require-dev": { "doctrine/collections": "^1.0", "doctrine/common": "^2.6", @@ -7133,12 +7133,12 @@ "source": { "type": "git", "url": "https://github.com/Roave/SecurityAdvisories.git", - "reference": "11696ae4d8970456cbd1919c17e6bb2ddb63553a" + "reference": "a1ce0a793ff447c9085f350d2fa8744efbdb5c1e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/11696ae4d8970456cbd1919c17e6bb2ddb63553a", - "reference": "11696ae4d8970456cbd1919c17e6bb2ddb63553a", + "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/a1ce0a793ff447c9085f350d2fa8744efbdb5c1e", + "reference": "a1ce0a793ff447c9085f350d2fa8744efbdb5c1e", "shasum": "" }, "conflict": { @@ -7201,7 +7201,7 @@ "doctrine/mongodb-odm": ">=1,<1.0.2", "doctrine/mongodb-odm-bundle": ">=2,<3.0.1", "doctrine/orm": ">=2,<2.4.8|>=2.5,<2.5.1|>=2.8.3,<2.8.4", - "dolibarr/dolibarr": "<14|>= 3.3.beta1, < 13.0.2", + "dolibarr/dolibarr": "<=14.0.4|>= 3.3.beta1, < 13.0.2", "dompdf/dompdf": ">=0.6,<0.6.2", "drupal/core": ">=7,<7.80|>=8,<8.9.16|>=9,<9.1.12|>=9.2,<9.2.4", "drupal/drupal": ">=7,<7.80|>=8,<8.9.16|>=9,<9.1.12|>=9.2,<9.2.4", @@ -7335,7 +7335,7 @@ "openmage/magento-lts": "<19.4.15|>=20,<20.0.13", "orchid/platform": ">=9,<9.4.4", "oro/crm": ">=1.7,<1.7.4|>=3.1,<4.1.17|>=4.2,<4.2.7", - "oro/platform": ">=1.7,<1.7.4|>=3.1,<3.1.21|>=4.1,<4.1.14|>=4.2,<4.2.8", + "oro/platform": ">=1.7,<1.7.4|>=3.1,<3.1.29|>=4.1,<4.1.17|>=4.2,<4.2.8", "padraic/humbug_get_contents": "<1.1.2", "pagarme/pagarme-php": ">=0,<3", "pagekit/pagekit": "<=1.0.18", @@ -7406,7 +7406,7 @@ "simplesamlphp/simplesamlphp-module-infocard": "<1.0.1", "simplito/elliptic-php": "<1.0.6", "slim/slim": "<2.6", - "smarty/smarty": "<3.1.39", + "smarty/smarty": "<3.1.43|>=4,<4.0.3", "snipe/snipe-it": "<5.3.5", "socalnick/scn-social-auth": "<1.15.2", "socialiteproviders/steam": "<1.1", @@ -7567,7 +7567,7 @@ "type": "tidelift" } ], - "time": "2022-01-08T00:53:14+00:00" + "time": "2022-01-12T23:15:39+00:00" }, { "name": "sebastian/cli-parser", @@ -8596,5 +8596,5 @@ "ext-json": "*" }, "platform-dev": [], - "plugin-api-version": "2.2.0" + "plugin-api-version": "2.1.0" } From 796f8e2462f46adde3877e4b5d09856a1c940995 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Thu, 13 Jan 2022 23:44:05 +0000 Subject: [PATCH 17/73] Review models - Reviewed models, fixed minor issues --- app/Models/Cache.php | 2 - app/Models/Category.php | 57 +-- app/Models/Currency.php | 9 +- app/Models/EntityLimits.php | 45 +- app/Models/ErrorLog.php | 9 +- app/Models/Item.php | 11 +- app/Models/ItemCategory.php | 21 +- app/Models/ItemPartialTransfer.php | 19 +- app/Models/ItemSubcategory.php | 22 +- app/Models/ItemSubtype.php | 11 +- app/Models/ItemTransfer.php | 29 +- app/Models/ItemType.php | 35 +- app/Models/PermittedUser.php | 44 +- app/Models/Queue.php | 14 +- app/Models/RequestErrorLog.php | 25 +- app/Models/Resource.php | 38 +- app/Models/ResourceAccess.php | 14 +- app/Models/ResourceItemSubtype.php | 8 +- app/Models/ResourceType.php | 51 +-- app/Models/ResourceTypeItem.php | 630 ---------------------------- app/Models/ResourceTypeItemType.php | 29 +- app/Models/Subcategory.php | 52 +-- app/Models/Summary/Category.php | 11 +- app/Models/Summary/Resource.php | 12 +- app/Models/Summary/ResourceType.php | 9 +- app/Models/Summary/Subcategory.php | 11 +- 26 files changed, 232 insertions(+), 986 deletions(-) delete mode 100644 app/Models/ResourceTypeItem.php diff --git a/app/Models/Cache.php b/app/Models/Cache.php index c994f25d..aced0eca 100644 --- a/app/Models/Cache.php +++ b/app/Models/Cache.php @@ -8,8 +8,6 @@ use Illuminate\Support\Facades\DB; /** - * Manage the our cache - * * @mixin QueryBuilder * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 diff --git a/app/Models/Category.php b/app/Models/Category.php index a126510e..f2d0c3aa 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -3,15 +3,20 @@ namespace App\Models; +use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Query\Builder as QueryBuilder; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\DB; /** - * Category model - * * @mixin QueryBuilder + * + * @property int $id + * @property int $resource_type_id + * @property string $name + * @property string $description + * * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE @@ -24,16 +29,11 @@ class Category extends Model protected $fillable = ['name', 'description', 'resource_type_id']; - public function category() + public function category(): BelongsTo { - return $this->belongsTo(Category::class, 'category_id', 'id'); + return $this->belongsTo(__CLASS__, 'category_id', 'id'); } - /** - * Return an array of the fields that can be PATCHed. - * - * @return array - */ public function patchableFields(): array { return array_keys(Config::get('api.category.validation.PATCH.fields')); @@ -120,11 +120,11 @@ public function paginatedCollection( foreach ($sort_parameters as $field => $direction) { switch ($field) { case 'created': - $collection->orderBy('category.created_at', $direction); + $collection->orderBy($this->table . '.created_at', $direction); break; default: - $collection->orderBy('category.' . $field, $direction); + $collection->orderBy($this->table . '.' . $field, $direction); break; } } @@ -138,14 +138,6 @@ public function paginatedCollection( return $collection->get()->toArray(); } - /** - * Return a single item - * - * @param integer $resource_type_id - * @param integer $category_id - * - * @return array|null - */ public function single(int $resource_type_id, int $category_id): ?array { $result = $this->join('resource_type', $this->table . '.resource_type_id', '=', 'resource_type.id')-> @@ -166,34 +158,20 @@ public function single(int $resource_type_id, int $category_id): ?array if ($result === null) { return null; - } else { - return $result->toArray(); } + + return $result->toArray(); } - /** - * Return an instance of a Category - * - * @param integer $category_id - * - * @return Category|null - */ public function instance(int $category_id): ?Category { return $this->find($category_id); } - /** - * Fetch all the categories assigned to the resource type - * - * @param integer $resource_type_id - * - * @return array - */ public function categoriesByResourceType(int $resource_type_id): array { return $this->join('resource_type', $this->table . '.resource_type_id', '=', 'resource_type.id')-> - where('resource_type.id', '=', intval($resource_type_id))-> + where('resource_type.id', '=', $resource_type_id)-> orderBy('category.name')-> select( 'category.id AS category_id', @@ -204,13 +182,6 @@ public function categoriesByResourceType(int $resource_type_id): array toArray(); } - /** - * Convert the model instance to an array for use with the transformer - * - * @param Category $category - * - * @return array - */ public function instanceToArray(Category $category): array { return [ diff --git a/app/Models/Currency.php b/app/Models/Currency.php index a9413d92..762f8d9a 100644 --- a/app/Models/Currency.php +++ b/app/Models/Currency.php @@ -8,6 +8,11 @@ /** * @mixin QueryBuilder + * + * @property int $id + * @property string $code + * @property string $name + * * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE @@ -49,11 +54,11 @@ public function paginatedCollection( foreach ($sort_parameters as $field => $direction) { switch ($field) { case 'created': - $collection->orderBy("{$this->table}.created_at", $direction); + $collection->orderBy($this->table . '.created_at', $direction); break; default: - $collection->orderBy("{$this->table}." . $field, $direction); + $collection->orderBy($this->table . '.' . $field, $direction); break; } } diff --git a/app/Models/EntityLimits.php b/app/Models/EntityLimits.php index 7c3d2b75..24b1d773 100644 --- a/app/Models/EntityLimits.php +++ b/app/Models/EntityLimits.php @@ -7,25 +7,14 @@ use Illuminate\Database\Query\Builder as QueryBuilder; /** - * Item model when fetching data by resource type - * * @mixin QueryBuilder + * * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class EntityLimits extends Model { - /** - * Work out the maximum year for the given date field in the given table. - * We default to the current year if there are no records - * - * @param integer $resource_type_id - * @param string $table - * @param string $field - * - * @return integer - */ public function maximumYearByResourceType( int $resource_type_id, string $table, @@ -40,16 +29,6 @@ public function maximumYearByResourceType( ); } - /** - * Work out the maximum year for the given date field in the given table. - * We default to the current year if there are no records - * - * @param integer $resource_type_id - * @param string $table - * @param string $field - * - * @return integer - */ public function minimumYearByResourceType( int $resource_type_id, string $table, @@ -64,17 +43,6 @@ public function minimumYearByResourceType( ); } - /** - * Work out the maximum year for the given date field in the given table. - * We default to the current year if there are no records - * - * @param integer $resource_type_id - * @param integer $resource_id - * @param string $table - * @param string $field - * - * @return integer - */ public function maximumYearByResourceTypeAndResource( int $resource_type_id, int $resource_id, @@ -91,17 +59,6 @@ public function maximumYearByResourceTypeAndResource( ); } - /** - * Work out the minimum year for the given date field in the given table. - * We default to the current year if there are no records - * - * @param integer $resource_type_id - * @param integer $resource_id - * @param string $table - * @param string $field - * - * @return integer - */ public function minimumYearByResourceTypeAndResource( int $resource_type_id, int $resource_id, diff --git a/app/Models/ErrorLog.php b/app/Models/ErrorLog.php index 64d0a8d7..e7a12e0f 100644 --- a/app/Models/ErrorLog.php +++ b/app/Models/ErrorLog.php @@ -7,9 +7,14 @@ use Illuminate\Database\Query\Builder as QueryBuilder; /** - * Error log - * * @mixin QueryBuilder + * + * @property int $id + * @property string $message + * @property string $file + * @property string $line + * @property string $trace + * * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE diff --git a/app/Models/Item.php b/app/Models/Item.php index cc7e9218..bbd34ee1 100644 --- a/app/Models/Item.php +++ b/app/Models/Item.php @@ -3,13 +3,18 @@ namespace App\Models; +use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Query\Builder as QueryBuilder; use Illuminate\Database\Eloquent\Model; /** - * Item model - * * @mixin QueryBuilder + * + * @property int $id + * @property int $resource_id + * @property int $created_by + * @property int $updated_by + * * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE @@ -20,7 +25,7 @@ class Item extends Model protected $guarded = ['id', 'created_at', 'updated_at']; - public function resource() + public function resource(): BelongsTo { return $this->belongsTo(Resource::class, 'resource_id', 'id'); } diff --git a/app/Models/ItemCategory.php b/app/Models/ItemCategory.php index 98957cd3..189ab8ff 100644 --- a/app/Models/ItemCategory.php +++ b/app/Models/ItemCategory.php @@ -5,11 +5,15 @@ use Illuminate\Database\Eloquent\Builder as QueryBuilder; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\HasOne; /** - * Item category model - * * @mixin QueryBuilder + * + * @property int $id + * @property int $item_id + * @property int $category_id + * * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE @@ -20,12 +24,12 @@ class ItemCategory extends Model protected $guarded = ['id', 'created_at', 'updated_at']; - public function category() + public function category(): HasOne { return $this->hasOne(Category::class, 'id', 'category_id'); } - public function item() + public function item(): HasOne { return $this->hasOne(Item::class, 'id', 'item_id'); } @@ -51,7 +55,7 @@ public function paginatedCollection( int $item_id, int $offset = 0, int $limit = 10 - ) + ): array { return $this->join('category', 'item_category.category_id', 'category.id')-> join('item', 'item_category.item_id', 'item.id')-> @@ -128,13 +132,6 @@ public function instance( find($item_category_id); } - /** - * Convert the model instance to an array for use with the transformer - * - * @param ItemCategory $item_category - * - * @return array - */ public function instanceToArray(ItemCategory $item_category): array { return [ diff --git a/app/Models/ItemPartialTransfer.php b/app/Models/ItemPartialTransfer.php index 87c496ca..c584e70f 100644 --- a/app/Models/ItemPartialTransfer.php +++ b/app/Models/ItemPartialTransfer.php @@ -7,9 +7,16 @@ use Illuminate\Database\Eloquent\Model; /** - * Item type model - * * @mixin QueryBuilder + * + * @property int $id + * @property int $resource_type_id + * @property int $from + * @property int $to + * @property int $item_id + * @property int $percentage + * @property int $transferred_by + * * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE @@ -66,14 +73,6 @@ public function paginatedCollection( return $collection->get()->toArray(); } - /** - * Return a single partial transfer - * - * @param integer $resource_type_id - * @param integer $item_partial_transfer_id - * - * @return array|null - */ public function single( int $resource_type_id, int $item_partial_transfer_id diff --git a/app/Models/ItemSubcategory.php b/app/Models/ItemSubcategory.php index 913ee241..0bcb87eb 100644 --- a/app/Models/ItemSubcategory.php +++ b/app/Models/ItemSubcategory.php @@ -5,11 +5,16 @@ use Illuminate\Database\Eloquent\Builder as QueryBuilder; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\HasOne; /** - * Item model - * * @mixin QueryBuilder + * + * @property int $id + * @property int $item_category_id + * @property int $sub_category_id + * * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE @@ -20,17 +25,17 @@ class ItemSubcategory extends Model protected $guarded = ['id', 'created_at', 'updated_at']; - public function sub_category() + public function sub_category(): HasOne { return $this->hasOne(Subcategory::class, 'id', 'sub_category_id'); } - public function item() + public function item(): HasOne { return $this->hasOne(Item::class, 'id', 'item_id'); } - public function item_category() + public function item_category(): BelongsTo { return $this->belongsTo(ItemCategory::class, 'item_category_id', 'id'); } @@ -145,13 +150,6 @@ public function instance( find($item_subcategory_id); } - /** - * Convert the model instance to an array for use with the transformer - * - * @param ItemSubcategory $item_sub_category - * - * @return array - */ public function instanceToArray(ItemSubcategory $item_sub_category): array { return [ diff --git a/app/Models/ItemSubtype.php b/app/Models/ItemSubtype.php index acb870fe..fcbc6f9d 100644 --- a/app/Models/ItemSubtype.php +++ b/app/Models/ItemSubtype.php @@ -8,6 +8,13 @@ /** * @mixin QueryBuilder + * + * @property int $id + * @property int $item_type_id + * @property string $name + * @property string $friendly_name + * @property string $description + * * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE @@ -54,11 +61,11 @@ public function paginatedCollection( foreach ($sort_parameters as $field => $direction) { switch ($field) { case 'created': - $collection->orderBy("{$this->table}.created_at", $direction); + $collection->orderBy($this->table . '.created_at', $direction); break; default: - $collection->orderBy("{$this->table}." . $field, $direction); + $collection->orderBy($this->table . '.' . $field, $direction); break; } } diff --git a/app/Models/ItemTransfer.php b/app/Models/ItemTransfer.php index 019f5108..d9cf9cee 100644 --- a/app/Models/ItemTransfer.php +++ b/app/Models/ItemTransfer.php @@ -7,9 +7,15 @@ use Illuminate\Database\Eloquent\Model; /** - * Item type model - * * @mixin QueryBuilder + * + * @propery int $id + * @propery int $resource_type_id + * @propery int $from + * @propery int $to + * @propery int $item_id + * @propery int $transferred_by + * * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE @@ -62,14 +68,6 @@ public function paginatedCollection( return $collection->get()->toArray(); } - /** - * Return a single partial transfer - * - * @param integer $resource_type_id - * @param integer $item_partial_transfer_id - * - * @return array|null - */ public function single( int $resource_type_id, int $item_partial_transfer_id @@ -97,9 +95,9 @@ public function single( if ($result === null) { return null; - } else { - return $result->toArray(); } + + return $result->toArray(); } public function total( @@ -130,12 +128,7 @@ public function total( return $collection->count(); } - /** - * @param int $item_id - * - * @return mixed - */ - public function deleteTransfers(int $item_id) + public function deleteTransfers(int $item_id): ?bool { return $this->where($this->table . '.item_id', '=', $item_id)->delete(); } diff --git a/app/Models/ItemType.php b/app/Models/ItemType.php index 14e63d58..ffb6158e 100644 --- a/app/Models/ItemType.php +++ b/app/Models/ItemType.php @@ -7,9 +7,14 @@ use Illuminate\Database\Eloquent\Model; /** - * Item type model - * * @mixin QueryBuilder + * + * @property int $id + * @property string $name + * @property string $friendly_name + * @property string $description + * @property string $example + * * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE @@ -20,11 +25,6 @@ class ItemType extends Model protected $guarded = ['id', 'name', 'description', 'example', 'created_at', 'updated_at']; - /** - * Fetch the item types, id, name and description only - * - * @return array - */ public function minimisedCollection(): array { return $this->select( @@ -36,16 +36,6 @@ public function minimisedCollection(): array toArray(); } - /** - * Return the paginated collection - * - * @param integer $offset Paging offset - * @param integer $limit Paging limit - * @param array $search_parameters - * @param array $sort_parameters - * - * @return array - */ public function paginatedCollection( int $offset = 0, int $limit = 10, @@ -68,11 +58,11 @@ public function paginatedCollection( foreach ($sort_parameters as $field => $direction) { switch ($field) { case 'created': - $collection->orderBy('item_type.created_at', $direction); + $collection->orderBy($this->table . '.created_at', $direction); break; default: - $collection->orderBy('item_type.' . $field, $direction); + $collection->orderBy($this->table . '.' . $field, $direction); break; } } @@ -110,13 +100,6 @@ public function single(int $item_type_id): ?array return $result[0]; } - /** - * Return the total number of item types - * - * @param array $search_parameters = [] - * - * @return integer - */ public function totalCount(array $search_parameters = []): int { $collection = $this->select("item_type.id"); diff --git a/app/Models/PermittedUser.php b/app/Models/PermittedUser.php index fd4eb0da..c713199a 100644 --- a/app/Models/PermittedUser.php +++ b/app/Models/PermittedUser.php @@ -7,9 +7,13 @@ use Illuminate\Database\Query\Builder as QueryBuilder; /** - * Error log - * * @mixin QueryBuilder + * + * @property int $id + * @property int $resource_type_id + * @property int $user_id + * @property int $added_by + * * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE @@ -20,14 +24,6 @@ class PermittedUser extends Model protected $guarded = ['id']; - /** - * Return an instance of a permitted user - * - * @param integer $resource_type_id - * @param integer $user_id - * - * @return ResourceAccess|null - */ public function instance(int $resource_type_id, int $user_id): ?PermittedUser { return $this->where('resource_type_id', '=', $resource_type_id)-> @@ -35,14 +31,6 @@ public function instance(int $resource_type_id, int $user_id): ?PermittedUser first(); } - /** - * Return the total number of permitted users for the resource type - * - * @param integer $resource_type_id - * @param array $search_parameters - * - * @return integer - */ public function totalCount( int $resource_type_id, array $search_parameters = [] @@ -57,17 +45,6 @@ public function totalCount( return $collection->count('permitted_user.id'); } - /** - * Return the permitted users based on the given conditions - * - * @param integer $resource_type_id - * @param integer $offset - * @param integer $limit - * @param array $search_parameters - * @param array $sort_parameters - * - * @return array - */ public function paginatedCollection( int $resource_type_id, int $offset = 0, @@ -91,7 +68,7 @@ public function paginatedCollection( foreach ($sort_parameters as $field => $direction) { switch ($field) { case 'created': - $collection->orderBy('permitted_user.created_at', $direction); + $collection->orderBy($this->table . '.created_at', $direction); break; default: @@ -100,9 +77,12 @@ public function paginatedCollection( } } } else { - $collection->orderBy('permitted_user.created_at', 'desc'); + $collection->orderBy($this->table . '.created_at', 'desc'); } - return $collection->offset($offset)->limit($limit)->get()->toArray(); + return $collection->offset($offset) + ->limit($limit) + ->get() + ->toArray(); } } diff --git a/app/Models/Queue.php b/app/Models/Queue.php index 7895fd40..73d06b61 100644 --- a/app/Models/Queue.php +++ b/app/Models/Queue.php @@ -8,6 +8,15 @@ /** * @mixin QueryBuilder + * + * @property int $id + * @property string $queue + * @property string $payload + * @property int $attempts + * @property int $reserved_at + * @property int $available_at + * @property int $created_at + * * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE @@ -59,8 +68,7 @@ public function single(int $currency_id): ?array public function totalCount(): int { - $collection = $this->select("{$this->table}.id"); - - return $collection->count(); + return $this->select($this->table . '.id') + ->count(); } } diff --git a/app/Models/RequestErrorLog.php b/app/Models/RequestErrorLog.php index c0e93d83..d4bbdb02 100644 --- a/app/Models/RequestErrorLog.php +++ b/app/Models/RequestErrorLog.php @@ -7,9 +7,16 @@ use Illuminate\Database\Query\Builder as QueryBuilder; /** - * Request error log - * * @mixin QueryBuilder + * + * @property int $id + * @property string $method + * @property string $source + * @property string $debug + * @property int $expected_status_code + * @property int $returned_status_code + * @property string $request_uri + * * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE @@ -20,7 +27,7 @@ class RequestErrorLog extends Model protected $guarded = ['id', 'created_at', 'updated_at']; - public function totalCount() + public function totalCount(): int { return $this->count(); } @@ -38,11 +45,11 @@ public function paginatedCollection( 'request_error_log.source AS request_error_log_source', 'request_error_log.created_at AS request_error_log_created_at', 'request_error_log.debug AS request_error_log_debug' - )-> - orderByDesc('created_at')-> - offset($offset)-> - limit($limit)-> - get()-> - toArray(); + ) + ->orderByDesc('created_at') + ->offset($offset) + ->limit($limit) + ->get() + ->toArray(); } } diff --git a/app/Models/Resource.php b/app/Models/Resource.php index 7ae9e098..bb75e2b2 100644 --- a/app/Models/Resource.php +++ b/app/Models/Resource.php @@ -4,13 +4,21 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Eloquent\Relations\HasOneThrough; use Illuminate\Database\Query\Builder as QueryBuilder; use Illuminate\Support\Facades\Config; /** - * Resource model - * * @mixin QueryBuilder + * + * @property int $id + * @property int $resource_type_id + * @property string $name + * @property string $description + * @property string $data + * * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE @@ -21,7 +29,7 @@ class Resource extends Model protected $guarded = ['id', 'created_at', 'updated_at']; - public function item_subtype() + public function item_subtype(): HasOneThrough { return $this->hasOneThrough( ItemSubtype::class, @@ -33,11 +41,6 @@ public function item_subtype() ); } - /** - * Return an array of the fields that can be PATCHed. - * - * @return array - */ public function patchableFields(): array { return array_keys(Config::get('api.resource.validation.PATCH.fields')); @@ -64,12 +67,12 @@ public function totalCount( return $collection->count(); } - public function items() + public function items(): HasMany { return $this->hasMany(Item::class, 'resource_id', 'id'); } - public function resource_type() + public function resource_type(): BelongsTo { return $this->belongsTo(ResourceType::class, 'resource_type_id', 'id'); } @@ -120,16 +123,16 @@ public function paginatedCollection( foreach ($sort_parameters as $field => $direction) { switch ($field) { case 'created': - $collection->orderBy('resource.created_at', $direction); + $collection->orderBy($this->table . '.created_at', $direction); break; default: - $collection->orderBy('resource.' . $field, $direction); + $collection->orderBy($this->table . '.' . $field, $direction); break; } } } else { - $collection->orderBy('resource.created_at', 'desc'); + $collection->orderBy($this->table . '.created_at', 'desc'); } return $collection->offset($offset)-> @@ -167,15 +170,6 @@ public function single(int $resource_type_id, int $resource_id): ?array return $result[0]; } - /** - * Return the list of resources for the requested resource type and - * optionally exclude the provided resource id - * - * @param integer $resource_type_id - * @param integer|null $exclude_id - * - * @return array - */ public function resourcesForResourceType( int $resource_type_id, int $exclude_id = null diff --git a/app/Models/ResourceAccess.php b/app/Models/ResourceAccess.php index f816a496..8db461d8 100644 --- a/app/Models/ResourceAccess.php +++ b/app/Models/ResourceAccess.php @@ -8,6 +8,12 @@ /** * @mixin QueryBuilder + * + * @property int $id + * @property int $resource_type_id + * @property int $user_id + * @property int $added_by + * * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE @@ -18,14 +24,6 @@ class ResourceAccess extends Model protected $guarded = ['id']; - /** - * Return an instance of a permitted user - * - * @param integer $resource_type_id - * @param integer $user_id - * - * @return ResourceAccess|null - */ public function instance(int $resource_type_id, int $user_id): ?ResourceAccess { return $this->where('resource_type_id', '=', $resource_type_id)-> diff --git a/app/Models/ResourceItemSubtype.php b/app/Models/ResourceItemSubtype.php index c6bcb81b..13780a06 100644 --- a/app/Models/ResourceItemSubtype.php +++ b/app/Models/ResourceItemSubtype.php @@ -8,6 +8,11 @@ /** * @mixin QueryBuilder + * + * @property int $id + * @property int $resource_id + * @property int $item_subtype_id + * * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE @@ -20,8 +25,7 @@ class ResourceItemSubtype extends Model public function instance(int $resource_id): Model { - return $this - ->where('resource_id', '=', $resource_id) + return $this->where('resource_id', '=', $resource_id) ->first(); } } diff --git a/app/Models/ResourceType.php b/app/Models/ResourceType.php index 4c6b48ad..3155755d 100644 --- a/app/Models/ResourceType.php +++ b/app/Models/ResourceType.php @@ -4,13 +4,20 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Eloquent\Relations\HasOneThrough; use Illuminate\Database\Query\Builder as QueryBuilder; use Illuminate\Support\Facades\Config; /** - * Resource type model - * * @mixin QueryBuilder + * + * @property int $id + * @property int $public + * @property string $name + * @property string $description + * @property string $data + * * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE @@ -21,7 +28,7 @@ class ResourceType extends Model protected $guarded = ['id']; - public function item_type() + public function item_type(): HasOneThrough { return $this->hasOneThrough( ItemType::class, @@ -33,11 +40,6 @@ public function item_type() ); } - /** - * Return an array of the fields that can be PATCHed. - * - * @return array - */ public function patchableFields(): array { return array_keys(Config::get('api.resource-type.validation.PATCH.fields')); @@ -47,10 +49,10 @@ public function publicResourceTypes(): array { $public = []; - $results = $this->where('public', '=', 1)-> - select('id')-> - get()-> - toArray(); + $results = $this->where('public', '=', 1) + ->select('id') + ->get() + ->toArray(); foreach ($results as $row) { $public[] = (int) $row['id']; @@ -76,7 +78,7 @@ public function totalCount( return $collection->count(); } - public function resources() + public function resources(): HasMany { return $this->hasMany(Resource::class, 'resource_type_id', 'id'); } @@ -139,16 +141,16 @@ public function paginatedCollection( foreach ($sort_parameters as $field => $direction) { switch ($field) { case 'created': - $collection->orderBy('resource_type.created_at', $direction); + $collection->orderBy($this->table . '.created_at', $direction); break; default: - $collection->orderBy('resource_type.' . $field, $direction); + $collection->orderBy($this->table . '.' . $field, $direction); break; } } } else { - $collection->orderByDesc('resource_type.created_at'); + $collection->orderByDesc($this->table . '.created_at'); } $collection->offset($offset); @@ -194,8 +196,7 @@ public function single( $viewable_resource_types ); - $result = $result - ->where($this->table . '.id', '=', $resource_type_id) + $result = $result->where($this->table . '.id', '=', $resource_type_id) ->get() ->toArray(); @@ -206,13 +207,6 @@ public function single( return $result[0]; } - /** - * Convert the model instance to an array for use with the transformer - * - * @param ResourceType - * - * @return array - */ public function instanceToArray(ResourceType $resource_type): array { return [ @@ -230,13 +224,6 @@ public function instanceToArray(ResourceType $resource_type): array ]; } - /** - * Return an instance of a resource type - * - * @param integer $resource_type_id - * - * @return ResourceType|null - */ public function instance(int $resource_type_id): ?ResourceType { return $this->find($resource_type_id); diff --git a/app/Models/ResourceTypeItem.php b/app/Models/ResourceTypeItem.php deleted file mode 100644 index a13e5d51..00000000 --- a/app/Models/ResourceTypeItem.php +++ /dev/null @@ -1,630 +0,0 @@ - - * @copyright Dean Blackborough 2018-2022 - * @license https://github.com/costs-to-expect/api/blob/master/LICENSE - */ -class ResourceTypeItem extends Model -{ - protected $table = 'item'; - - protected $guarded = ['id', 'actualised_total', 'created_at', 'updated_at']; - - /** - * Return the total number of items for the requested resource type - * - * @param integer $resource_type_id - * @param array $parameters_collection - * @param array $search_conditions - * - * @return integer - */ - public function totalCount( - int $resource_type_id, - array $parameters_collection = [], - array $search_conditions = [] - ): int - { - $collection = $this->join('item_type_allocated_expense', 'item.id', 'item_type_allocated_expense.item_id')-> - join('resource', 'item.resource_id', 'resource.id')-> - join('resource_type', 'resource.resource_type_id', 'resource_type.id')-> - where('resource_type.id', '=', $resource_type_id); - - if (array_key_exists('year', $parameters_collection) === true && - $parameters_collection['year'] !== null) { - $collection->where(DB::raw('YEAR(item_type_allocated_expense.effective_date)'), '=', $parameters_collection['year']); - } - - if (array_key_exists('month', $parameters_collection) === true && - $parameters_collection['month'] !== null) { - $collection->where(DB::raw('MONTH(item_type_allocated_expense.effective_date)'), '=', $parameters_collection['month']); - } - - if (array_key_exists('category', $parameters_collection) === true && - $parameters_collection['category'] !== null) { - $collection->join("item_category", "item_category.item_id", "item.id"); - $collection->where('item_category.category_id', '=', $parameters_collection['category']); - - if ( - array_key_exists('subcategory', $parameters_collection) === true && - $parameters_collection['subcategory'] !== null - ) { - $collection->join('item_sub_category', 'item_category.id', 'item_sub_category.item_category_id')-> - join('sub_category', 'item_sub_category.sub_category_id', 'sub_category.id')-> - where('item_sub_category.sub_category_id', '=', $parameters_collection['subcategory']); - } - } - - if (count($search_conditions) > 0) { - foreach ($search_conditions as $field => $search_term) { - $collection->where('item_type_allocated_expense.' . $field, 'LIKE', '%' . $search_term . '%'); - } - } - - $collection = Clause::applyExcludeFutureUnpublished($collection, $parameters_collection); - - return $collection->count(); - } - - /** - * Return the pagination collection for all the items assigned to the - * resources for a resource group - * - * @param int $resource_type_id - * @param int $offset - * @param int $limit - * @param array $parameters_collection - * @param array $sort_parameters - * @param array $search_conditions - * - * @return array - */ - public function paginatedCollection( - int $resource_type_id, - int $offset = 0, - int $limit = 10, - array $parameters_collection = [], - array $sort_parameters = [], - array $search_conditions = [] - ): array - { - $select_fields = [ - 'resource.id AS resource_id', - 'resource.name AS resource_name', - 'resource.description AS resource_description', - 'item.id AS item_id', - 'item_type_allocated_expense.name AS item_name', - 'item_type_allocated_expense.description AS item_description', - 'item_type_allocated_expense.effective_date AS item_effective_date', - 'item_type_allocated_expense.total AS item_total', - 'item_type_allocated_expense.percentage AS item_percentage', - 'item_type_allocated_expense.actualised_total AS item_actualised_total', - 'item.created_at AS item_created_at' - ]; - - $collection = $this->join('item_type_allocated_expense', 'item.id', 'item_type_allocated_expense.item_id')-> - join('resource', 'item.resource_id', 'resource.id')-> - join('resource_type', 'resource.resource_type_id', 'resource_type.id')-> - where('resource_type.id', '=', $resource_type_id); - - $category_join = false; // Check to see if join has taken place - $subcategory_join = false; // Check to see if join has taken place - - if ( - array_key_exists('include-categories', $parameters_collection) === true && - Boolean::convertedValue($parameters_collection['include-categories']) === true - ) { - $collection->join('item_category', 'item.id', 'item_category.item_id')-> - join('category', 'item_category.category_id', 'category.id'); - - $category_join = true; - - $select_fields[] = 'category.id AS category_id'; - $select_fields[] = 'category.name AS category_name'; - $select_fields[] = 'category.description AS category_description'; - - if (array_key_exists('category', $parameters_collection) === true && - $parameters_collection['category'] !== null) { - $collection->where('item_category.category_id', '=', $parameters_collection['category']); - } - - if ( - array_key_exists('include-subcategories', $parameters_collection) === true && - Boolean::convertedValue($parameters_collection['include-subcategories']) === true - ) { - $collection->join('item_sub_category', 'item_category.id', 'item_sub_category.item_category_id')-> - join('sub_category', 'item_sub_category.sub_category_id', 'sub_category.id'); - - $subcategory_join = true; - - $select_fields[] = 'sub_category.id AS subcategory_id'; - $select_fields[] = 'sub_category.name AS subcategory_name'; - $select_fields[] = 'sub_category.description AS subcategory_description'; - - if (array_key_exists('subcategory', $parameters_collection) === true && - $parameters_collection['subcategory'] !== null) { - $collection->where('item_sub_category.sub_category_id', '=', $parameters_collection['subcategory']); - } - } - } - - if (array_key_exists('year', $parameters_collection) === true && - $parameters_collection['year'] !== null) { - $collection->where(DB::raw('YEAR(item_type_allocated_expense.effective_date)'), '=', $parameters_collection['year']); - } - - if (array_key_exists('month', $parameters_collection) === true && - $parameters_collection['month'] !== null) { - $collection->where(DB::raw('MONTH(item_type_allocated_expense.effective_date)'), '=', $parameters_collection['month']); - } - - if (array_key_exists('category', $parameters_collection) === true && - $parameters_collection['category'] !== null && - $category_join === false) { - - $collection->join('item_category', 'item.id', 'item_category.item_id')-> - join('category', 'item_category.category_id', 'category.id')-> - where('item_category.category_id', '=', $parameters_collection['category']); - - if (array_key_exists('subcategory', $parameters_collection) === true && - $parameters_collection['subcategory'] !== null && - $subcategory_join === false) { - - $collection->join('item_sub_category', 'item_category.id', 'item_sub_category.item_category_id')-> - join('sub_category', 'item_sub_category.sub_category_id', 'sub_category.id')-> - where('item_sub_category.sub_category_id', '=', $parameters_collection['subcategory']); - } - } - - if (count($search_conditions) > 0) { - foreach ($search_conditions as $field => $search_term) { - $collection->where('item_type_allocated_expense.' . $field, 'LIKE', '%' . $search_term . '%'); - } - } - - $collection = Clause::applyExcludeFutureUnpublished($collection, $parameters_collection); - - if (count($sort_parameters) > 0) { - foreach ($sort_parameters as $field => $direction) { - switch ($field) { - case 'created': - $collection->orderBy('item.created_at', $direction); - break; - - case 'actualised_total': - case 'description': - case 'effective_date': - case 'name': - case 'total': - $collection->orderBy('item_type_allocated_expense.' . $field, $direction); - break; - - default: - $collection->orderBy('item.' . $field, $direction); - break; - } - } - } else { - $collection->orderBy('item_type_allocated_expense.effective_date', 'desc'); - $collection->orderBy('item.created_at', 'desc'); - } - - $collection->offset($offset); - $collection->limit($limit); - $collection->select($select_fields); - - return $collection->get()->toArray(); - } - - /** - * Return the summary for all items for the resources in the requested resource type - * - * @param int $resource_type_id - * @param boolean $include_unpublished = false - * - * @return array - */ - public function summary(int $resource_type_id, bool $include_unpublished): array - { - $collection = $this->selectRaw('sum(item_type_allocated_expense.actualised_total) AS actualised_total')-> - join('item_type_allocated_expense', 'item.id', 'item_type_allocated_expense.item_id')-> - join('resource', 'item.resource_id', 'resource.id')-> - join('resource_type', 'resource.resource_type_id', 'resource_type.id')-> - where('resource_type.id', '=', $resource_type_id); - - if ($include_unpublished === false) { - $collection = Clause::applyExcludeFutureUnpublished($collection, []); - } - - return $collection-> - get()-> - toArray(); - } - - /** - * Return the summary for all items for the resources in the requested resource - * type grouped by resource - * - * @param int $resource_type_id - * @param boolean $include_unpublished - * - * @return array - */ - public function resourcesSummary(int $resource_type_id, bool $include_unpublished): array - { - $collection = $this->selectRaw(' - resource.id AS id, - resource.name AS `name`, - SUM(item_type_allocated_expense.actualised_total) AS total' - )-> - join('item_type_allocated_expense', 'item.id', 'item_type_allocated_expense.item_id')-> - join('resource', 'item.resource_id', 'resource.id')-> - join('resource_type', 'resource.resource_type_id', 'resource_type.id')-> - where('resource_type.id', '=', $resource_type_id); - - if ($include_unpublished === false) { - $collection = Clause::applyExcludeFutureUnpublished($collection, []); - } - - return $collection->groupBy('resource.id')-> - orderBy('name')-> - get()-> - toArray(); - } - - /** - * Return the summary for all items for the resources in the requested resource - * type grouped by year - * - * @param int $resource_type_id - * @param boolean $include_unpublished - - * @return array - */ - public function yearsSummary(int $resource_type_id, bool $include_unpublished): array - { - $collection = $this->selectRaw(" - YEAR(item_type_allocated_expense.effective_date) as year, - SUM(item_type_allocated_expense.actualised_total) AS total" - )-> - join('item_type_allocated_expense', 'item.id', 'item_type_allocated_expense.item_id')-> - join("resource", "resource.id", "item.resource_id")-> - join("resource_type", "resource_type.id", "resource.resource_type_id")-> - where("resource_type.id", "=", $resource_type_id); - - if ($include_unpublished === false) { - $collection = Clause::applyExcludeFutureUnpublished($collection, []); - } - - return $collection->groupBy("year")-> - orderBy("year")-> - get()-> - toArray(); - } - - /** - * Return the summary for all items for the resources in the requested resource - * type grouped by month for the requested year - * - * @param integer $resource_type_id - * @param integer $year - * @param boolean $include_unpublished - * - * @return array - */ - public function monthsSummary(int $resource_type_id, int $year, bool $include_unpublished): array - { - $collection = $this->selectRaw(" - MONTH(item_type_allocated_expense.effective_date) as month, - SUM(item_type_allocated_expense.actualised_total) AS total" - )-> - join('item_type_allocated_expense', 'item.id', 'item_type_allocated_expense.item_id')-> - join("resource", "resource.id", "item.resource_id")-> - join("resource_type", "resource_type.id", "resource.resource_type_id")-> - where("resource_type.id", "=", $resource_type_id)-> - where(DB::raw('YEAR(item_type_allocated_expense.effective_date)'), '=', $year); - - if ($include_unpublished === false) { - $collection = Clause::applyExcludeFutureUnpublished($collection, []); - } - - return $collection->groupBy("month")-> - orderBy("month")-> - get()-> - toArray(); - } - - /** - * Return the summary for all items for the resources in the requested resource - * type for a specific year and month - * - * @param integer $resource_type_id - * @param integer $year - * @param integer $month - * @param boolean $include_unpublished - * - * @return array - */ - public function monthSummary( - int $resource_type_id, - int $year, - int $month, - bool $include_unpublished - ): array - { - $collection = $this->selectRaw(" - MONTH(item_type_allocated_expense.effective_date) as month, - SUM(item_type_allocated_expense.actualised_total) AS total" - )-> - join('item_type_allocated_expense', 'item.id', 'item_type_allocated_expense.item_id')-> - join("resource", "resource.id", "item.resource_id")-> - join("resource_type", "resource_type.id", "resource.resource_type_id")-> - where("resource_type.id", "=", $resource_type_id)-> - where(DB::raw('YEAR(item_type_allocated_expense.effective_date)'), '=', $year)-> - where(DB::raw('MONTH(item_type_allocated_expense.effective_date)'), '=', $month); - - if ($include_unpublished === false) { - $collection = Clause::applyExcludeFutureUnpublished($collection, []); - } - - return $collection->groupBy("month")-> - orderBy("month")-> - get()-> - toArray(); - } - - /** - * Return the summary for all items for the resources in the requested resource - * type for a specific year - * - * @param integer $resource_type_id - * @param integer $year - * @param boolean $include_unpublished - * - * @return array - */ - public function yearSummary(int $resource_type_id, int $year, bool $include_unpublished): array - { - $collection = $this->selectRaw(" - YEAR(item_type_allocated_expense.effective_date) as year, - SUM(item_type_allocated_expense.actualised_total) AS total" - )-> - join('item_type_allocated_expense', 'item.id', 'item_type_allocated_expense.item_id')-> - join("resource", "resource.id", "item.resource_id")-> - join("resource_type", "resource_type.id", "resource.resource_type_id")-> - where("resource_type.id", "=", $resource_type_id)-> - where(DB::raw('YEAR(item_type_allocated_expense.effective_date)'), '=', $year); - - if ($include_unpublished === false) { - $collection = Clause::applyExcludeFutureUnpublished($collection, []); - } - - return $collection->groupBy("year")-> - orderBy("year")-> - get()-> - toArray(); - } - - /** - * Return the summary for all items for the resources in the requested resource - * type grouped by category - * - * @param integer $resource_type_id - * @param boolean $include_unpublished - * - * @return array - */ - public function categoriesSummary( - int $resource_type_id, - bool $include_unpublished = false - ): array - { - $collection = $this->selectRaw(' - category.id, - category.name AS name, - category.description AS description, - SUM(item_type_allocated_expense.actualised_total) AS total')-> - join('item_type_allocated_expense', 'item.id', 'item_type_allocated_expense.item_id')-> - join("resource", "resource.id", "item.resource_id")-> - join("resource_type", "resource_type.id", "resource.resource_type_id")-> - join("item_category", "item_category.item_id", "item.id")-> - join("category", "category.id", "item_category.category_id")-> - where("category.resource_type_id", "=", $resource_type_id)-> - where("resource_type.id", "=", $resource_type_id); - - if ($include_unpublished === false) { - $collection = Clause::applyExcludeFutureUnpublished($collection, []); - } - - return $collection->groupBy("category.id")-> - orderBy("name")-> - get()-> - toArray(); - } - - /** - * Return the summary for all items for the resources in the requested resource - * type for the requested category - * - * @param integer $resource_type_id - * @param integer $category_id - * @param boolean $include_unpublished - * - * @return array - */ - public function categorySummary( - int $resource_type_id, - int $category_id, - bool $include_unpublished = false - ): array - { - $collection = $this->selectRaw(' - category.id, - category.name AS name, - category.description, - SUM(item_type_allocated_expense.actualised_total) AS total')-> - join('item_type_allocated_expense', 'item.id', 'item_type_allocated_expense.item_id')-> - join("resource", "resource.id", "item.resource_id")-> - join("resource_type", "resource_type.id", "resource.resource_type_id")-> - join("item_category", "item_category.item_id", "item.id")-> - join("category", "category.id", "item_category.category_id")-> - where("category.resource_type_id", "=", $resource_type_id)-> - where("resource_type.id", "=", $resource_type_id)-> - where("category.id", '=', $category_id); - - if ($include_unpublished === false) { - $collection = Clause::applyExcludeFutureUnpublished($collection, []); - } - - return $collection->groupBy("category.id")-> - orderBy("name")-> - get()-> - toArray(); - } - - public function filteredSummary( - int $resource_type_id, - int $category_id = null, - int $subcategory_id = null, - int $year = null, - int $month = null, - array $search_parameters = [], - bool $include_unpublished = false - ): array - { - $collection = $this-> - selectRaw('SUM(item_type_allocated_expense.actualised_total) AS total')-> - join('item_type_allocated_expense', 'item.id', 'item_type_allocated_expense.item_id')-> - join("resource", "resource.id", "item.resource_id")-> - join("resource_type", "resource_type.id", "resource.resource_type_id")-> - join("item_category", "item_category.item_id", "item.id")-> - join("item_sub_category", "item_sub_category.item_category_id", "item_category.id")-> - join("category", "category.id", "item_category.category_id")-> - join("sub_category", "sub_category.id", "item_sub_category.sub_category_id")-> - where("resource_type.id", "=", $resource_type_id); - - if ($category_id !== null) { - $collection->where("category.id", "=", $category_id); - } - if ($subcategory_id !== null) { - $collection->where("sub_category.id", "=", $subcategory_id); - } - if ($year !== null) { - $collection->whereRaw(DB::raw("YEAR(item_type_allocated_expense.effective_date) = {$year}")); - } - if ($month !== null) { - $collection->whereRaw(DB::raw("MONTH(item_type_allocated_expense.effective_date) = {$month}")); - } - if (count($search_parameters) > 0) { - foreach ($search_parameters as $field => $search_term) { - $collection->where('item_type_allocated_expense.' . $field, 'LIKE', '%' . $search_term . '%'); - } - } - - if ($include_unpublished === false) { - $collection = Clause::applyExcludeFutureUnpublished($collection, []); - } - - return $collection->get()-> - toArray(); - } - - /** - * Return the summary for all items for the resources in the requested resource - * type and category grouped by subcategory - * - * @param int $resource_type_id - * @param int $category_id - * @param boolean $include_unpublished - * - * @return array - */ - public function subcategoriesSummary( - int $resource_type_id, - int $category_id, - bool $include_unpublished = false - ): array - { - $collection = $this->selectRaw(' - sub_category.id, - sub_category.name AS name, - sub_category.description AS description, - SUM(item_type_allocated_expense.actualised_total) AS total')-> - join('item_type_allocated_expense', 'item.id', 'item_type_allocated_expense.item_id')-> - join("resource", "resource.id", "item.resource_id")-> - join("resource_type", "resource_type.id", "resource.resource_type_id")-> - join("item_category", "item_category.item_id", "item.id")-> - join("item_sub_category", "item_sub_category.item_category_id", "item_category.id")-> - join("category", "category.id", "item_category.category_id")-> - join("sub_category", "sub_category.id", "item_sub_category.sub_category_id")-> - where("category.resource_type_id", "=", $resource_type_id)-> - where("resource_type.id", "=", $resource_type_id)-> - where("category.id", "=", $category_id); - - if ($include_unpublished === false) { - $collection = Clause::applyExcludeFutureUnpublished($collection, []); - } - - return $collection->groupBy("sub_category.id")-> - orderBy("name")-> - get()-> - toArray(); - } - - /** - * Return the summary for all items for the resources in the requested resource - * type and category and subcategory - * - * @param int $resource_type_id - * @param int $category_id - * @param int $subcategory_id - * @param boolean $include_unpublished - * - * @return array - */ - public function subcategorySummary( - int $resource_type_id, - int $category_id, - int $subcategory_id, - bool $include_unpublished = false - ): array - { - $collection = $this->selectRaw(' - sub_category.id, - sub_category.name AS name, - sub_category.description AS description, - SUM(item_type_allocated_expense.actualised_total) AS total')-> - join('item_type_allocated_expense', 'item.id', 'item_type_allocated_expense.item_id')-> - join("resource", "resource.id", "item.resource_id")-> - join("resource_type", "resource_type.id", "resource.resource_type_id")-> - join("item_category", "item_category.item_id", "item.id")-> - join("item_sub_category", "item_sub_category.item_category_id", "item_category.id")-> - join("category", "category.id", "item_category.category_id")-> - join("sub_category", "sub_category.id", "item_sub_category.sub_category_id")-> - where("category.resource_type_id", "=", $resource_type_id)-> - where("resource_type.id", "=", $resource_type_id)-> - where("category.id", "=", $category_id)-> - where('sub_category.id', '=', $subcategory_id); - - if ($include_unpublished === false) { - $collection = Clause::applyExcludeFutureUnpublished($collection, []); - } - - return $collection->groupBy("sub_category.id")-> - orderBy("name")-> - get()-> - toArray(); - } -} diff --git a/app/Models/ResourceTypeItemType.php b/app/Models/ResourceTypeItemType.php index feab4e05..146c9465 100644 --- a/app/Models/ResourceTypeItemType.php +++ b/app/Models/ResourceTypeItemType.php @@ -7,9 +7,12 @@ use Illuminate\Database\Eloquent\Model; /** - * Resource type item type model - * * @mixin QueryBuilder + * + * @property int $id + * @property int $resource_type_id + * @property int $item_type_id + * * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE @@ -20,13 +23,6 @@ class ResourceTypeItemType extends Model protected $guarded = ['id', 'created_at', 'updated_at']; - /** - * Fetch the item type assigned to the requested resource type - * - * @param integer $resource_type_id - * - * @return string|null - */ public function itemType(int $resource_type_id): ?string { $collection = $this->join( @@ -38,21 +34,14 @@ public function itemType(int $resource_type_id): ?string if ($collection !== null) { return $collection->toArray()['name']; - } else { - return null; } + + return null; } - /** - * Return an instance of the resource type item type - * - * @param integer $resource_type_id - * - * @return ResourceAccess|null - */ public function instance(int $resource_type_id): ?ResourceTypeItemType { - return $this->where('resource_type_id', '=', $resource_type_id)-> - first(); + return $this->where('resource_type_id', '=', $resource_type_id) + ->first(); } } diff --git a/app/Models/Subcategory.php b/app/Models/Subcategory.php index d1a0df22..c9d938dd 100644 --- a/app/Models/Subcategory.php +++ b/app/Models/Subcategory.php @@ -3,14 +3,19 @@ namespace App\Models; +use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Query\Builder as QueryBuilder; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Config; /** - * Sub category model - * * @mixin QueryBuilder + * + * @property int $id + * @property int $category_id + * @property string $name + * @property string $description + * * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE @@ -21,53 +26,31 @@ class Subcategory extends Model protected $guarded = ['id', 'created_at', 'updated_at']; - public function category() + public function category(): BelongsTo { return $this->belongsTo(Category::class, 'category_id', 'id'); } - /** - * Return an array of the fields that can be PATCHed. - * - * @return array - */ public function patchableFields(): array { return array_keys(Config::get('api.subcategory.validation.PATCH.fields')); } - /** - * @param integer $resource_type_id - * @param integer $category_id - * @param array $search_parameters - * - * @return integer - */ public function totalCount( int $resource_type_id, int $category_id, array $search_parameters = [] ): int { - $collection = $this->join('category', 'sub_category.category_id', 'category.id')-> - where('sub_category.category_id', '=', $category_id)-> - where('category.resource_type_id', '=', $resource_type_id); + $collection = $this->join('category', 'sub_category.category_id', 'category.id') + ->where('sub_category.category_id', '=', $category_id) + ->where('category.resource_type_id', '=', $resource_type_id); $collection = Clause::applySearch($collection, $this->table, $search_parameters); return $collection->count(); } - /** - * @param integer $resource_type_id - * @param integer $category_id - * @param integer $offset - * @param integer $limit - * @param array $search_parameters - * @param array $sort_parameters - * - * @return array - */ public function paginatedCollection( int $resource_type_id, int $category_id, @@ -111,16 +94,16 @@ public function paginatedCollection( foreach ($sort_parameters as $field => $direction) { switch ($field) { case 'created': - $collection->orderBy('sub_category.created_at', $direction); + $collection->orderBy($this->table . '.created_at', $direction); break; default: - $collection->orderBy('sub_category.' . $field, $direction); + $collection->orderBy($this->table . '.' . $field, $direction); break; } } } else { - $collection->orderBy('sub_category.name', 'asc'); + $collection->orderBy($this->table . '.name', 'asc'); } $collection->offset($offset)-> @@ -170,13 +153,6 @@ public function instance( find($subcategory_id); } - /** - * Convert the model instance to an array for use with the transformer - * - * @param Subcategory $subcategory - * - * @return array - */ public function instanceToArray(Subcategory $subcategory): array { return [ diff --git a/app/Models/Summary/Category.php b/app/Models/Summary/Category.php index ca7062de..7b653961 100644 --- a/app/Models/Summary/Category.php +++ b/app/Models/Summary/Category.php @@ -8,9 +8,13 @@ use Illuminate\Database\Eloquent\Model; /** - * Category model - * * @mixin QueryBuilder + * + * @property int $id + * @property int $resource_type_id + * @property string $name + * @property string $description + * * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE @@ -54,8 +58,7 @@ public function total( $collection = Clause::applySearch($collection, $this->table, $search_parameters); - return $collection - ->get() + return $collection->get() ->toArray(); } } diff --git a/app/Models/Summary/Resource.php b/app/Models/Summary/Resource.php index d841a68b..9e229a44 100644 --- a/app/Models/Summary/Resource.php +++ b/app/Models/Summary/Resource.php @@ -8,9 +8,14 @@ use Illuminate\Database\Query\Builder as QueryBuilder; /** - * Resource model - * * @mixin QueryBuilder + * + * @property int $id + * @property int $resource_type_id + * @property string $name + * @property string $description + * @property string $data + * * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE @@ -54,8 +59,7 @@ public function totalCount( $collection = Clause::applySearch($collection, $this->table, $search_parameters); - return $collection - ->get() + return $collection->get() ->toArray(); } } diff --git a/app/Models/Summary/ResourceType.php b/app/Models/Summary/ResourceType.php index 47bfd7de..24ea501a 100644 --- a/app/Models/Summary/ResourceType.php +++ b/app/Models/Summary/ResourceType.php @@ -8,9 +8,14 @@ use Illuminate\Database\Query\Builder as QueryBuilder; /** - * Resource type model - * * @mixin QueryBuilder + * + * @property int $id + * @property int $public + * @property string $name + * @property string $description + * @property string $data + * * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE diff --git a/app/Models/Summary/Subcategory.php b/app/Models/Summary/Subcategory.php index 9f4f099b..26ffc014 100644 --- a/app/Models/Summary/Subcategory.php +++ b/app/Models/Summary/Subcategory.php @@ -8,9 +8,13 @@ use Illuminate\Database\Eloquent\Model; /** - * Sub category model - * * @mixin QueryBuilder + * + * @property int $id + * @property int $category_id + * @property string $name + * @property string $description + * * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE @@ -50,8 +54,7 @@ public function totalCount( $collection = Clause::applySearch($collection, $this->table, $search_parameters); - return $collection - ->get() + return $collection->get() ->toArray(); } } From 16fc955c69f9ede3f7bf4c2573f2f34d5a47fb34 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Fri, 14 Jan 2022 12:04:08 +0000 Subject: [PATCH 18/73] Refactoring - Correct route - Reworking item type classes, better organisation. --- app/Http/Controllers/ItemView.php | 15 ++------ app/Http/Controllers/ResourceTypeItemView.php | 2 +- app/Http/Controllers/ResourceView.php | 3 +- .../{Response.php => ApiResponse.php} | 9 +++-- ...aryResponse.php => ApiSummaryResponse.php} | 4 +- app/ItemType/AllocatedExpense/Item.php | 16 ++++---- .../{Model.php => Models/Item.php} | 13 ++++--- .../ResourceTypeItem.php} | 4 +- ...sponse.php => ResourceTypeApiResponse.php} | 7 ++-- ...php => SummaryResourceTypeApiResponse.php} | 4 +- .../{Response.php => ApiResponse.php} | 5 +-- ...aryResponse.php => ApiSummaryResponse.php} | 2 +- app/ItemType/Entity.php | 25 ++++-------- .../Game/{Response.php => ApiResponse.php} | 9 +++-- ...aryResponse.php => ApiSummaryResponse.php} | 4 +- app/ItemType/Game/Item.php | 14 +++---- .../Game/{Model.php => Models/Item.php} | 8 ++-- .../ResourceTypeItem.php} | 4 +- ...sponse.php => ResourceTypeApiResponse.php} | 7 ++-- ...php => SummaryResourceTypeApiResponse.php} | 4 +- ...sponse.php => ResourceTypeApiResponse.php} | 2 +- .../{Response.php => ApiResponse.php} | 9 +++-- ...aryResponse.php => ApiSummaryResponse.php} | 4 +- app/ItemType/SimpleExpense/Item.php | 14 +++---- .../{Model.php => Models/Item.php} | 12 +++--- .../ResourceTypeItem.php} | 4 +- ...sponse.php => ResourceTypeApiResponse.php} | 7 ++-- ...php => SummaryResourceTypeApiResponse.php} | 4 +- .../{Response.php => ApiResponse.php} | 9 +++-- ...aryResponse.php => ApiSummaryResponse.php} | 4 +- app/ItemType/SimpleItem/Item.php | 14 +++---- .../SimpleItem/{Model.php => Models/Item.php} | 12 +++--- .../ResourceTypeItem.php} | 4 +- ...sponse.php => ResourceTypeApiResponse.php} | 7 ++-- ...php => SummaryResourceTypeApiResponse.php} | 4 +- ...php => SummaryResourceTypeApiResponse.php} | 2 +- app/Models/ResourceTypeItemType.php | 38 ++++++------------- database/factories/UserFactory.php | 2 +- routes/api/public-routes.php | 6 +-- 39 files changed, 146 insertions(+), 171 deletions(-) rename app/ItemType/AllocatedExpense/{Response.php => ApiResponse.php} (93%) rename app/ItemType/AllocatedExpense/{SummaryResponse.php => ApiSummaryResponse.php} (99%) rename app/ItemType/AllocatedExpense/{Model.php => Models/Item.php} (98%) rename app/ItemType/AllocatedExpense/{ResourceTypeModel.php => Models/ResourceTypeItem.php} (99%) rename app/ItemType/AllocatedExpense/{ResourceTypeResponse.php => ResourceTypeApiResponse.php} (91%) rename app/ItemType/AllocatedExpense/{SummaryResourceTypeResponse.php => SummaryResourceTypeApiResponse.php} (98%) rename app/ItemType/{Response.php => ApiResponse.php} (97%) rename app/ItemType/{SummaryResponse.php => ApiSummaryResponse.php} (98%) rename app/ItemType/Game/{Response.php => ApiResponse.php} (93%) rename app/ItemType/Game/{SummaryResponse.php => ApiSummaryResponse.php} (95%) rename app/ItemType/Game/{Model.php => Models/Item.php} (97%) rename app/ItemType/Game/{ResourceTypeModel.php => Models/ResourceTypeItem.php} (98%) rename app/ItemType/Game/{ResourceTypeResponse.php => ResourceTypeApiResponse.php} (91%) rename app/ItemType/Game/{SummaryResourceTypeResponse.php => SummaryResourceTypeApiResponse.php} (95%) rename app/ItemType/{ResourceTypeResponse.php => ResourceTypeApiResponse.php} (98%) rename app/ItemType/SimpleExpense/{Response.php => ApiResponse.php} (93%) rename app/ItemType/SimpleExpense/{SummaryResponse.php => ApiSummaryResponse.php} (98%) rename app/ItemType/SimpleExpense/{Model.php => Models/Item.php} (98%) rename app/ItemType/SimpleExpense/{ResourceTypeModel.php => Models/ResourceTypeItem.php} (99%) rename app/ItemType/SimpleExpense/{ResourceTypeResponse.php => ResourceTypeApiResponse.php} (90%) rename app/ItemType/SimpleExpense/{SummaryResourceTypeResponse.php => SummaryResourceTypeApiResponse.php} (98%) rename app/ItemType/SimpleItem/{Response.php => ApiResponse.php} (93%) rename app/ItemType/SimpleItem/{SummaryResponse.php => ApiSummaryResponse.php} (95%) rename app/ItemType/SimpleItem/{Model.php => Models/Item.php} (96%) rename app/ItemType/SimpleItem/{ResourceTypeModel.php => Models/ResourceTypeItem.php} (98%) rename app/ItemType/SimpleItem/{ResourceTypeResponse.php => ResourceTypeApiResponse.php} (90%) rename app/ItemType/SimpleItem/{SummaryResourceTypeResponse.php => SummaryResourceTypeApiResponse.php} (95%) rename app/ItemType/{SummaryResourceTypeResponse.php => SummaryResourceTypeApiResponse.php} (98%) diff --git a/app/Http/Controllers/ItemView.php b/app/Http/Controllers/ItemView.php index d568be2b..1f86bbb7 100644 --- a/app/Http/Controllers/ItemView.php +++ b/app/Http/Controllers/ItemView.php @@ -4,7 +4,7 @@ use App\AllowedValue\Currency; use App\ItemType\Entity; -use App\ItemType\Response; +use App\ItemType\ApiResponse; use App\Option\ItemCollection; use App\Option\ItemItem; use Illuminate\Http\JsonResponse; @@ -16,15 +16,6 @@ */ class ItemView extends Controller { - /** - * Return all the items for the resource type and resource applying - * any filtering, pagination and ordering - * - * @param string $resource_type_id - * @param string $resource_id - * - * @return JsonResponse - */ public function index( string $resource_type_id, string $resource_id @@ -39,7 +30,7 @@ public function index( $collection_class = $entity->viewClass(); /** - * @var $collection Response + * @var $collection ApiResponse */ $collection = new $collection_class( (int) $resource_type_id, @@ -74,7 +65,7 @@ public function show( $collection_class = $entity->viewClass(); /** - * @var $collection Response + * @var $collection ApiResponse */ $collection = new $collection_class( (int) $resource_type_id, diff --git a/app/Http/Controllers/ResourceTypeItemView.php b/app/Http/Controllers/ResourceTypeItemView.php index ed704dd7..75cacce6 100644 --- a/app/Http/Controllers/ResourceTypeItemView.php +++ b/app/Http/Controllers/ResourceTypeItemView.php @@ -26,7 +26,7 @@ public function index(string $resource_type_id): JsonResponse $collection_class = $entity->resourceTypeItemCollectionClass(); /** - * @var $collection \App\ItemType\ResourceTypeResponse + * @var $collection \App\ItemType\ResourceTypeApiResponse */ $collection = new $collection_class( (int) $resource_type_id, diff --git a/app/Http/Controllers/ResourceView.php b/app/Http/Controllers/ResourceView.php index 8b8e10aa..acb1d94f 100644 --- a/app/Http/Controllers/ResourceView.php +++ b/app/Http/Controllers/ResourceView.php @@ -154,8 +154,7 @@ public function optionsIndex(string $resource_type_id): JsonResponse $response = new ResourceCollection($this->permissions((int) $resource_type_id)); - return $response - ->setAllowedFields((new ItemSubtype())->allowedValues($resource_type['resource_type_item_type_id'])) + return $response->setAllowedFields((new ItemSubtype())->allowedValues($resource_type['resource_type_item_type_id'])) ->create() ->response(); } diff --git a/app/ItemType/AllocatedExpense/Response.php b/app/ItemType/AllocatedExpense/ApiResponse.php similarity index 93% rename from app/ItemType/AllocatedExpense/Response.php rename to app/ItemType/AllocatedExpense/ApiResponse.php index 9c8f4f4f..a3961813 100644 --- a/app/ItemType/AllocatedExpense/Response.php +++ b/app/ItemType/AllocatedExpense/ApiResponse.php @@ -3,11 +3,12 @@ namespace App\ItemType\AllocatedExpense; -use App\ItemType\Response as ItemTypeResponse; +use App\ItemType\AllocatedExpense\Models\Item; +use App\ItemType\ApiResponse as ItemTypeResponse; use App\Response\Responses; use Illuminate\Http\JsonResponse; -class Response extends ItemTypeResponse +class ApiResponse extends ItemTypeResponse { public function collectionResponse(): JsonResponse { @@ -24,7 +25,7 @@ public function collectionResponse(): JsonResponse $this->cache_control->isRequestCacheable() === false || $cache_collection->valid() === false ) { - $model = new Model(); + $model = new Item(); $this->fetchAllRequestParameters( new Item() @@ -87,7 +88,7 @@ public function showResponse(int $item_id): JsonResponse new Item() ); - $item = (new Model())->single( + $item = (new Item())->single( $this->resource_type_id, $this->resource_id, $item_id, diff --git a/app/ItemType/AllocatedExpense/SummaryResponse.php b/app/ItemType/AllocatedExpense/ApiSummaryResponse.php similarity index 99% rename from app/ItemType/AllocatedExpense/SummaryResponse.php rename to app/ItemType/AllocatedExpense/ApiSummaryResponse.php index f1726b72..1a1bd694 100644 --- a/app/ItemType/AllocatedExpense/SummaryResponse.php +++ b/app/ItemType/AllocatedExpense/ApiSummaryResponse.php @@ -2,11 +2,11 @@ namespace App\ItemType\AllocatedExpense; -use App\ItemType\SummaryResponse as BaseSummaryResponse; +use App\ItemType\ApiSummaryResponse as BaseSummaryResponse; use App\Request\Validate\Boolean; use Illuminate\Http\JsonResponse; -class SummaryResponse extends BaseSummaryResponse +class ApiSummaryResponse extends BaseSummaryResponse { public function __construct( int $resource_type_id, diff --git a/app/ItemType/AllocatedExpense/Item.php b/app/ItemType/AllocatedExpense/Item.php index baf7bc60..7c01c81c 100644 --- a/app/ItemType/AllocatedExpense/Item.php +++ b/app/ItemType/AllocatedExpense/Item.php @@ -37,14 +37,14 @@ public function allowPartialTransfers(): bool * * @param integer $id * - * @return Model + * @return \App\ItemType\AllocatedExpense\Models\Model */ public function create($id): Model { $hash = new Hash(); $currency_id = $hash->decode('currency', request()->input('currency_id')); - $item = new \App\ItemType\AllocatedExpense\Model([ + $item = new Models\Item([ 'item_id' => $id, 'name' => request()->input('name'), 'description' => request()->input('description', null), @@ -74,7 +74,7 @@ public function dateRangeField(): ?string public function instance(int $id): Model { - return (new \App\ItemType\AllocatedExpense\Model())->instance($id); + return (new Models\Item())->instance($id); } public function table(): string @@ -89,17 +89,17 @@ public function type(): string public function model() { - return new \App\ItemType\AllocatedExpense\Model(); + return new Models\Item(); } public function summaryClass(): string { - return SummaryResponse::class; + return ApiSummaryResponse::class; } public function resourceTypeSummaryClass(): string { - return SummaryResourceTypeResponse::class; + return SummaryResourceTypeApiResponse::class; } public function transformer(array $data_to_transform): Transformer @@ -139,12 +139,12 @@ public function validator(): Validator public function viewClass(): string { - return Response::class; + return ApiResponse::class; } public function resourceTypeItemCollectionClass(): string { - return ResourceTypeResponse::class; + return ResourceTypeApiResponse::class; } protected function allowedValuesItemCollectionClass(): string diff --git a/app/ItemType/AllocatedExpense/Model.php b/app/ItemType/AllocatedExpense/Models/Item.php similarity index 98% rename from app/ItemType/AllocatedExpense/Model.php rename to app/ItemType/AllocatedExpense/Models/Item.php index 87071a08..e357c053 100644 --- a/app/ItemType/AllocatedExpense/Model.php +++ b/app/ItemType/AllocatedExpense/Models/Item.php @@ -1,7 +1,7 @@ * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class Model extends LaravelModel +class Item extends LaravelModel { protected $table = 'item_type_allocated_expense'; @@ -34,7 +35,7 @@ public function setActualisedTotal($total, $percentage) $this->attributes['actualised_total'] = ($percentage === 100) ? $total : $total * ($percentage/100); } - public function instance(int $item_id): ?Model + public function instance(int $item_id): ?Item { return $this->where('item_id', '=', $item_id)-> select( @@ -168,12 +169,12 @@ public function minimumEffectiveDateYear(int $resource_id): int /** * Convert the model instance to an array for use with the transformer * - * @param Model $item - * @param Model $item_type + * @param Item $item + * @param Item $item_type * * @return array */ - public function instanceToArray(LaravelModel $item, Model $item_type): array + public function instanceToArray(LaravelModel $item, Item $item_type): array { return [ 'item_id' => $item->id, diff --git a/app/ItemType/AllocatedExpense/ResourceTypeModel.php b/app/ItemType/AllocatedExpense/Models/ResourceTypeItem.php similarity index 99% rename from app/ItemType/AllocatedExpense/ResourceTypeModel.php rename to app/ItemType/AllocatedExpense/Models/ResourceTypeItem.php index bb503c68..d7903eb8 100644 --- a/app/ItemType/AllocatedExpense/ResourceTypeModel.php +++ b/app/ItemType/AllocatedExpense/Models/ResourceTypeItem.php @@ -1,7 +1,7 @@ cache_control->isRequestCacheable() === false || $cache_collection->valid() === false ) { - $model = new ResourceTypeModel(); + $model = new ResourceTypeItem(); $this->fetchAllRequestParameters( new Item() diff --git a/app/ItemType/AllocatedExpense/SummaryResourceTypeResponse.php b/app/ItemType/AllocatedExpense/SummaryResourceTypeApiResponse.php similarity index 98% rename from app/ItemType/AllocatedExpense/SummaryResourceTypeResponse.php rename to app/ItemType/AllocatedExpense/SummaryResourceTypeApiResponse.php index 2bb1a182..f5ed3f66 100644 --- a/app/ItemType/AllocatedExpense/SummaryResourceTypeResponse.php +++ b/app/ItemType/AllocatedExpense/SummaryResourceTypeApiResponse.php @@ -2,11 +2,11 @@ namespace App\ItemType\AllocatedExpense; -use App\ItemType\SummaryResourceTypeResponse as BaseSummaryResourceTypeResponse; +use App\ItemType\SummaryResourceTypeApiResponse as BaseSummaryResourceTypeResponse; use App\Request\Validate\Boolean; use Illuminate\Http\JsonResponse; -class SummaryResourceTypeResponse extends BaseSummaryResourceTypeResponse +class SummaryResourceTypeApiResponse extends BaseSummaryResourceTypeResponse { public function __construct( int $resource_type_id, diff --git a/app/ItemType/Response.php b/app/ItemType/ApiResponse.php similarity index 97% rename from app/ItemType/Response.php rename to app/ItemType/ApiResponse.php index 5c2184e5..351a37a4 100644 --- a/app/ItemType/Response.php +++ b/app/ItemType/ApiResponse.php @@ -11,7 +11,7 @@ use App\Response\Pagination as UtilityPagination; use Illuminate\Http\JsonResponse; -abstract class Response +abstract class ApiResponse { protected int $resource_type_id; @@ -107,8 +107,7 @@ protected function fetchAllRequestParameters( protected function pagination_parameters(int $total): array { $pagination = new UtilityPagination(request()->path(), $total); - return $pagination - ->allowPaginationOverride(false) + return $pagination->allowPaginationOverride(false) ->setSearchParameters($this->search_parameters) ->setSortParameters($this->sort_fields) ->setParameters($this->request_parameters) diff --git a/app/ItemType/SummaryResponse.php b/app/ItemType/ApiSummaryResponse.php similarity index 98% rename from app/ItemType/SummaryResponse.php rename to app/ItemType/ApiSummaryResponse.php index 29eb6fa3..4faaea61 100644 --- a/app/ItemType/SummaryResponse.php +++ b/app/ItemType/ApiSummaryResponse.php @@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Http\JsonResponse; -abstract class SummaryResponse +abstract class ApiSummaryResponse { protected int $resource_type_id; diff --git a/app/ItemType/Entity.php b/app/ItemType/Entity.php index cc39b16b..d4fb4fcd 100644 --- a/app/ItemType/Entity.php +++ b/app/ItemType/Entity.php @@ -12,7 +12,7 @@ class Entity { public static function item(int $resource_type_id): ItemType { - $type =(new ResourceTypeItemType())->itemType($resource_type_id); + $type = (new ResourceTypeItemType())->itemType($resource_type_id); if ($type !== null) { return self::byType($type); @@ -23,21 +23,12 @@ public static function item(int $resource_type_id): ItemType public static function byType(string $item_type): ItemType { - switch ($item_type) { - case 'allocated-expense': - return new AllocatedExpenseItem(); - - case 'simple-expense': - return new SimpleExpenseItem(); - - case 'simple-item': - return new SimpleItemItem(); - - case 'game': - return new GameItem(); - - default: - throw new \OutOfRangeException('No entity definition for ' . $item_type, 500); - } + return match ($item_type) { + 'allocated-expense' => new AllocatedExpenseItem(), + 'simple-expense' => new SimpleExpenseItem(), + 'simple-item' => new SimpleItemItem(), + 'game' => new GameItem(), + default => throw new \OutOfRangeException('No entity definition for ' . $item_type, 500), + }; } } diff --git a/app/ItemType/Game/Response.php b/app/ItemType/Game/ApiResponse.php similarity index 93% rename from app/ItemType/Game/Response.php rename to app/ItemType/Game/ApiResponse.php index 4ef8a6e2..65dcb3ce 100644 --- a/app/ItemType/Game/Response.php +++ b/app/ItemType/Game/ApiResponse.php @@ -3,11 +3,12 @@ namespace App\ItemType\Game; -use App\ItemType\Response as ItemTypeResponse; +use App\ItemType\ApiResponse as ItemTypeResponse; +use App\ItemType\Game\Models\Item; use App\Response\Responses; use Illuminate\Http\JsonResponse; -class Response extends ItemTypeResponse +class ApiResponse extends ItemTypeResponse { public function collectionResponse(): JsonResponse { @@ -20,7 +21,7 @@ public function collectionResponse(): JsonResponse $this->cache_control->isRequestCacheable() === false || $cache_collection->valid() === false ) { - $model = new Model(); + $model = new Item(); $this->fetchAllRequestParameters( new Item() @@ -83,7 +84,7 @@ public function showResponse(int $item_id): JsonResponse new Item() ); - $item = (new Model())->single( + $item = (new Item())->single( $this->resource_type_id, $this->resource_id, $item_id, diff --git a/app/ItemType/Game/SummaryResponse.php b/app/ItemType/Game/ApiSummaryResponse.php similarity index 95% rename from app/ItemType/Game/SummaryResponse.php rename to app/ItemType/Game/ApiSummaryResponse.php index 925b5d33..29c3c419 100644 --- a/app/ItemType/Game/SummaryResponse.php +++ b/app/ItemType/Game/ApiSummaryResponse.php @@ -2,10 +2,10 @@ namespace App\ItemType\Game; -use App\ItemType\SummaryResponse as BaseSummaryResponse; +use App\ItemType\ApiSummaryResponse as BaseSummaryResponse; use Illuminate\Http\JsonResponse; -class SummaryResponse extends BaseSummaryResponse +class ApiSummaryResponse extends BaseSummaryResponse { public function __construct( int $resource_type_id, diff --git a/app/ItemType/Game/Item.php b/app/ItemType/Game/Item.php index 21d20c32..3f033f44 100644 --- a/app/ItemType/Game/Item.php +++ b/app/ItemType/Game/Item.php @@ -35,7 +35,7 @@ public function categoryAssignmentLimit(): int public function create(int $id): Model { - $item = new \App\ItemType\Game\Model([ + $item = new Models\Item([ 'item_id' => $id, 'name' => request()->input('name'), 'description' => request()->input('description', null), @@ -52,12 +52,12 @@ public function create(int $id): Model public function instance(int $id): Model { - return (new \App\ItemType\Game\Model())->instance($id); + return (new Models\Item())->instance($id); } public function model() { - return new \App\ItemType\Game\Model(); + return new Models\Item(); } public function subcategoryAssignmentLimit(): int @@ -116,22 +116,22 @@ public function patchFields(): array public function summaryClass(): string { - return SummaryResponse::class; + return ApiSummaryResponse::class; } public function viewClass(): string { - return Response::class; + return ApiResponse::class; } public function resourceTypeSummaryClass(): string { - return SummaryResourceTypeResponse::class; + return SummaryResourceTypeApiResponse::class; } public function resourceTypeItemCollectionClass(): string { - return ResourceTypeResponse::class; + return ResourceTypeApiResponse::class; } protected function allowedValuesItemCollectionClass(): string diff --git a/app/ItemType/Game/Model.php b/app/ItemType/Game/Models/Item.php similarity index 97% rename from app/ItemType/Game/Model.php rename to app/ItemType/Game/Models/Item.php index 8d7438ab..9fb2de2c 100644 --- a/app/ItemType/Game/Model.php +++ b/app/ItemType/Game/Models/Item.php @@ -1,7 +1,7 @@ hasOne(Category::class, 'id', 'winner_id'); } - public function instance(int $item_id): ?Model + public function instance(int $item_id): ?Item { return $this->where('item_id', '=', $item_id)-> select( @@ -36,7 +36,7 @@ public function instance(int $item_id): ?Model first(); } - public function instanceToArray(LaravelModel $item, Model $item_type): array + public function instanceToArray(LaravelModel $item, Item $item_type): array { return [ 'item_id' => $item->id, diff --git a/app/ItemType/Game/ResourceTypeModel.php b/app/ItemType/Game/Models/ResourceTypeItem.php similarity index 98% rename from app/ItemType/Game/ResourceTypeModel.php rename to app/ItemType/Game/Models/ResourceTypeItem.php index 3df02f80..f4a88d01 100644 --- a/app/ItemType/Game/ResourceTypeModel.php +++ b/app/ItemType/Game/Models/ResourceTypeItem.php @@ -1,7 +1,7 @@ cache_control->isRequestCacheable() === false || $cache_collection->valid() === false ) { - $model = new ResourceTypeModel(); + $model = new ResourceTypeItem(); $this->fetchAllRequestParameters( new Item() diff --git a/app/ItemType/Game/SummaryResourceTypeResponse.php b/app/ItemType/Game/SummaryResourceTypeApiResponse.php similarity index 95% rename from app/ItemType/Game/SummaryResourceTypeResponse.php rename to app/ItemType/Game/SummaryResourceTypeApiResponse.php index 85132d6d..9bdb60e3 100644 --- a/app/ItemType/Game/SummaryResourceTypeResponse.php +++ b/app/ItemType/Game/SummaryResourceTypeApiResponse.php @@ -2,12 +2,12 @@ namespace App\ItemType\Game; -use App\ItemType\SummaryResourceTypeResponse as BaseSummaryResourceTypeResponse; +use App\ItemType\SummaryResourceTypeApiResponse as BaseSummaryResourceTypeResponse; use App\ItemType\Game\SummaryTransformer as GameTransformer; use App\Request\Validate\Boolean; use Illuminate\Http\JsonResponse; -class SummaryResourceTypeResponse extends BaseSummaryResourceTypeResponse +class SummaryResourceTypeApiResponse extends BaseSummaryResourceTypeResponse { public function __construct( int $resource_type_id, diff --git a/app/ItemType/ResourceTypeResponse.php b/app/ItemType/ResourceTypeApiResponse.php similarity index 98% rename from app/ItemType/ResourceTypeResponse.php rename to app/ItemType/ResourceTypeApiResponse.php index 0eb3e1b4..65a53dd5 100644 --- a/app/ItemType/ResourceTypeResponse.php +++ b/app/ItemType/ResourceTypeApiResponse.php @@ -11,7 +11,7 @@ use App\Response\Pagination as UtilityPagination; use Illuminate\Http\JsonResponse; -abstract class ResourceTypeResponse +abstract class ResourceTypeApiResponse { protected int $resource_type_id; diff --git a/app/ItemType/SimpleExpense/Response.php b/app/ItemType/SimpleExpense/ApiResponse.php similarity index 93% rename from app/ItemType/SimpleExpense/Response.php rename to app/ItemType/SimpleExpense/ApiResponse.php index 39a4a64b..6e4fc463 100644 --- a/app/ItemType/SimpleExpense/Response.php +++ b/app/ItemType/SimpleExpense/ApiResponse.php @@ -3,11 +3,12 @@ namespace App\ItemType\SimpleExpense; -use App\ItemType\Response as ItemTypeResponse; +use App\ItemType\ApiResponse as ItemTypeResponse; +use App\ItemType\SimpleExpense\Models\Item; use App\Response\Responses; use Illuminate\Http\JsonResponse; -class Response extends ItemTypeResponse +class ApiResponse extends ItemTypeResponse { public function collectionResponse(): JsonResponse { @@ -20,7 +21,7 @@ public function collectionResponse(): JsonResponse $this->cache_control->isRequestCacheable() === false || $cache_collection->valid() === false ) { - $model = new Model(); + $model = new Item(); $this->fetchAllRequestParameters( new Item() @@ -83,7 +84,7 @@ public function showResponse(int $item_id): JsonResponse new Item() ); - $item = (new Model())->single( + $item = (new Item())->single( $this->resource_type_id, $this->resource_id, $item_id, diff --git a/app/ItemType/SimpleExpense/SummaryResponse.php b/app/ItemType/SimpleExpense/ApiSummaryResponse.php similarity index 98% rename from app/ItemType/SimpleExpense/SummaryResponse.php rename to app/ItemType/SimpleExpense/ApiSummaryResponse.php index b91729ff..1d0d2038 100644 --- a/app/ItemType/SimpleExpense/SummaryResponse.php +++ b/app/ItemType/SimpleExpense/ApiSummaryResponse.php @@ -2,11 +2,11 @@ namespace App\ItemType\SimpleExpense; -use App\ItemType\SummaryResponse as BaseSummaryResponse; +use App\ItemType\ApiSummaryResponse as BaseSummaryResponse; use App\Request\Validate\Boolean; use Illuminate\Http\JsonResponse; -class SummaryResponse extends BaseSummaryResponse +class ApiSummaryResponse extends BaseSummaryResponse { public function __construct( int $resource_type_id, diff --git a/app/ItemType/SimpleExpense/Item.php b/app/ItemType/SimpleExpense/Item.php index 903382b4..3280f8d1 100644 --- a/app/ItemType/SimpleExpense/Item.php +++ b/app/ItemType/SimpleExpense/Item.php @@ -32,7 +32,7 @@ public function create(int $id): Model $hash = new Hash(); $currency_id = $hash->decode('currency', request()->input('currency_id')); - $item = new \App\ItemType\SimpleExpense\Model([ + $item = new Models\Item([ 'item_id' => $id, 'name' => request()->input('name'), 'description' => request()->input('description', null), @@ -49,12 +49,12 @@ public function create(int $id): Model public function instance(int $id): Model { - return (new \App\ItemType\SimpleExpense\Model())->instance($id); + return (new Models\Item())->instance($id); } public function model() { - return new \App\ItemType\SimpleExpense\Model(); + return new Models\Item(); } public function table(): string @@ -69,12 +69,12 @@ public function type(): string public function summaryClass(): string { - return SummaryResponse::class; + return ApiSummaryResponse::class; } public function resourceTypeSummaryClass(): string { - return SummaryResourceTypeResponse::class; + return SummaryResourceTypeApiResponse::class; } public function transformer(array $data_to_transform): Transformer @@ -105,12 +105,12 @@ public function validator(): Validator public function viewClass(): string { - return Response::class; + return ApiResponse::class; } public function resourceTypeItemCollectionClass(): string { - return ResourceTypeResponse::class; + return ResourceTypeApiResponse::class; } protected function allowedValuesItemCollectionClass(): string diff --git a/app/ItemType/SimpleExpense/Model.php b/app/ItemType/SimpleExpense/Models/Item.php similarity index 98% rename from app/ItemType/SimpleExpense/Model.php rename to app/ItemType/SimpleExpense/Models/Item.php index c60ca663..abc56cba 100644 --- a/app/ItemType/SimpleExpense/Model.php +++ b/app/ItemType/SimpleExpense/Models/Item.php @@ -1,7 +1,7 @@ hasOne(Currency::class, 'id', 'currency_id'); } - public function instance(int $item_id): ?Model + public function instance(int $item_id): ?Item { return $this->where('item_id', '=', $item_id)-> select( @@ -40,12 +40,12 @@ public function instance(int $item_id): ?Model /** * Convert the model instance to an array for use with the transformer * - * @param Model $item - * @param Model $item_type + * @param Item $item + * @param Item $item_type * * @return array */ - public function instanceToArray(LaravelModel $item, Model $item_type): array + public function instanceToArray(LaravelModel $item, Item $item_type): array { return [ 'item_id' => $item->id, diff --git a/app/ItemType/SimpleExpense/ResourceTypeModel.php b/app/ItemType/SimpleExpense/Models/ResourceTypeItem.php similarity index 99% rename from app/ItemType/SimpleExpense/ResourceTypeModel.php rename to app/ItemType/SimpleExpense/Models/ResourceTypeItem.php index 04b5b6d1..0417ae59 100644 --- a/app/ItemType/SimpleExpense/ResourceTypeModel.php +++ b/app/ItemType/SimpleExpense/Models/ResourceTypeItem.php @@ -1,7 +1,7 @@ cache_control->isRequestCacheable() === false || $cache_collection->valid() === false ) { - $model = new ResourceTypeModel(); + $model = new ResourceTypeItem(); $this->fetchAllRequestParameters( new Item() diff --git a/app/ItemType/SimpleExpense/SummaryResourceTypeResponse.php b/app/ItemType/SimpleExpense/SummaryResourceTypeApiResponse.php similarity index 98% rename from app/ItemType/SimpleExpense/SummaryResourceTypeResponse.php rename to app/ItemType/SimpleExpense/SummaryResourceTypeApiResponse.php index f718e8c2..ab791643 100644 --- a/app/ItemType/SimpleExpense/SummaryResourceTypeResponse.php +++ b/app/ItemType/SimpleExpense/SummaryResourceTypeApiResponse.php @@ -2,11 +2,11 @@ namespace App\ItemType\SimpleExpense; -use App\ItemType\SummaryResourceTypeResponse as BaseSummaryResourceTypeResponse; +use App\ItemType\SummaryResourceTypeApiResponse as BaseSummaryResourceTypeResponse; use App\Request\Validate\Boolean; use Illuminate\Http\JsonResponse; -class SummaryResourceTypeResponse extends BaseSummaryResourceTypeResponse +class SummaryResourceTypeApiResponse extends BaseSummaryResourceTypeResponse { public function __construct( int $resource_type_id, diff --git a/app/ItemType/SimpleItem/Response.php b/app/ItemType/SimpleItem/ApiResponse.php similarity index 93% rename from app/ItemType/SimpleItem/Response.php rename to app/ItemType/SimpleItem/ApiResponse.php index 75caefd5..c81156c4 100644 --- a/app/ItemType/SimpleItem/Response.php +++ b/app/ItemType/SimpleItem/ApiResponse.php @@ -3,11 +3,12 @@ namespace App\ItemType\SimpleItem; -use App\ItemType\Response as ItemTypeResponse; +use App\ItemType\ApiResponse as ItemTypeResponse; +use App\ItemType\SimpleItem\Models\Item; use App\Response\Responses; use Illuminate\Http\JsonResponse; -class Response extends ItemTypeResponse +class ApiResponse extends ItemTypeResponse { public function collectionResponse(): JsonResponse { @@ -20,7 +21,7 @@ public function collectionResponse(): JsonResponse $this->cache_control->isRequestCacheable() === false || $cache_collection->valid() === false ) { - $model = new Model(); + $model = new Item(); $this->fetchAllRequestParameters( new Item() @@ -82,7 +83,7 @@ public function showResponse(int $item_id): JsonResponse new Item() ); - $item = (new Model())->single( + $item = (new Item())->single( $this->resource_type_id, $this->resource_id, $item_id, diff --git a/app/ItemType/SimpleItem/SummaryResponse.php b/app/ItemType/SimpleItem/ApiSummaryResponse.php similarity index 95% rename from app/ItemType/SimpleItem/SummaryResponse.php rename to app/ItemType/SimpleItem/ApiSummaryResponse.php index e39b74dc..4abc7880 100644 --- a/app/ItemType/SimpleItem/SummaryResponse.php +++ b/app/ItemType/SimpleItem/ApiSummaryResponse.php @@ -2,10 +2,10 @@ namespace App\ItemType\SimpleItem; -use App\ItemType\SummaryResponse as BaseSummaryResponse; +use App\ItemType\ApiSummaryResponse as BaseSummaryResponse; use Illuminate\Http\JsonResponse; -class SummaryResponse extends BaseSummaryResponse +class ApiSummaryResponse extends BaseSummaryResponse { public function __construct( int $resource_type_id, diff --git a/app/ItemType/SimpleItem/Item.php b/app/ItemType/SimpleItem/Item.php index 9fff6b31..538609b4 100644 --- a/app/ItemType/SimpleItem/Item.php +++ b/app/ItemType/SimpleItem/Item.php @@ -32,7 +32,7 @@ public function categoryAssignmentLimit(): int public function create(int $id): Model { - $item = new \App\ItemType\SimpleItem\Model([ + $item = new Models\Item([ 'item_id' => $id, 'name' => request()->input('name'), 'description' => request()->input('description', null), @@ -48,12 +48,12 @@ public function create(int $id): Model public function instance(int $id): Model { - return (new \App\ItemType\SimpleItem\Model())->instance($id); + return (new Models\Item())->instance($id); } public function model() { - return new \App\ItemType\SimpleItem\Model(); + return new Models\Item(); } public function subcategoryAssignmentLimit(): int @@ -73,12 +73,12 @@ public function type(): string public function summaryClass(): string { - return SummaryResponse::class; + return ApiSummaryResponse::class; } public function resourceTypeSummaryClass(): string { - return SummaryResourceTypeResponse::class; + return SummaryResourceTypeApiResponse::class; } public function transformer(array $data_to_transform): Transformer @@ -104,12 +104,12 @@ public function validator(): Validator public function viewClass(): string { - return Response::class; + return ApiResponse::class; } public function resourceTypeItemCollectionClass(): string { - return ResourceTypeResponse::class; + return ResourceTypeApiResponse::class; } protected function allowedValuesItemCollectionClass(): string diff --git a/app/ItemType/SimpleItem/Model.php b/app/ItemType/SimpleItem/Models/Item.php similarity index 96% rename from app/ItemType/SimpleItem/Model.php rename to app/ItemType/SimpleItem/Models/Item.php index 20df82a4..198899e3 100644 --- a/app/ItemType/SimpleItem/Model.php +++ b/app/ItemType/SimpleItem/Models/Item.php @@ -1,7 +1,7 @@ where('item_id', '=', $item_id)-> select( @@ -33,12 +33,12 @@ public function instance(int $item_id): ?Model /** * Convert the model instance to an array for use with the item transformer * - * @param Model $item - * @param Model $item_type + * @param Item $item + * @param Item $item_type * * @return array */ - public function instanceToArray(LaravelModel $item, Model $item_type): array + public function instanceToArray(LaravelModel $item, Item $item_type): array { return [ 'item_id' => $item->id, diff --git a/app/ItemType/SimpleItem/ResourceTypeModel.php b/app/ItemType/SimpleItem/Models/ResourceTypeItem.php similarity index 98% rename from app/ItemType/SimpleItem/ResourceTypeModel.php rename to app/ItemType/SimpleItem/Models/ResourceTypeItem.php index 3a9dd541..cf4b3576 100644 --- a/app/ItemType/SimpleItem/ResourceTypeModel.php +++ b/app/ItemType/SimpleItem/Models/ResourceTypeItem.php @@ -1,7 +1,7 @@ cache_control->isRequestCacheable() === false || $cache_collection->valid() === false ) { - $model = new ResourceTypeModel(); + $model = new ResourceTypeItem(); $this->fetchAllRequestParameters( new Item() diff --git a/app/ItemType/SimpleItem/SummaryResourceTypeResponse.php b/app/ItemType/SimpleItem/SummaryResourceTypeApiResponse.php similarity index 95% rename from app/ItemType/SimpleItem/SummaryResourceTypeResponse.php rename to app/ItemType/SimpleItem/SummaryResourceTypeApiResponse.php index 87c9af43..1e7369f0 100644 --- a/app/ItemType/SimpleItem/SummaryResourceTypeResponse.php +++ b/app/ItemType/SimpleItem/SummaryResourceTypeApiResponse.php @@ -2,11 +2,11 @@ namespace App\ItemType\SimpleItem; -use App\ItemType\SummaryResourceTypeResponse as BaseSummaryResourceTypeResponse; +use App\ItemType\SummaryResourceTypeApiResponse as BaseSummaryResourceTypeResponse; use App\Request\Validate\Boolean; use Illuminate\Http\JsonResponse; -class SummaryResourceTypeResponse extends BaseSummaryResourceTypeResponse +class SummaryResourceTypeApiResponse extends BaseSummaryResourceTypeResponse { public function __construct( int $resource_type_id, diff --git a/app/ItemType/SummaryResourceTypeResponse.php b/app/ItemType/SummaryResourceTypeApiResponse.php similarity index 98% rename from app/ItemType/SummaryResourceTypeResponse.php rename to app/ItemType/SummaryResourceTypeApiResponse.php index 2da70f87..d65bc277 100644 --- a/app/ItemType/SummaryResourceTypeResponse.php +++ b/app/ItemType/SummaryResourceTypeApiResponse.php @@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Http\JsonResponse; -abstract class SummaryResourceTypeResponse +abstract class SummaryResourceTypeApiResponse { protected int $resource_type_id; diff --git a/app/Models/ResourceTypeItemType.php b/app/Models/ResourceTypeItemType.php index feab4e05..9c35422f 100644 --- a/app/Models/ResourceTypeItemType.php +++ b/app/Models/ResourceTypeItemType.php @@ -7,9 +7,12 @@ use Illuminate\Database\Eloquent\Model; /** - * Resource type item type model - * * @mixin QueryBuilder + * + * @property int $id + * @property int $resource_type_id + * @property int $item_type_id + * * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE @@ -20,39 +23,22 @@ class ResourceTypeItemType extends Model protected $guarded = ['id', 'created_at', 'updated_at']; - /** - * Fetch the item type assigned to the requested resource type - * - * @param integer $resource_type_id - * - * @return string|null - */ public function itemType(int $resource_type_id): ?string { - $collection = $this->join( - 'item_type', - 'resource_type_item_type.item_type_id', - 'item_type.id')-> - where('resource_type_item_type.resource_type_id', '=', $resource_type_id)-> - first(['item_type.name']); + $collection = $this->join('item_type', 'resource_type_item_type.item_type_id','item_type.id') + ->where('resource_type_item_type.resource_type_id', '=', $resource_type_id) + ->first(['item_type.name']); if ($collection !== null) { return $collection->toArray()['name']; - } else { - return null; } + + return null; } - /** - * Return an instance of the resource type item type - * - * @param integer $resource_type_id - * - * @return ResourceAccess|null - */ public function instance(int $resource_type_id): ?ResourceTypeItemType { - return $this->where('resource_type_id', '=', $resource_type_id)-> - first(); + return $this->where('resource_type_id', '=', $resource_type_id) + ->first(); } } diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index facf2337..19c4c02a 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -4,7 +4,7 @@ /* |-------------------------------------------------------------------------- -| Model Factories +| Models Factories |-------------------------------------------------------------------------- | | This directory should contain each of the model factory definitions for diff --git a/routes/api/public-routes.php b/routes/api/public-routes.php index 7215d71a..b3b1caa6 100644 --- a/routes/api/public-routes.php +++ b/routes/api/public-routes.php @@ -220,17 +220,17 @@ static function () { Route::options( 'resource-types/{resource_type_id}/resources', - [\App\Http\Controllers\ResourceTypeView::class, 'optionsIndex'] + [\App\Http\Controllers\ResourceView::class, 'optionsIndex'] )->name('resource.list.options'); Route::get( 'resource-types/{resource_type_id}/resources/{resource_id}', - [\App\Http\Controllers\ResourceTypeView::class, 'show'] + [\App\Http\Controllers\ResourceView::class, 'show'] )->name('resource.show'); Route::options( 'resource-types/{resource_type_id}/resources/{resource_id}', - [\App\Http\Controllers\ResourceTypeView::class, 'optionsShow'] + [\App\Http\Controllers\ResourceView::class, 'optionsShow'] )->name('resource.show.options'); Route::get( From f7ec4c539045c2391cb39e7fe08d9333f0802237 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Fri, 14 Jan 2022 13:44:52 +0000 Subject: [PATCH 19/73] Refactoring - Refactoring corrections --- app/ItemType/AllocatedExpense/ApiResponse.php | 4 ++-- app/ItemType/Game/ApiResponse.php | 4 ++-- app/ItemType/SimpleExpense/ApiResponse.php | 4 ++-- app/ItemType/SimpleItem/ApiResponse.php | 4 ++-- app/Models/ItemTransfer.php | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/ItemType/AllocatedExpense/ApiResponse.php b/app/ItemType/AllocatedExpense/ApiResponse.php index a3961813..750c0899 100644 --- a/app/ItemType/AllocatedExpense/ApiResponse.php +++ b/app/ItemType/AllocatedExpense/ApiResponse.php @@ -28,7 +28,7 @@ public function collectionResponse(): JsonResponse $model = new Item(); $this->fetchAllRequestParameters( - new Item() + new \App\ItemType\AllocatedExpense\Item() ); $total = $model->totalCount( @@ -85,7 +85,7 @@ static function ($item) { public function showResponse(int $item_id): JsonResponse { $this->fetchAllRequestParameters( - new Item() + new \App\ItemType\AllocatedExpense\Item() ); $item = (new Item())->single( diff --git a/app/ItemType/Game/ApiResponse.php b/app/ItemType/Game/ApiResponse.php index 65dcb3ce..d326d699 100644 --- a/app/ItemType/Game/ApiResponse.php +++ b/app/ItemType/Game/ApiResponse.php @@ -24,7 +24,7 @@ public function collectionResponse(): JsonResponse $model = new Item(); $this->fetchAllRequestParameters( - new Item() + new \App\ItemType\Game\Item() ); $total = $model->totalCount( @@ -81,7 +81,7 @@ static function ($item) { public function showResponse(int $item_id): JsonResponse { $this->fetchAllRequestParameters( - new Item() + new \App\ItemType\Game\Item() ); $item = (new Item())->single( diff --git a/app/ItemType/SimpleExpense/ApiResponse.php b/app/ItemType/SimpleExpense/ApiResponse.php index 6e4fc463..3f8e2822 100644 --- a/app/ItemType/SimpleExpense/ApiResponse.php +++ b/app/ItemType/SimpleExpense/ApiResponse.php @@ -24,7 +24,7 @@ public function collectionResponse(): JsonResponse $model = new Item(); $this->fetchAllRequestParameters( - new Item() + new \App\ItemType\SimpleExpense\Item() ); $total = $model->totalCount( @@ -81,7 +81,7 @@ static function ($item) { public function showResponse(int $item_id): JsonResponse { $this->fetchAllRequestParameters( - new Item() + new \App\ItemType\SimpleExpense\Item() ); $item = (new Item())->single( diff --git a/app/ItemType/SimpleItem/ApiResponse.php b/app/ItemType/SimpleItem/ApiResponse.php index c81156c4..a377c593 100644 --- a/app/ItemType/SimpleItem/ApiResponse.php +++ b/app/ItemType/SimpleItem/ApiResponse.php @@ -24,7 +24,7 @@ public function collectionResponse(): JsonResponse $model = new Item(); $this->fetchAllRequestParameters( - new Item() + new \App\ItemType\SimpleItem\Item() ); $total = $model->totalCount( @@ -80,7 +80,7 @@ static function ($item) { public function showResponse(int $item_id): JsonResponse { $this->fetchAllRequestParameters( - new Item() + new \App\ItemType\SimpleItem\Item() ); $item = (new Item())->single( diff --git a/app/Models/ItemTransfer.php b/app/Models/ItemTransfer.php index d9cf9cee..4c8bc76b 100644 --- a/app/Models/ItemTransfer.php +++ b/app/Models/ItemTransfer.php @@ -128,7 +128,7 @@ public function total( return $collection->count(); } - public function deleteTransfers(int $item_id): ?bool + public function deleteTransfers(int $item_id): ?int { return $this->where($this->table . '.item_id', '=', $item_id)->delete(); } From c1164b8def3c4fbade1fabb51f2be5e7cf5d8b34 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Fri, 14 Jan 2022 14:04:51 +0000 Subject: [PATCH 20/73] Refactoring - Move transformers and models --- app/ItemType/AllocatedExpense/ApiResponse.php | 1 + app/ItemType/AllocatedExpense/ApiSummaryResponse.php | 6 ++++++ app/ItemType/AllocatedExpense/Item.php | 2 +- .../AllocatedExpense/{ => Models}/SummaryModel.php | 2 +- .../{ => Models}/SummaryResourceTypeModel.php | 2 +- app/ItemType/AllocatedExpense/ResourceTypeApiResponse.php | 2 +- .../AllocatedExpense/SummaryResourceTypeApiResponse.php | 7 +++++++ .../{ => Transformers}/ResourceTypeTransformer.php | 2 +- .../{ => Transformers}/SummaryTransformer.php | 2 +- .../Transformers}/SummaryTransformerByCategory.php | 2 +- .../{ => Transformers}/SummaryTransformerByMonth.php | 2 +- .../{ => Transformers}/SummaryTransformerByResource.php | 2 +- .../Transformers}/SummaryTransformerBySubcategory.php | 2 +- .../{ => Transformers}/SummaryTransformerByYear.php | 2 +- .../AllocatedExpense/{ => Transformers}/Transformer.php | 2 +- app/ItemType/Game/ApiResponse.php | 1 + app/ItemType/Game/ApiSummaryResponse.php | 2 ++ app/ItemType/Game/Item.php | 2 +- app/ItemType/Game/{ => Models}/SummaryModel.php | 2 +- .../Game/{ => Models}/SummaryResourceTypeModel.php | 2 +- app/ItemType/Game/ResourceTypeApiResponse.php | 2 +- app/ItemType/Game/SummaryResourceTypeApiResponse.php | 4 +++- .../Game/{ => Transformers}/ResourceTypeTransformer.php | 2 +- .../Game/{ => Transformers}/SummaryTransformer.php | 2 +- .../{ => Transformers}/SummaryTransformerByResource.php | 2 +- app/ItemType/Game/{ => Transformers}/Transformer.php | 2 +- app/ItemType/SimpleExpense/ApiResponse.php | 1 + app/ItemType/SimpleExpense/ApiSummaryResponse.php | 4 ++++ app/ItemType/SimpleExpense/Item.php | 2 +- app/ItemType/SimpleExpense/{ => Models}/SummaryModel.php | 2 +- .../{ => Models}/SummaryResourceTypeModel.php | 2 +- app/ItemType/SimpleExpense/ResourceTypeApiResponse.php | 2 +- .../SimpleExpense/SummaryResourceTypeApiResponse.php | 5 +++++ .../{ => Transformers}/ResourceTypeTransformer.php | 2 +- .../{ => Transformers}/SummaryTransformer.php | 2 +- .../Transformers}/SummaryTransformerByCategory.php | 2 +- .../{ => Transformers}/SummaryTransformerByResource.php | 2 +- .../Transformers}/SummaryTransformerBySubcategory.php | 2 +- .../SimpleExpense/{ => Transformers}/Transformer.php | 2 +- app/ItemType/SimpleItem/ApiResponse.php | 1 + app/ItemType/SimpleItem/ApiSummaryResponse.php | 2 ++ app/ItemType/SimpleItem/Item.php | 2 +- app/ItemType/SimpleItem/{ => Models}/SummaryModel.php | 2 +- .../SimpleItem/{ => Models}/SummaryResourceTypeModel.php | 2 +- app/ItemType/SimpleItem/ResourceTypeApiResponse.php | 2 +- app/ItemType/SimpleItem/SummaryResourceTypeApiResponse.php | 3 +++ .../{ => Transformers}/ResourceTypeTransformer.php | 2 +- .../SimpleItem/{ => Transformers}/SummaryTransformer.php | 2 +- .../{ => Transformers}/SummaryTransformerByResource.php | 2 +- app/ItemType/SimpleItem/{ => Transformers}/Transformer.php | 2 +- 50 files changed, 74 insertions(+), 39 deletions(-) rename app/ItemType/AllocatedExpense/{ => Models}/SummaryModel.php (99%) rename app/ItemType/AllocatedExpense/{ => Models}/SummaryResourceTypeModel.php (99%) rename app/ItemType/AllocatedExpense/{ => Transformers}/ResourceTypeTransformer.php (96%) rename app/ItemType/AllocatedExpense/{ => Transformers}/SummaryTransformer.php (92%) rename app/ItemType/{SimpleExpense => AllocatedExpense/Transformers}/SummaryTransformerByCategory.php (95%) rename app/ItemType/AllocatedExpense/{ => Transformers}/SummaryTransformerByMonth.php (95%) rename app/ItemType/AllocatedExpense/{ => Transformers}/SummaryTransformerByResource.php (95%) rename app/ItemType/{SimpleExpense => AllocatedExpense/Transformers}/SummaryTransformerBySubcategory.php (95%) rename app/ItemType/AllocatedExpense/{ => Transformers}/SummaryTransformerByYear.php (95%) rename app/ItemType/AllocatedExpense/{ => Transformers}/Transformer.php (96%) rename app/ItemType/Game/{ => Models}/SummaryModel.php (99%) rename app/ItemType/Game/{ => Models}/SummaryResourceTypeModel.php (99%) rename app/ItemType/Game/{ => Transformers}/ResourceTypeTransformer.php (98%) rename app/ItemType/Game/{ => Transformers}/SummaryTransformer.php (98%) rename app/ItemType/Game/{ => Transformers}/SummaryTransformerByResource.php (97%) rename app/ItemType/Game/{ => Transformers}/Transformer.php (97%) rename app/ItemType/SimpleExpense/{ => Models}/SummaryModel.php (99%) rename app/ItemType/SimpleExpense/{ => Models}/SummaryResourceTypeModel.php (99%) rename app/ItemType/SimpleExpense/{ => Transformers}/ResourceTypeTransformer.php (96%) rename app/ItemType/SimpleExpense/{ => Transformers}/SummaryTransformer.php (92%) rename app/ItemType/{AllocatedExpense => SimpleExpense/Transformers}/SummaryTransformerByCategory.php (96%) rename app/ItemType/SimpleExpense/{ => Transformers}/SummaryTransformerByResource.php (95%) rename app/ItemType/{AllocatedExpense => SimpleExpense/Transformers}/SummaryTransformerBySubcategory.php (96%) rename app/ItemType/SimpleExpense/{ => Transformers}/Transformer.php (95%) rename app/ItemType/SimpleItem/{ => Models}/SummaryModel.php (98%) rename app/ItemType/SimpleItem/{ => Models}/SummaryResourceTypeModel.php (99%) rename app/ItemType/SimpleItem/{ => Transformers}/ResourceTypeTransformer.php (95%) rename app/ItemType/SimpleItem/{ => Transformers}/SummaryTransformer.php (91%) rename app/ItemType/SimpleItem/{ => Transformers}/SummaryTransformerByResource.php (93%) rename app/ItemType/SimpleItem/{ => Transformers}/Transformer.php (94%) diff --git a/app/ItemType/AllocatedExpense/ApiResponse.php b/app/ItemType/AllocatedExpense/ApiResponse.php index 750c0899..4bb8024c 100644 --- a/app/ItemType/AllocatedExpense/ApiResponse.php +++ b/app/ItemType/AllocatedExpense/ApiResponse.php @@ -4,6 +4,7 @@ namespace App\ItemType\AllocatedExpense; use App\ItemType\AllocatedExpense\Models\Item; +use App\ItemType\AllocatedExpense\Transformers\Transformer; use App\ItemType\ApiResponse as ItemTypeResponse; use App\Response\Responses; use Illuminate\Http\JsonResponse; diff --git a/app/ItemType/AllocatedExpense/ApiSummaryResponse.php b/app/ItemType/AllocatedExpense/ApiSummaryResponse.php index 1a1bd694..bba54ada 100644 --- a/app/ItemType/AllocatedExpense/ApiSummaryResponse.php +++ b/app/ItemType/AllocatedExpense/ApiSummaryResponse.php @@ -2,6 +2,12 @@ namespace App\ItemType\AllocatedExpense; +use App\ItemType\AllocatedExpense\Models\SummaryModel; +use App\ItemType\AllocatedExpense\Transformers\SummaryTransformer; +use App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByCategory; +use App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByMonth; +use App\ItemType\AllocatedExpense\Transformers\SummaryTransformerBySubcategory; +use App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByYear; use App\ItemType\ApiSummaryResponse as BaseSummaryResponse; use App\Request\Validate\Boolean; use Illuminate\Http\JsonResponse; diff --git a/app/ItemType/AllocatedExpense/Item.php b/app/ItemType/AllocatedExpense/Item.php index 7c01c81c..81006098 100644 --- a/app/ItemType/AllocatedExpense/Item.php +++ b/app/ItemType/AllocatedExpense/Item.php @@ -104,7 +104,7 @@ public function resourceTypeSummaryClass(): string public function transformer(array $data_to_transform): Transformer { - return new \App\ItemType\AllocatedExpense\Transformer($data_to_transform); + return new Transformers\Transformer($data_to_transform); } public function update(array $patch, Model $instance): bool diff --git a/app/ItemType/AllocatedExpense/SummaryModel.php b/app/ItemType/AllocatedExpense/Models/SummaryModel.php similarity index 99% rename from app/ItemType/AllocatedExpense/SummaryModel.php rename to app/ItemType/AllocatedExpense/Models/SummaryModel.php index 67029d81..1e5b8249 100644 --- a/app/ItemType/AllocatedExpense/SummaryModel.php +++ b/app/ItemType/AllocatedExpense/Models/SummaryModel.php @@ -1,7 +1,7 @@ Date: Fri, 14 Jan 2022 14:41:44 +0000 Subject: [PATCH 21/73] Refactoring - Moving classes around, year away has given me clarity --- app/Entity/Api.php | 39 ------------------- app/Http/Controllers/Authentication.php | 18 ++++----- app/Http/Controllers/ResourceTypeItemView.php | 2 +- .../{ => AllowedValue}/AllowedValue.php | 3 +- .../ResourceTypeAllowedValue.php | 3 +- app/ItemType/AllocatedExpense/Item.php | 10 ++++- .../ApiResourceTypeResponse.php} | 9 +++-- .../{ => Response}/ApiResponse.php | 5 ++- .../ApiSummaryResourceTypeResponse.php} | 9 +++-- .../{ => Response}/ApiSummaryResponse.php | 5 ++- ...sponse.php => ApiResourceTypeResponse.php} | 2 +- ...php => ApiSummaryResourceTypeResponse.php} | 2 +- .../Game/{ => AllowedValue}/AllowedValue.php | 4 +- .../ResourceTypeAllowedValue.php | 4 +- app/ItemType/Game/Item.php | 10 ++++- .../ApiResourceTypeResponse.php} | 9 +++-- .../Game/{ => Response}/ApiResponse.php | 5 ++- .../ApiSummaryResourceTypeResponse.php} | 8 ++-- .../{ => Response}/ApiSummaryResponse.php | 4 +- .../{ => AllowedValue}/AllowedValue.php | 3 +- .../ResourceTypeAllowedValue.php | 3 +- app/ItemType/SimpleExpense/Item.php | 10 ++++- .../ApiResourceTypeResponse.php} | 9 +++-- .../{ => Response}/ApiResponse.php | 5 ++- .../ApiSummaryResourceTypeResponse.php} | 8 ++-- .../{ => Response}/ApiSummaryResponse.php | 4 +- .../{ => AllowedValue}/AllowedValue.php | 3 +- .../ResourceTypeAllowedValue.php | 3 +- app/ItemType/SimpleItem/Item.php | 10 ++++- .../ApiResourceTypeResponse.php} | 9 +++-- .../SimpleItem/{ => Response}/ApiResponse.php | 5 ++- .../ApiSummaryResourceTypeResponse.php} | 8 ++-- .../{ => Response}/ApiSummaryResponse.php | 4 +- app/Method/GetRequest.php | 37 +++++++++++++++--- app/Method/Method.php | 6 --- app/Option/{ => Auth}/Check.php | 4 +- app/Option/{ => Auth}/CreateNewPassword.php | 3 +- app/Option/{ => Auth}/CreatePassword.php | 3 +- app/Option/{ => Auth}/ForgotPassword.php | 3 +- app/Option/{ => Auth}/Login.php | 3 +- app/Option/{ => Auth}/Register.php | 3 +- app/Option/{ => Auth}/UpdatePassword.php | 3 +- app/Option/{ => Auth}/UpdateProfile.php | 3 +- app/Option/{ => Auth}/User.php | 4 +- 44 files changed, 188 insertions(+), 119 deletions(-) delete mode 100644 app/Entity/Api.php rename app/ItemType/AllocatedExpense/{ => AllowedValue}/AllowedValue.php (91%) rename app/ItemType/AllocatedExpense/{ => AllowedValue}/ResourceTypeAllowedValue.php (91%) rename app/ItemType/AllocatedExpense/{ResourceTypeApiResponse.php => Response/ApiResourceTypeResponse.php} (90%) rename app/ItemType/AllocatedExpense/{ => Response}/ApiResponse.php (96%) rename app/ItemType/AllocatedExpense/{SummaryResourceTypeApiResponse.php => Response/ApiSummaryResourceTypeResponse.php} (98%) rename app/ItemType/AllocatedExpense/{ => Response}/ApiSummaryResponse.php (99%) rename app/ItemType/{ResourceTypeApiResponse.php => ApiResourceTypeResponse.php} (98%) rename app/ItemType/{SummaryResourceTypeApiResponse.php => ApiSummaryResourceTypeResponse.php} (98%) rename app/ItemType/Game/{ => AllowedValue}/AllowedValue.php (95%) rename app/ItemType/Game/{ => AllowedValue}/ResourceTypeAllowedValue.php (95%) rename app/ItemType/Game/{ResourceTypeApiResponse.php => Response/ApiResourceTypeResponse.php} (90%) rename app/ItemType/Game/{ => Response}/ApiResponse.php (96%) rename app/ItemType/Game/{SummaryResourceTypeApiResponse.php => Response/ApiSummaryResourceTypeResponse.php} (94%) rename app/ItemType/Game/{ => Response}/ApiSummaryResponse.php (96%) rename app/ItemType/SimpleExpense/{ => AllowedValue}/AllowedValue.php (91%) rename app/ItemType/SimpleExpense/{ => AllowedValue}/ResourceTypeAllowedValue.php (91%) rename app/ItemType/SimpleExpense/{ResourceTypeApiResponse.php => Response/ApiResourceTypeResponse.php} (90%) rename app/ItemType/SimpleExpense/{ => Response}/ApiResponse.php (96%) rename app/ItemType/SimpleExpense/{SummaryResourceTypeApiResponse.php => Response/ApiSummaryResourceTypeResponse.php} (97%) rename app/ItemType/SimpleExpense/{ => Response}/ApiSummaryResponse.php (98%) rename app/ItemType/SimpleItem/{ => AllowedValue}/AllowedValue.php (89%) rename app/ItemType/SimpleItem/{ => AllowedValue}/ResourceTypeAllowedValue.php (89%) rename app/ItemType/SimpleItem/{ResourceTypeApiResponse.php => Response/ApiResourceTypeResponse.php} (90%) rename app/ItemType/SimpleItem/{ => Response}/ApiResponse.php (96%) rename app/ItemType/SimpleItem/{SummaryResourceTypeApiResponse.php => Response/ApiSummaryResourceTypeResponse.php} (94%) rename app/ItemType/SimpleItem/{ => Response}/ApiSummaryResponse.php (96%) rename app/Option/{ => Auth}/Check.php (88%) rename app/Option/{ => Auth}/CreateNewPassword.php (90%) rename app/Option/{ => Auth}/CreatePassword.php (90%) rename app/Option/{ => Auth}/ForgotPassword.php (90%) rename app/Option/{ => Auth}/Login.php (89%) rename app/Option/{ => Auth}/Register.php (89%) rename app/Option/{ => Auth}/UpdatePassword.php (91%) rename app/Option/{ => Auth}/UpdateProfile.php (91%) rename app/Option/{ => Auth}/User.php (90%) diff --git a/app/Entity/Api.php b/app/Entity/Api.php deleted file mode 100644 index aca8f416..00000000 --- a/app/Entity/Api.php +++ /dev/null @@ -1,39 +0,0 @@ -create()->response(); } @@ -249,7 +249,7 @@ public function forgotPassword(Request $request): Http\JsonResponse public function optionsForgotPassword(): Http\JsonResponse { - $response = new \App\Option\ForgotPassword([]); + $response = new \App\Option\Auth\ForgotPassword([]); return $response->create()->response(); } @@ -500,7 +500,7 @@ public function user(): Http\JsonResponse public function optionsUser(): Http\JsonResponse { - $response = new \App\Option\User(['view'=> $this->user_id !== null]); + $response = new \App\Option\Auth\User(['view'=> $this->user_id !== null]); return $response->create()->response(); } diff --git a/app/Http/Controllers/ResourceTypeItemView.php b/app/Http/Controllers/ResourceTypeItemView.php index 75cacce6..d278b9d6 100644 --- a/app/Http/Controllers/ResourceTypeItemView.php +++ b/app/Http/Controllers/ResourceTypeItemView.php @@ -26,7 +26,7 @@ public function index(string $resource_type_id): JsonResponse $collection_class = $entity->resourceTypeItemCollectionClass(); /** - * @var $collection \App\ItemType\ResourceTypeApiResponse + * @var $collection \App\ItemType\ApiResourceTypeResponse */ $collection = new $collection_class( (int) $resource_type_id, diff --git a/app/ItemType/AllocatedExpense/AllowedValue.php b/app/ItemType/AllocatedExpense/AllowedValue/AllowedValue.php similarity index 91% rename from app/ItemType/AllocatedExpense/AllowedValue.php rename to app/ItemType/AllocatedExpense/AllowedValue/AllowedValue.php index 39a572b0..d8ff253f 100644 --- a/app/ItemType/AllocatedExpense/AllowedValue.php +++ b/app/ItemType/AllocatedExpense/AllowedValue/AllowedValue.php @@ -1,8 +1,9 @@ * @copyright Dean Blackborough 2018-2022 @@ -68,9 +70,9 @@ public function setPaginationStatus( $this->pagination = true; if ($override === false) { - $this->pagination_parameters = $this->api_config->paginationParameters(); + $this->pagination_parameters = $this->paginationParameters(); } else { - $this->pagination_parameters = $this->api_config->paginationParametersAllowingEntireCollection(); + $this->pagination_parameters = $this->paginationParametersAllowingEntireCollection(); } } @@ -126,9 +128,9 @@ protected function mergeAndLocalise(): void foreach ( array_merge_recursive( $this->pagination_parameters, - ($this->sortable === true ? $this->api_config->sortParameter() : []), - ($this->searchable === true ? $this->api_config->searchParameter() : []), - ($this->filterable === true ? $this->api_config->filterParameter() : []), + ($this->sortable === true ? $this->sortParameter() : []), + ($this->searchable === true ? $this->searchParameter() : []), + ($this->filterable === true ? $this->filterParameter() : []), $this->parameters, $this->dynamic_parameters ) @@ -162,4 +164,29 @@ public function option(): array 'parameters' => $this->parameters_after_localisation ]; } + + protected function filterParameter(): array + { + return LaravelConfig::get('api.app.filterable-parameters', []); + } + + protected function paginationParameters(): array + { + return LaravelConfig::get('api.app.pagination-parameters', []); + } + + protected function paginationParametersAllowingEntireCollection(): array + { + return LaravelConfig::get('api.app.pagination-parameters-including-collection', []); + } + + protected function searchParameter(): array + { + return LaravelConfig::get('api.app.searchable-parameters', []); + } + + protected function sortParameter(): array + { + return LaravelConfig::get('api.app.sortable-parameters', []); + } } diff --git a/app/Method/Method.php b/app/Method/Method.php index f206d2c8..3247d622 100644 --- a/app/Method/Method.php +++ b/app/Method/Method.php @@ -3,8 +3,6 @@ namespace App\Method; -use App\Entity\Api; - /** * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 @@ -18,15 +16,11 @@ abstract class Method protected string $description; - protected Api $api_config; - public function __construct() { $this->authentication = false; $this->authenticated = false; $this->description = ''; - - $this->api_config = new Api(); } public function setAuthenticationRequirement( diff --git a/app/Option/Check.php b/app/Option/Auth/Check.php similarity index 88% rename from app/Option/Check.php rename to app/Option/Auth/Check.php index b31e8ad7..ab81a4f0 100644 --- a/app/Option/Check.php +++ b/app/Option/Auth/Check.php @@ -1,7 +1,9 @@ Date: Sat, 15 Jan 2022 15:27:40 +0000 Subject: [PATCH 22/73] Refactoring - Renamed all the allowed values classes, don't duplicate namespace --- .../{ResourceTypeAllowedValue.php => Item.php} | 11 ++++++----- .../{AllowedValue.php => ResourceTypeItem.php} | 8 +++----- app/ItemType/AllocatedExpense/Item.php | 7 +++---- .../Game/AllowedValue/{AllowedValue.php => Item.php} | 9 ++++----- ...ourceTypeAllowedValue.php => ResourceTypeItem.php} | 6 +++--- app/ItemType/Game/Item.php | 7 +++---- .../{ResourceTypeAllowedValue.php => Item.php} | 11 ++++++----- .../{AllowedValue.php => ResourceTypeItem.php} | 8 +++----- app/ItemType/SimpleExpense/Item.php | 7 +++---- .../{ResourceTypeAllowedValue.php => Item.php} | 11 ++++++----- .../{AllowedValue.php => ResourceTypeItem.php} | 8 +++----- app/ItemType/SimpleItem/Item.php | 7 +++---- 12 files changed, 46 insertions(+), 54 deletions(-) rename app/ItemType/AllocatedExpense/AllowedValue/{ResourceTypeAllowedValue.php => Item.php} (75%) rename app/ItemType/AllocatedExpense/AllowedValue/{AllowedValue.php => ResourceTypeItem.php} (82%) rename app/ItemType/Game/AllowedValue/{AllowedValue.php => Item.php} (89%) rename app/ItemType/Game/AllowedValue/{ResourceTypeAllowedValue.php => ResourceTypeItem.php} (90%) rename app/ItemType/SimpleExpense/AllowedValue/{ResourceTypeAllowedValue.php => Item.php} (72%) rename app/ItemType/SimpleExpense/AllowedValue/{AllowedValue.php => ResourceTypeItem.php} (80%) rename app/ItemType/SimpleItem/AllowedValue/{ResourceTypeAllowedValue.php => Item.php} (64%) rename app/ItemType/SimpleItem/AllowedValue/{AllowedValue.php => ResourceTypeItem.php} (74%) diff --git a/app/ItemType/AllocatedExpense/AllowedValue/ResourceTypeAllowedValue.php b/app/ItemType/AllocatedExpense/AllowedValue/Item.php similarity index 75% rename from app/ItemType/AllocatedExpense/AllowedValue/ResourceTypeAllowedValue.php rename to app/ItemType/AllocatedExpense/AllowedValue/Item.php index 89cf12d6..9de965b3 100644 --- a/app/ItemType/AllocatedExpense/AllowedValue/ResourceTypeAllowedValue.php +++ b/app/ItemType/AllocatedExpense/AllowedValue/Item.php @@ -3,27 +3,28 @@ namespace App\ItemType\AllocatedExpense\AllowedValue; -use App\ItemType\AllocatedExpense\Item; -use App\ItemType\ResourceTypeAllowedValue as BaseResourceTypeAllowedValue; +use App\ItemType\AllowedValue; -class ResourceTypeAllowedValue extends BaseResourceTypeAllowedValue +class Item extends AllowedValue { public function __construct( int $resource_type_id, + int $resource_id, array $viewable_resource_types ) { parent::__construct( $resource_type_id, + $resource_id, $viewable_resource_types ); - $this->entity = new Item(); + $this->entity = new \App\ItemType\AllocatedExpense\Item(); $this->setAllowedValueFields(); } - public function fetch(): BaseResourceTypeAllowedValue + public function fetch(): AllowedValue { $this->fetchValuesForYear(); diff --git a/app/ItemType/AllocatedExpense/AllowedValue/AllowedValue.php b/app/ItemType/AllocatedExpense/AllowedValue/ResourceTypeItem.php similarity index 82% rename from app/ItemType/AllocatedExpense/AllowedValue/AllowedValue.php rename to app/ItemType/AllocatedExpense/AllowedValue/ResourceTypeItem.php index d8ff253f..c1850594 100644 --- a/app/ItemType/AllocatedExpense/AllowedValue/AllowedValue.php +++ b/app/ItemType/AllocatedExpense/AllowedValue/ResourceTypeItem.php @@ -4,19 +4,17 @@ namespace App\ItemType\AllocatedExpense\AllowedValue; use App\ItemType\AllocatedExpense\Item; -use App\ItemType\AllowedValue as BaseAllowedValue; +use App\ItemType\ResourceTypeAllowedValue; -class AllowedValue extends BaseAllowedValue +class ResourceTypeItem extends ResourceTypeAllowedValue { public function __construct( int $resource_type_id, - int $resource_id, array $viewable_resource_types ) { parent::__construct( $resource_type_id, - $resource_id, $viewable_resource_types ); @@ -25,7 +23,7 @@ public function __construct( $this->setAllowedValueFields(); } - public function fetch(): BaseAllowedValue + public function fetch(): ResourceTypeAllowedValue { $this->fetchValuesForYear(); diff --git a/app/ItemType/AllocatedExpense/Item.php b/app/ItemType/AllocatedExpense/Item.php index d6e89cbc..bc746874 100644 --- a/app/ItemType/AllocatedExpense/Item.php +++ b/app/ItemType/AllocatedExpense/Item.php @@ -4,8 +4,7 @@ namespace App\ItemType\AllocatedExpense; use App\AllowedValue\Currency; -use App\ItemType\AllocatedExpense\AllowedValue\AllowedValue; -use App\ItemType\AllocatedExpense\AllowedValue\ResourceTypeAllowedValue; +use App\ItemType\AllocatedExpense\AllowedValue\ResourceTypeItem; use App\ItemType\AllocatedExpense\Response\ApiResourceTypeResponse; use App\ItemType\AllocatedExpense\Response\ApiResponse; use App\ItemType\AllocatedExpense\Response\ApiSummaryResourceTypeResponse; @@ -155,11 +154,11 @@ public function resourceTypeItemCollectionClass(): string protected function allowedValuesItemCollectionClass(): string { - return AllowedValue::class; + return AllowedValue\Item::class; } protected function allowedValuesResourceTypeItemCollectionClass(): string { - return ResourceTypeAllowedValue::class; + return ResourceTypeItem::class; } } diff --git a/app/ItemType/Game/AllowedValue/AllowedValue.php b/app/ItemType/Game/AllowedValue/Item.php similarity index 89% rename from app/ItemType/Game/AllowedValue/AllowedValue.php rename to app/ItemType/Game/AllowedValue/Item.php index 764f691e..f97b6023 100644 --- a/app/ItemType/Game/AllowedValue/AllowedValue.php +++ b/app/ItemType/Game/AllowedValue/Item.php @@ -3,12 +3,11 @@ namespace App\ItemType\Game\AllowedValue; -use App\ItemType\AllowedValue as BaseAllowedValue; -use App\ItemType\Game\Item; +use App\ItemType\AllowedValue; use App\Models\Category; use function trans; -class AllowedValue extends BaseAllowedValue +class Item extends AllowedValue { public function __construct( int $resource_type_id, @@ -22,12 +21,12 @@ public function __construct( $viewable_resource_types ); - $this->entity = new Item(); + $this->entity = new \App\ItemType\Game\Item(); $this->setAllowedValueFields(); } - public function fetch(): BaseAllowedValue + public function fetch(): AllowedValue { $this->fetchValuesForWinner(); diff --git a/app/ItemType/Game/AllowedValue/ResourceTypeAllowedValue.php b/app/ItemType/Game/AllowedValue/ResourceTypeItem.php similarity index 90% rename from app/ItemType/Game/AllowedValue/ResourceTypeAllowedValue.php rename to app/ItemType/Game/AllowedValue/ResourceTypeItem.php index dc1dae8d..55740a9c 100644 --- a/app/ItemType/Game/AllowedValue/ResourceTypeAllowedValue.php +++ b/app/ItemType/Game/AllowedValue/ResourceTypeItem.php @@ -4,11 +4,11 @@ namespace App\ItemType\Game\AllowedValue; use App\ItemType\Game\Item; -use App\ItemType\ResourceTypeAllowedValue as BaseResourceTypeAllowedValue; +use App\ItemType\ResourceTypeAllowedValue; use App\Models\Category; use function trans; -class ResourceTypeAllowedValue extends BaseResourceTypeAllowedValue +class ResourceTypeItem extends ResourceTypeAllowedValue { public function __construct( int $resource_type_id, @@ -25,7 +25,7 @@ public function __construct( $this->setAllowedValueFields(); } - public function fetch(): BaseResourceTypeAllowedValue + public function fetch(): ResourceTypeAllowedValue { $this->fetchValuesForWinner(); diff --git a/app/ItemType/Game/Item.php b/app/ItemType/Game/Item.php index 8def3546..609ab669 100644 --- a/app/ItemType/Game/Item.php +++ b/app/ItemType/Game/Item.php @@ -4,8 +4,7 @@ namespace App\ItemType\Game; use App\AllowedValue\Winner; -use App\ItemType\Game\AllowedValue\AllowedValue; -use App\ItemType\Game\AllowedValue\ResourceTypeAllowedValue; +use App\ItemType\Game\AllowedValue\ResourceTypeItem; use App\ItemType\Game\Response\ApiResourceTypeResponse; use App\ItemType\Game\Response\ApiResponse; use App\ItemType\Game\Response\ApiSummaryResourceTypeResponse; @@ -142,11 +141,11 @@ public function resourceTypeItemCollectionClass(): string protected function allowedValuesItemCollectionClass(): string { - return AllowedValue::class; + return AllowedValue\Item::class; } protected function allowedValuesResourceTypeItemCollectionClass(): string { - return ResourceTypeAllowedValue::class; + return ResourceTypeItem::class; } } diff --git a/app/ItemType/SimpleExpense/AllowedValue/ResourceTypeAllowedValue.php b/app/ItemType/SimpleExpense/AllowedValue/Item.php similarity index 72% rename from app/ItemType/SimpleExpense/AllowedValue/ResourceTypeAllowedValue.php rename to app/ItemType/SimpleExpense/AllowedValue/Item.php index e5bf4bad..7f10bc5f 100644 --- a/app/ItemType/SimpleExpense/AllowedValue/ResourceTypeAllowedValue.php +++ b/app/ItemType/SimpleExpense/AllowedValue/Item.php @@ -3,27 +3,28 @@ namespace App\ItemType\SimpleExpense\AllowedValue; -use App\ItemType\ResourceTypeAllowedValue as BaseResourceTypeAllowedValue; -use App\ItemType\SimpleExpense\Item; +use App\ItemType\AllowedValue; -class ResourceTypeAllowedValue extends BaseResourceTypeAllowedValue +class Item extends AllowedValue { public function __construct( int $resource_type_id, + int $resource_id, array $viewable_resource_types ) { parent::__construct( $resource_type_id, + $resource_id, $viewable_resource_types ); - $this->entity = new Item(); + $this->entity = new \App\ItemType\SimpleExpense\Item(); $this->setAllowedValueFields(); } - public function fetch(): BaseResourceTypeAllowedValue + public function fetch(): AllowedValue { $this->fetchValuesForCategory(); diff --git a/app/ItemType/SimpleExpense/AllowedValue/AllowedValue.php b/app/ItemType/SimpleExpense/AllowedValue/ResourceTypeItem.php similarity index 80% rename from app/ItemType/SimpleExpense/AllowedValue/AllowedValue.php rename to app/ItemType/SimpleExpense/AllowedValue/ResourceTypeItem.php index 91792e22..2c8e6c52 100644 --- a/app/ItemType/SimpleExpense/AllowedValue/AllowedValue.php +++ b/app/ItemType/SimpleExpense/AllowedValue/ResourceTypeItem.php @@ -3,20 +3,18 @@ namespace App\ItemType\SimpleExpense\AllowedValue; -use App\ItemType\AllowedValue as BaseAllowedValue; +use App\ItemType\ResourceTypeAllowedValue; use App\ItemType\SimpleExpense\Item; -class AllowedValue extends BaseAllowedValue +class ResourceTypeItem extends ResourceTypeAllowedValue { public function __construct( int $resource_type_id, - int $resource_id, array $viewable_resource_types ) { parent::__construct( $resource_type_id, - $resource_id, $viewable_resource_types ); @@ -25,7 +23,7 @@ public function __construct( $this->setAllowedValueFields(); } - public function fetch(): BaseAllowedValue + public function fetch(): ResourceTypeAllowedValue { $this->fetchValuesForCategory(); diff --git a/app/ItemType/SimpleExpense/Item.php b/app/ItemType/SimpleExpense/Item.php index ffe6f14f..26da9cb2 100644 --- a/app/ItemType/SimpleExpense/Item.php +++ b/app/ItemType/SimpleExpense/Item.php @@ -5,8 +5,7 @@ use App\AllowedValue\Currency; use App\ItemType\ItemType; -use App\ItemType\SimpleExpense\AllowedValue\AllowedValue; -use App\ItemType\SimpleExpense\AllowedValue\ResourceTypeAllowedValue; +use App\ItemType\SimpleExpense\AllowedValue\ResourceTypeItem; use App\ItemType\SimpleExpense\Response\ApiResourceTypeResponse; use App\ItemType\SimpleExpense\Response\ApiResponse; use App\ItemType\SimpleExpense\Response\ApiSummaryResourceTypeResponse; @@ -121,11 +120,11 @@ public function resourceTypeItemCollectionClass(): string protected function allowedValuesItemCollectionClass(): string { - return AllowedValue::class; + return AllowedValue\Item::class; } protected function allowedValuesResourceTypeItemCollectionClass(): string { - return ResourceTypeAllowedValue::class; + return ResourceTypeItem::class; } } diff --git a/app/ItemType/SimpleItem/AllowedValue/ResourceTypeAllowedValue.php b/app/ItemType/SimpleItem/AllowedValue/Item.php similarity index 64% rename from app/ItemType/SimpleItem/AllowedValue/ResourceTypeAllowedValue.php rename to app/ItemType/SimpleItem/AllowedValue/Item.php index 09a30208..a3aec28e 100644 --- a/app/ItemType/SimpleItem/AllowedValue/ResourceTypeAllowedValue.php +++ b/app/ItemType/SimpleItem/AllowedValue/Item.php @@ -3,27 +3,28 @@ namespace App\ItemType\SimpleItem\AllowedValue; -use App\ItemType\ResourceTypeAllowedValue as BaseResourceTypeAllowedValue; -use App\ItemType\SimpleItem\Item; +use App\ItemType\AllowedValue; -class ResourceTypeAllowedValue extends BaseResourceTypeAllowedValue +class Item extends AllowedValue { public function __construct( int $resource_type_id, + int $resource_id, array $viewable_resource_types ) { parent::__construct( $resource_type_id, + $resource_id, $viewable_resource_types ); - $this->entity = new Item(); + $this->entity = new \App\ItemType\SimpleItem\Item(); $this->setAllowedValueFields(); } - public function fetch(): BaseResourceTypeAllowedValue + public function fetch(): AllowedValue { return $this; } diff --git a/app/ItemType/SimpleItem/AllowedValue/AllowedValue.php b/app/ItemType/SimpleItem/AllowedValue/ResourceTypeItem.php similarity index 74% rename from app/ItemType/SimpleItem/AllowedValue/AllowedValue.php rename to app/ItemType/SimpleItem/AllowedValue/ResourceTypeItem.php index be9e5b26..c9ec8854 100644 --- a/app/ItemType/SimpleItem/AllowedValue/AllowedValue.php +++ b/app/ItemType/SimpleItem/AllowedValue/ResourceTypeItem.php @@ -3,20 +3,18 @@ namespace App\ItemType\SimpleItem\AllowedValue; -use App\ItemType\AllowedValue as BaseAllowedValue; +use App\ItemType\ResourceTypeAllowedValue; use App\ItemType\SimpleItem\Item; -class AllowedValue extends BaseAllowedValue +class ResourceTypeItem extends ResourceTypeAllowedValue { public function __construct( int $resource_type_id, - int $resource_id, array $viewable_resource_types ) { parent::__construct( $resource_type_id, - $resource_id, $viewable_resource_types ); @@ -25,7 +23,7 @@ public function __construct( $this->setAllowedValueFields(); } - public function fetch(): BaseAllowedValue + public function fetch(): ResourceTypeAllowedValue { return $this; } diff --git a/app/ItemType/SimpleItem/Item.php b/app/ItemType/SimpleItem/Item.php index fbbd4057..295a5907 100644 --- a/app/ItemType/SimpleItem/Item.php +++ b/app/ItemType/SimpleItem/Item.php @@ -4,8 +4,7 @@ namespace App\ItemType\SimpleItem; use App\ItemType\ItemType; -use App\ItemType\SimpleItem\AllowedValue\AllowedValue; -use App\ItemType\SimpleItem\AllowedValue\ResourceTypeAllowedValue; +use App\ItemType\SimpleItem\AllowedValue\ResourceTypeItem; use App\ItemType\SimpleItem\Response\ApiResourceTypeResponse; use App\ItemType\SimpleItem\Response\ApiResponse; use App\ItemType\SimpleItem\Response\ApiSummaryResourceTypeResponse; @@ -120,11 +119,11 @@ public function resourceTypeItemCollectionClass(): string protected function allowedValuesItemCollectionClass(): string { - return AllowedValue::class; + return AllowedValue\Item::class; } protected function allowedValuesResourceTypeItemCollectionClass(): string { - return ResourceTypeAllowedValue::class; + return ResourceTypeItem::class; } } From c0fe7f74b04956573660897a99c4fa98b7966a6f Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Sat, 15 Jan 2022 15:52:39 +0000 Subject: [PATCH 23/73] Refacoring - Rename the response classes --- .../ApiResourceTypeResponse.php | 2 +- .../ApiSummaryResourceTypeResponse.php | 2 +- .../ApiResponse.php => ApiResponse/Item.php} | 9 ++++----- .../Summary.php} | 4 ++-- app/ItemType/AllocatedExpense/Item.php | 11 +++++------ .../ApiResourceTypeResponse.php | 2 +- .../ApiSummaryResourceTypeResponse.php | 2 +- .../ApiResponse.php => ApiResponse/Item.php} | 9 ++++----- .../Summary.php} | 4 ++-- app/ItemType/Game/Item.php | 11 +++++------ .../ApiResourceTypeResponse.php | 2 +- .../ApiSummaryResourceTypeResponse.php | 2 +- .../ApiResponse.php => ApiResponse/Item.php} | 9 ++++----- .../Summary.php} | 4 ++-- app/ItemType/SimpleExpense/Item.php | 11 +++++------ .../ApiResourceTypeResponse.php | 2 +- .../ApiSummaryResourceTypeResponse.php | 2 +- .../ApiResponse.php => ApiResponse/Item.php} | 9 ++++----- .../Summary.php} | 4 ++-- app/ItemType/SimpleItem/Item.php | 11 +++++------ 20 files changed, 52 insertions(+), 60 deletions(-) rename app/ItemType/AllocatedExpense/{Response => ApiResponse}/ApiResourceTypeResponse.php (98%) rename app/ItemType/AllocatedExpense/{Response => ApiResponse}/ApiSummaryResourceTypeResponse.php (99%) rename app/ItemType/AllocatedExpense/{Response/ApiResponse.php => ApiResponse/Item.php} (93%) rename app/ItemType/AllocatedExpense/{Response/ApiSummaryResponse.php => ApiResponse/Summary.php} (99%) rename app/ItemType/Game/{Response => ApiResponse}/ApiResourceTypeResponse.php (98%) rename app/ItemType/Game/{Response => ApiResponse}/ApiSummaryResourceTypeResponse.php (99%) rename app/ItemType/Game/{Response/ApiResponse.php => ApiResponse/Item.php} (93%) rename app/ItemType/Game/{Response/ApiSummaryResponse.php => ApiResponse/Summary.php} (96%) rename app/ItemType/SimpleExpense/{Response => ApiResponse}/ApiResourceTypeResponse.php (98%) rename app/ItemType/SimpleExpense/{Response => ApiResponse}/ApiSummaryResourceTypeResponse.php (99%) rename app/ItemType/SimpleExpense/{Response/ApiResponse.php => ApiResponse/Item.php} (93%) rename app/ItemType/SimpleExpense/{Response/ApiSummaryResponse.php => ApiResponse/Summary.php} (98%) rename app/ItemType/SimpleItem/{Response => ApiResponse}/ApiResourceTypeResponse.php (98%) rename app/ItemType/SimpleItem/{Response => ApiResponse}/ApiSummaryResourceTypeResponse.php (98%) rename app/ItemType/SimpleItem/{Response/ApiResponse.php => ApiResponse/Item.php} (93%) rename app/ItemType/SimpleItem/{Response/ApiSummaryResponse.php => ApiResponse/Summary.php} (96%) diff --git a/app/ItemType/AllocatedExpense/Response/ApiResourceTypeResponse.php b/app/ItemType/AllocatedExpense/ApiResponse/ApiResourceTypeResponse.php similarity index 98% rename from app/ItemType/AllocatedExpense/Response/ApiResourceTypeResponse.php rename to app/ItemType/AllocatedExpense/ApiResponse/ApiResourceTypeResponse.php index 0a608703..c98bf262 100644 --- a/app/ItemType/AllocatedExpense/Response/ApiResourceTypeResponse.php +++ b/app/ItemType/AllocatedExpense/ApiResponse/ApiResourceTypeResponse.php @@ -1,7 +1,7 @@ cache_control->isRequestCacheable() === false || $cache_collection->valid() === false ) { - $model = new Item(); + $model = new \App\ItemType\AllocatedExpense\Models\Item(); $this->fetchAllRequestParameters( new \App\ItemType\AllocatedExpense\Item() @@ -92,7 +91,7 @@ public function showResponse(int $item_id): JsonResponse new \App\ItemType\AllocatedExpense\Item() ); - $item = (new Item())->single( + $item = (new \App\ItemType\AllocatedExpense\Models\Item())->single( $this->resource_type_id, $this->resource_id, $item_id, diff --git a/app/ItemType/AllocatedExpense/Response/ApiSummaryResponse.php b/app/ItemType/AllocatedExpense/ApiResponse/Summary.php similarity index 99% rename from app/ItemType/AllocatedExpense/Response/ApiSummaryResponse.php rename to app/ItemType/AllocatedExpense/ApiResponse/Summary.php index 6177441f..2a38e547 100644 --- a/app/ItemType/AllocatedExpense/Response/ApiSummaryResponse.php +++ b/app/ItemType/AllocatedExpense/ApiResponse/Summary.php @@ -1,6 +1,6 @@ cache_control->isRequestCacheable() === false || $cache_collection->valid() === false ) { - $model = new Item(); + $model = new \App\ItemType\Game\Models\Item(); $this->fetchAllRequestParameters( new \App\ItemType\Game\Item() @@ -88,7 +87,7 @@ public function showResponse(int $item_id): JsonResponse new \App\ItemType\Game\Item() ); - $item = (new Item())->single( + $item = (new \App\ItemType\Game\Models\Item())->single( $this->resource_type_id, $this->resource_id, $item_id, diff --git a/app/ItemType/Game/Response/ApiSummaryResponse.php b/app/ItemType/Game/ApiResponse/Summary.php similarity index 96% rename from app/ItemType/Game/Response/ApiSummaryResponse.php rename to app/ItemType/Game/ApiResponse/Summary.php index 8ee5d2b8..7a15d0c7 100644 --- a/app/ItemType/Game/Response/ApiSummaryResponse.php +++ b/app/ItemType/Game/ApiResponse/Summary.php @@ -1,6 +1,6 @@ cache_control->isRequestCacheable() === false || $cache_collection->valid() === false ) { - $model = new Item(); + $model = new \App\ItemType\SimpleExpense\Models\Item(); $this->fetchAllRequestParameters( new \App\ItemType\SimpleExpense\Item() @@ -88,7 +87,7 @@ public function showResponse(int $item_id): JsonResponse new \App\ItemType\SimpleExpense\Item() ); - $item = (new Item())->single( + $item = (new \App\ItemType\SimpleExpense\Models\Item())->single( $this->resource_type_id, $this->resource_id, $item_id, diff --git a/app/ItemType/SimpleExpense/Response/ApiSummaryResponse.php b/app/ItemType/SimpleExpense/ApiResponse/Summary.php similarity index 98% rename from app/ItemType/SimpleExpense/Response/ApiSummaryResponse.php rename to app/ItemType/SimpleExpense/ApiResponse/Summary.php index eb3fc79f..a42b1c12 100644 --- a/app/ItemType/SimpleExpense/Response/ApiSummaryResponse.php +++ b/app/ItemType/SimpleExpense/ApiResponse/Summary.php @@ -1,6 +1,6 @@ cache_control->isRequestCacheable() === false || $cache_collection->valid() === false ) { - $model = new Item(); + $model = new \App\ItemType\SimpleItem\Models\Item(); $this->fetchAllRequestParameters( new \App\ItemType\SimpleItem\Item() @@ -87,7 +86,7 @@ public function showResponse(int $item_id): JsonResponse new \App\ItemType\SimpleItem\Item() ); - $item = (new Item())->single( + $item = (new \App\ItemType\SimpleItem\Models\Item())->single( $this->resource_type_id, $this->resource_id, $item_id, diff --git a/app/ItemType/SimpleItem/Response/ApiSummaryResponse.php b/app/ItemType/SimpleItem/ApiResponse/Summary.php similarity index 96% rename from app/ItemType/SimpleItem/Response/ApiSummaryResponse.php rename to app/ItemType/SimpleItem/ApiResponse/Summary.php index b4db2ba3..6c00ce4b 100644 --- a/app/ItemType/SimpleItem/Response/ApiSummaryResponse.php +++ b/app/ItemType/SimpleItem/ApiResponse/Summary.php @@ -1,6 +1,6 @@ Date: Sat, 15 Jan 2022 16:12:07 +0000 Subject: [PATCH 24/73] Refactoring - Rename all the response classes --- ...ResourceTypeResponse.php => ResourceTypeItem.php} | 5 ++--- ...eTypeResponse.php => SummaryResourceTypeItem.php} | 5 ++--- app/ItemType/AllocatedExpense/Item.php | 12 ++++-------- ...urceTypeModel.php => SummaryResourceTypeItem.php} | 2 +- ...ResourceTypeResponse.php => ResourceTypeItem.php} | 5 ++--- ...eTypeResponse.php => SummaryResourceTypeItem.php} | 5 ++--- app/ItemType/Game/Item.php | 8 +++----- ...ResourceTypeResponse.php => ResourceTypeItem.php} | 5 ++--- ...eTypeResponse.php => SummaryResourceTypeItem.php} | 5 ++--- app/ItemType/SimpleExpense/Item.php | 12 ++++-------- ...ResourceTypeResponse.php => ResourceTypeItem.php} | 5 ++--- ...eTypeResponse.php => SummaryResourceTypeItem.php} | 5 ++--- app/ItemType/SimpleItem/Item.php | 12 ++++-------- 13 files changed, 32 insertions(+), 54 deletions(-) rename app/ItemType/AllocatedExpense/ApiResponse/{ApiResourceTypeResponse.php => ResourceTypeItem.php} (94%) rename app/ItemType/AllocatedExpense/ApiResponse/{ApiSummaryResourceTypeResponse.php => SummaryResourceTypeItem.php} (98%) rename app/ItemType/AllocatedExpense/Models/{SummaryResourceTypeModel.php => SummaryResourceTypeItem.php} (99%) rename app/ItemType/Game/ApiResponse/{ApiResourceTypeResponse.php => ResourceTypeItem.php} (94%) rename app/ItemType/Game/ApiResponse/{ApiSummaryResourceTypeResponse.php => SummaryResourceTypeItem.php} (95%) rename app/ItemType/SimpleExpense/ApiResponse/{ApiResourceTypeResponse.php => ResourceTypeItem.php} (93%) rename app/ItemType/SimpleExpense/ApiResponse/{ApiSummaryResourceTypeResponse.php => SummaryResourceTypeItem.php} (97%) rename app/ItemType/SimpleItem/ApiResponse/{ApiResourceTypeResponse.php => ResourceTypeItem.php} (93%) rename app/ItemType/SimpleItem/ApiResponse/{ApiSummaryResourceTypeResponse.php => SummaryResourceTypeItem.php} (95%) diff --git a/app/ItemType/AllocatedExpense/ApiResponse/ApiResourceTypeResponse.php b/app/ItemType/AllocatedExpense/ApiResponse/ResourceTypeItem.php similarity index 94% rename from app/ItemType/AllocatedExpense/ApiResponse/ApiResourceTypeResponse.php rename to app/ItemType/AllocatedExpense/ApiResponse/ResourceTypeItem.php index c98bf262..c12d921e 100644 --- a/app/ItemType/AllocatedExpense/ApiResponse/ApiResourceTypeResponse.php +++ b/app/ItemType/AllocatedExpense/ApiResponse/ResourceTypeItem.php @@ -4,14 +4,13 @@ namespace App\ItemType\AllocatedExpense\ApiResponse; use App\ItemType\AllocatedExpense\Item; -use App\ItemType\AllocatedExpense\Models\ResourceTypeItem; use App\ItemType\AllocatedExpense\Transformers\ResourceTypeTransformer as Transformer; use App\ItemType\ApiResourceTypeResponse as BaseResourceTypeResponse; use Illuminate\Http\JsonResponse; use function request; use function response; -class ApiResourceTypeResponse extends BaseResourceTypeResponse +class ResourceTypeItem extends BaseResourceTypeResponse { public function response(): JsonResponse { @@ -28,7 +27,7 @@ public function response(): JsonResponse $this->cache_control->isRequestCacheable() === false || $cache_collection->valid() === false ) { - $model = new ResourceTypeItem(); + $model = new \App\ItemType\AllocatedExpense\Models\ResourceTypeItem(); $this->fetchAllRequestParameters( new Item() diff --git a/app/ItemType/AllocatedExpense/ApiResponse/ApiSummaryResourceTypeResponse.php b/app/ItemType/AllocatedExpense/ApiResponse/SummaryResourceTypeItem.php similarity index 98% rename from app/ItemType/AllocatedExpense/ApiResponse/ApiSummaryResourceTypeResponse.php rename to app/ItemType/AllocatedExpense/ApiResponse/SummaryResourceTypeItem.php index 2dfcc28e..2ff3152f 100644 --- a/app/ItemType/AllocatedExpense/ApiResponse/ApiSummaryResourceTypeResponse.php +++ b/app/ItemType/AllocatedExpense/ApiResponse/SummaryResourceTypeItem.php @@ -3,7 +3,6 @@ namespace App\ItemType\AllocatedExpense\ApiResponse; use App\ItemType\AllocatedExpense\Item; -use App\ItemType\AllocatedExpense\Models\SummaryResourceTypeModel; use App\ItemType\AllocatedExpense\Transformers\SummaryTransformer; use App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByCategory; use App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByMonth; @@ -16,7 +15,7 @@ use function request; use function response; -class ApiSummaryResourceTypeResponse extends BaseSummaryResourceTypeResponse +class SummaryResourceTypeItem extends BaseSummaryResourceTypeResponse { public function __construct( int $resource_type_id, @@ -32,7 +31,7 @@ public function __construct( $this->setUpCache(); - $this->model = new SummaryResourceTypeModel(); + $this->model = new \App\ItemType\AllocatedExpense\Models\SummaryResourceTypeItem(); $this->shortCircuit(); // Skip working out which for obvious routes diff --git a/app/ItemType/AllocatedExpense/Item.php b/app/ItemType/AllocatedExpense/Item.php index 0835c5af..2e1ad88e 100644 --- a/app/ItemType/AllocatedExpense/Item.php +++ b/app/ItemType/AllocatedExpense/Item.php @@ -4,10 +4,6 @@ namespace App\ItemType\AllocatedExpense; use App\AllowedValue\Currency; -use App\ItemType\AllocatedExpense\AllowedValue\ResourceTypeItem; -use App\ItemType\AllocatedExpense\ApiResponse\ApiResourceTypeResponse; -use App\ItemType\AllocatedExpense\ApiResponse\ApiSummaryResourceTypeResponse; -use App\ItemType\AllocatedExpense\ApiResponse\Summary; use App\ItemType\ItemType; use App\Transformers\Transformer; use App\Request\Hash; @@ -98,12 +94,12 @@ public function model() public function summaryClass(): string { - return Summary::class; + return ApiResponse\Summary::class; } public function resourceTypeSummaryClass(): string { - return ApiSummaryResourceTypeResponse::class; + return ApiResponse\SummaryResourceTypeItem::class; } public function transformer(array $data_to_transform): Transformer @@ -148,7 +144,7 @@ public function viewClass(): string public function resourceTypeItemCollectionClass(): string { - return ApiResourceTypeResponse::class; + return ApiResponse\ResourceTypeItem::class; } protected function allowedValuesItemCollectionClass(): string @@ -158,6 +154,6 @@ protected function allowedValuesItemCollectionClass(): string protected function allowedValuesResourceTypeItemCollectionClass(): string { - return ResourceTypeItem::class; + return AllowedValue\ResourceTypeItem::class; } } diff --git a/app/ItemType/AllocatedExpense/Models/SummaryResourceTypeModel.php b/app/ItemType/AllocatedExpense/Models/SummaryResourceTypeItem.php similarity index 99% rename from app/ItemType/AllocatedExpense/Models/SummaryResourceTypeModel.php rename to app/ItemType/AllocatedExpense/Models/SummaryResourceTypeItem.php index 3016bcb9..14992401 100644 --- a/app/ItemType/AllocatedExpense/Models/SummaryResourceTypeModel.php +++ b/app/ItemType/AllocatedExpense/Models/SummaryResourceTypeItem.php @@ -14,7 +14,7 @@ * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class SummaryResourceTypeModel extends LaravelModel +class SummaryResourceTypeItem extends LaravelModel { protected $guarded = ['id', 'actualised_total', 'created_at', 'updated_at']; protected $table = 'item'; diff --git a/app/ItemType/Game/ApiResponse/ApiResourceTypeResponse.php b/app/ItemType/Game/ApiResponse/ResourceTypeItem.php similarity index 94% rename from app/ItemType/Game/ApiResponse/ApiResourceTypeResponse.php rename to app/ItemType/Game/ApiResponse/ResourceTypeItem.php index 5eb1b988..cc402096 100644 --- a/app/ItemType/Game/ApiResponse/ApiResourceTypeResponse.php +++ b/app/ItemType/Game/ApiResponse/ResourceTypeItem.php @@ -4,14 +4,13 @@ namespace App\ItemType\Game\ApiResponse; use App\ItemType\Game\Item; -use App\ItemType\Game\Models\ResourceTypeItem; use App\ItemType\Game\Transformers\ResourceTypeTransformer as Transformer; use App\ItemType\ApiResourceTypeResponse as BaseResourceTypeResponse; use Illuminate\Http\JsonResponse; use function request; use function response; -class ApiResourceTypeResponse extends BaseResourceTypeResponse +class ResourceTypeItem extends BaseResourceTypeResponse { public function response(): JsonResponse { @@ -24,7 +23,7 @@ public function response(): JsonResponse $this->cache_control->isRequestCacheable() === false || $cache_collection->valid() === false ) { - $model = new ResourceTypeItem(); + $model = new \App\ItemType\Game\Models\ResourceTypeItem(); $this->fetchAllRequestParameters( new Item() diff --git a/app/ItemType/Game/ApiResponse/ApiSummaryResourceTypeResponse.php b/app/ItemType/Game/ApiResponse/SummaryResourceTypeItem.php similarity index 95% rename from app/ItemType/Game/ApiResponse/ApiSummaryResourceTypeResponse.php rename to app/ItemType/Game/ApiResponse/SummaryResourceTypeItem.php index db1b6659..9690a652 100644 --- a/app/ItemType/Game/ApiResponse/ApiSummaryResourceTypeResponse.php +++ b/app/ItemType/Game/ApiResponse/SummaryResourceTypeItem.php @@ -3,7 +3,6 @@ namespace App\ItemType\Game\ApiResponse; use App\ItemType\Game\Item; -use App\ItemType\Game\Models\SummaryResourceTypeModel; use App\ItemType\Game\Transformers\SummaryTransformerByResource; use App\ItemType\ApiSummaryResourceTypeResponse as BaseSummaryResourceTypeResponse; use App\ItemType\Game\Transformers\SummaryTransformer as GameTransformer; @@ -11,7 +10,7 @@ use Illuminate\Http\JsonResponse; use function response; -class ApiSummaryResourceTypeResponse extends BaseSummaryResourceTypeResponse +class SummaryResourceTypeItem extends BaseSummaryResourceTypeResponse { public function __construct( int $resource_type_id, @@ -27,7 +26,7 @@ public function __construct( $this->setUpCache(); - $this->model = new SummaryResourceTypeModel(); + $this->model = new \App\ItemType\Game\Models\SummaryResourceTypeModel(); $this->fetchAllRequestParameters(new Item()); diff --git a/app/ItemType/Game/Item.php b/app/ItemType/Game/Item.php index 9412314b..543adf71 100644 --- a/app/ItemType/Game/Item.php +++ b/app/ItemType/Game/Item.php @@ -5,8 +5,6 @@ use App\AllowedValue\Winner; use App\ItemType\Game\AllowedValue\ResourceTypeItem; -use App\ItemType\Game\ApiResponse\ApiResourceTypeResponse; -use App\ItemType\Game\ApiResponse\ApiSummaryResourceTypeResponse; use App\ItemType\Game\ApiResponse\Summary; use App\ItemType\ItemType; use App\Transformers\Transformer; @@ -120,7 +118,7 @@ public function patchFields(): array public function summaryClass(): string { - return Summary::class; + return ApiResponse\Summary::class; } public function viewClass(): string @@ -130,12 +128,12 @@ public function viewClass(): string public function resourceTypeSummaryClass(): string { - return ApiSummaryResourceTypeResponse::class; + return ApiResponse\SummaryResourceTypeItem::class; } public function resourceTypeItemCollectionClass(): string { - return ApiResourceTypeResponse::class; + return ApiResponse\ResourceTypeItem::class; } protected function allowedValuesItemCollectionClass(): string diff --git a/app/ItemType/SimpleExpense/ApiResponse/ApiResourceTypeResponse.php b/app/ItemType/SimpleExpense/ApiResponse/ResourceTypeItem.php similarity index 93% rename from app/ItemType/SimpleExpense/ApiResponse/ApiResourceTypeResponse.php rename to app/ItemType/SimpleExpense/ApiResponse/ResourceTypeItem.php index b0fd9d5d..e00e1e12 100644 --- a/app/ItemType/SimpleExpense/ApiResponse/ApiResourceTypeResponse.php +++ b/app/ItemType/SimpleExpense/ApiResponse/ResourceTypeItem.php @@ -5,13 +5,12 @@ use App\ItemType\ApiResourceTypeResponse as BaseResourceTypeResponse; use App\ItemType\SimpleExpense\Item; -use App\ItemType\SimpleExpense\Models\ResourceTypeItem; use App\ItemType\SimpleExpense\Transformers\ResourceTypeTransformer as Transformer; use Illuminate\Http\JsonResponse; use function request; use function response; -class ApiResourceTypeResponse extends BaseResourceTypeResponse +class ResourceTypeItem extends BaseResourceTypeResponse { public function response(): JsonResponse { @@ -24,7 +23,7 @@ public function response(): JsonResponse $this->cache_control->isRequestCacheable() === false || $cache_collection->valid() === false ) { - $model = new ResourceTypeItem(); + $model = new \App\ItemType\SimpleExpense\Models\ResourceTypeItem(); $this->fetchAllRequestParameters( new Item() diff --git a/app/ItemType/SimpleExpense/ApiResponse/ApiSummaryResourceTypeResponse.php b/app/ItemType/SimpleExpense/ApiResponse/SummaryResourceTypeItem.php similarity index 97% rename from app/ItemType/SimpleExpense/ApiResponse/ApiSummaryResourceTypeResponse.php rename to app/ItemType/SimpleExpense/ApiResponse/SummaryResourceTypeItem.php index 6856fc5d..75db42e1 100644 --- a/app/ItemType/SimpleExpense/ApiResponse/ApiSummaryResourceTypeResponse.php +++ b/app/ItemType/SimpleExpense/ApiResponse/SummaryResourceTypeItem.php @@ -3,7 +3,6 @@ namespace App\ItemType\SimpleExpense\ApiResponse; use App\ItemType\SimpleExpense\Item; -use App\ItemType\SimpleExpense\Models\SummaryResourceTypeModel; use App\ItemType\SimpleExpense\Transformers\SummaryTransformer; use App\ItemType\SimpleExpense\Transformers\SummaryTransformerByCategory; use App\ItemType\SimpleExpense\Transformers\SummaryTransformerByResource; @@ -13,7 +12,7 @@ use Illuminate\Http\JsonResponse; use function response; -class ApiSummaryResourceTypeResponse extends BaseSummaryResourceTypeResponse +class SummaryResourceTypeItem extends BaseSummaryResourceTypeResponse { public function __construct( int $resource_type_id, @@ -29,7 +28,7 @@ public function __construct( $this->setUpCache(); - $this->model = new SummaryResourceTypeModel(); + $this->model = new \App\ItemType\SimpleExpense\Models\SummaryResourceTypeModel(); $this->fetchAllRequestParameters(new Item()); diff --git a/app/ItemType/SimpleExpense/Item.php b/app/ItemType/SimpleExpense/Item.php index 95c00891..eee421d6 100644 --- a/app/ItemType/SimpleExpense/Item.php +++ b/app/ItemType/SimpleExpense/Item.php @@ -5,10 +5,6 @@ use App\AllowedValue\Currency; use App\ItemType\ItemType; -use App\ItemType\SimpleExpense\AllowedValue\ResourceTypeItem; -use App\ItemType\SimpleExpense\ApiResponse\ApiResourceTypeResponse; -use App\ItemType\SimpleExpense\ApiResponse\ApiSummaryResourceTypeResponse; -use App\ItemType\SimpleExpense\ApiResponse\Summary; use App\Transformers\Transformer; use App\Request\Hash; use App\Request\Validate\Validator; @@ -73,12 +69,12 @@ public function type(): string public function summaryClass(): string { - return Summary::class; + return ApiResponse\Summary::class; } public function resourceTypeSummaryClass(): string { - return ApiSummaryResourceTypeResponse::class; + return ApiResponse\SummaryResourceTypeItem::class; } public function transformer(array $data_to_transform): Transformer @@ -114,7 +110,7 @@ public function viewClass(): string public function resourceTypeItemCollectionClass(): string { - return ApiResourceTypeResponse::class; + return ApiResponse\ResourceTypeItem::class; } protected function allowedValuesItemCollectionClass(): string @@ -124,6 +120,6 @@ protected function allowedValuesItemCollectionClass(): string protected function allowedValuesResourceTypeItemCollectionClass(): string { - return ResourceTypeItem::class; + return AllowedValue\ResourceTypeItem::class; } } diff --git a/app/ItemType/SimpleItem/ApiResponse/ApiResourceTypeResponse.php b/app/ItemType/SimpleItem/ApiResponse/ResourceTypeItem.php similarity index 93% rename from app/ItemType/SimpleItem/ApiResponse/ApiResourceTypeResponse.php rename to app/ItemType/SimpleItem/ApiResponse/ResourceTypeItem.php index c69184bf..2bf09990 100644 --- a/app/ItemType/SimpleItem/ApiResponse/ApiResourceTypeResponse.php +++ b/app/ItemType/SimpleItem/ApiResponse/ResourceTypeItem.php @@ -5,13 +5,12 @@ use App\ItemType\ApiResourceTypeResponse as BaseResourceTypeResponse; use App\ItemType\SimpleItem\Item; -use App\ItemType\SimpleItem\Models\ResourceTypeItem; use App\ItemType\SimpleItem\Transformers\ResourceTypeTransformer as Transformer; use Illuminate\Http\JsonResponse; use function request; use function response; -class ApiResourceTypeResponse extends BaseResourceTypeResponse +class ResourceTypeItem extends BaseResourceTypeResponse { public function response(): JsonResponse { @@ -24,7 +23,7 @@ public function response(): JsonResponse $this->cache_control->isRequestCacheable() === false || $cache_collection->valid() === false ) { - $model = new ResourceTypeItem(); + $model = new \App\ItemType\SimpleItem\Models\ResourceTypeItem(); $this->fetchAllRequestParameters( new Item() diff --git a/app/ItemType/SimpleItem/ApiResponse/ApiSummaryResourceTypeResponse.php b/app/ItemType/SimpleItem/ApiResponse/SummaryResourceTypeItem.php similarity index 95% rename from app/ItemType/SimpleItem/ApiResponse/ApiSummaryResourceTypeResponse.php rename to app/ItemType/SimpleItem/ApiResponse/SummaryResourceTypeItem.php index 94d40423..51196267 100644 --- a/app/ItemType/SimpleItem/ApiResponse/ApiSummaryResourceTypeResponse.php +++ b/app/ItemType/SimpleItem/ApiResponse/SummaryResourceTypeItem.php @@ -3,7 +3,6 @@ namespace App\ItemType\SimpleItem\ApiResponse; use App\ItemType\SimpleItem\Item; -use App\ItemType\SimpleItem\Models\SummaryResourceTypeModel; use App\ItemType\SimpleItem\Transformers\SummaryTransformer; use App\ItemType\SimpleItem\Transformers\SummaryTransformerByResource; use App\ItemType\ApiSummaryResourceTypeResponse as BaseSummaryResourceTypeResponse; @@ -11,7 +10,7 @@ use Illuminate\Http\JsonResponse; use function response; -class ApiSummaryResourceTypeResponse extends BaseSummaryResourceTypeResponse +class SummaryResourceTypeItem extends BaseSummaryResourceTypeResponse { public function __construct( int $resource_type_id, @@ -27,7 +26,7 @@ public function __construct( $this->setUpCache(); - $this->model = new SummaryResourceTypeModel(); + $this->model = new \App\ItemType\SimpleItem\Models\SummaryResourceTypeModel(); $this->fetchAllRequestParameters(new Item()); diff --git a/app/ItemType/SimpleItem/Item.php b/app/ItemType/SimpleItem/Item.php index 716a9534..7aba5366 100644 --- a/app/ItemType/SimpleItem/Item.php +++ b/app/ItemType/SimpleItem/Item.php @@ -4,10 +4,6 @@ namespace App\ItemType\SimpleItem; use App\ItemType\ItemType; -use App\ItemType\SimpleItem\AllowedValue\ResourceTypeItem; -use App\ItemType\SimpleItem\ApiResponse\ApiResourceTypeResponse; -use App\ItemType\SimpleItem\ApiResponse\ApiSummaryResourceTypeResponse; -use App\ItemType\SimpleItem\ApiResponse\Summary; use App\Transformers\Transformer; use App\Request\Validate\Validator; use Illuminate\Database\Eloquent\Model; @@ -77,12 +73,12 @@ public function type(): string public function summaryClass(): string { - return Summary::class; + return ApiResponse\Summary::class; } public function resourceTypeSummaryClass(): string { - return ApiSummaryResourceTypeResponse::class; + return ApiResponse\SummaryResourceTypeItem::class; } public function transformer(array $data_to_transform): Transformer @@ -113,7 +109,7 @@ public function viewClass(): string public function resourceTypeItemCollectionClass(): string { - return ApiResourceTypeResponse::class; + return ApiResponse\ResourceTypeItem::class; } protected function allowedValuesItemCollectionClass(): string @@ -123,6 +119,6 @@ protected function allowedValuesItemCollectionClass(): string protected function allowedValuesResourceTypeItemCollectionClass(): string { - return ResourceTypeItem::class; + return AllowedValue\ResourceTypeItem::class; } } From 99ba4b2bd48560c55e62efd656923ce8ecf0ca55 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Sun, 16 Jan 2022 00:03:14 +0000 Subject: [PATCH 25/73] Refactoring - Renamed model classes --- app/ItemType/AllocatedExpense/ApiResponse/Summary.php | 3 +-- app/ItemType/AllocatedExpense/Item.php | 7 ------- .../Models/{SummaryModel.php => Summary.php} | 2 +- app/ItemType/Game/ApiResponse/Summary.php | 3 +-- app/ItemType/Game/ApiResponse/SummaryResourceTypeItem.php | 2 +- app/ItemType/Game/Item.php | 4 +--- app/ItemType/Game/Models/{SummaryModel.php => Summary.php} | 3 ++- ...ryResourceTypeModel.php => SummaryResourceTypeItem.php} | 3 ++- app/ItemType/SimpleExpense/ApiResponse/Summary.php | 3 +-- .../SimpleExpense/ApiResponse/SummaryResourceTypeItem.php | 2 +- .../SimpleExpense/Models/{SummaryModel.php => Summary.php} | 2 +- ...ryResourceTypeModel.php => SummaryResourceTypeItem.php} | 3 ++- app/ItemType/SimpleItem/ApiResponse/Summary.php | 3 +-- .../SimpleItem/ApiResponse/SummaryResourceTypeItem.php | 2 +- .../SimpleItem/Models/{SummaryModel.php => Summary.php} | 3 ++- ...ryResourceTypeModel.php => SummaryResourceTypeItem.php} | 3 ++- 16 files changed, 20 insertions(+), 28 deletions(-) rename app/ItemType/AllocatedExpense/Models/{SummaryModel.php => Summary.php} (99%) rename app/ItemType/Game/Models/{SummaryModel.php => Summary.php} (99%) rename app/ItemType/Game/Models/{SummaryResourceTypeModel.php => SummaryResourceTypeItem.php} (99%) rename app/ItemType/SimpleExpense/Models/{SummaryModel.php => Summary.php} (99%) rename app/ItemType/SimpleExpense/Models/{SummaryResourceTypeModel.php => SummaryResourceTypeItem.php} (99%) rename app/ItemType/SimpleItem/Models/{SummaryModel.php => Summary.php} (99%) rename app/ItemType/SimpleItem/Models/{SummaryResourceTypeModel.php => SummaryResourceTypeItem.php} (98%) diff --git a/app/ItemType/AllocatedExpense/ApiResponse/Summary.php b/app/ItemType/AllocatedExpense/ApiResponse/Summary.php index 2a38e547..0bb2f2c4 100644 --- a/app/ItemType/AllocatedExpense/ApiResponse/Summary.php +++ b/app/ItemType/AllocatedExpense/ApiResponse/Summary.php @@ -3,7 +3,6 @@ namespace App\ItemType\AllocatedExpense\ApiResponse; use App\ItemType\AllocatedExpense\Item; -use App\ItemType\AllocatedExpense\Models\SummaryModel; use App\ItemType\AllocatedExpense\Transformers\SummaryTransformer; use App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByCategory; use App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByMonth; @@ -33,7 +32,7 @@ public function __construct( $this->setUpCache(); - $this->model = new SummaryModel(); + $this->model = new \App\ItemType\AllocatedExpense\Models\Summary(); $this->shortCircuit(); // Skip working out which for obvious routes diff --git a/app/ItemType/AllocatedExpense/Item.php b/app/ItemType/AllocatedExpense/Item.php index 2e1ad88e..45e1933d 100644 --- a/app/ItemType/AllocatedExpense/Item.php +++ b/app/ItemType/AllocatedExpense/Item.php @@ -32,13 +32,6 @@ public function allowPartialTransfers(): bool return true; } - /** - * Create and save the item and item type data - * - * @param integer $id - * - * @return \App\ItemType\AllocatedExpense\Models\Model - */ public function create($id): Model { $hash = new Hash(); diff --git a/app/ItemType/AllocatedExpense/Models/SummaryModel.php b/app/ItemType/AllocatedExpense/Models/Summary.php similarity index 99% rename from app/ItemType/AllocatedExpense/Models/SummaryModel.php rename to app/ItemType/AllocatedExpense/Models/Summary.php index 1e5b8249..1c0f1cd9 100644 --- a/app/ItemType/AllocatedExpense/Models/SummaryModel.php +++ b/app/ItemType/AllocatedExpense/Models/Summary.php @@ -14,7 +14,7 @@ * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class SummaryModel extends LaravelModel +class Summary extends LaravelModel { protected $guarded = ['id', 'actualised_total', 'created_at', 'updated_at']; protected $table = 'item'; diff --git a/app/ItemType/Game/ApiResponse/Summary.php b/app/ItemType/Game/ApiResponse/Summary.php index 7a15d0c7..581e888d 100644 --- a/app/ItemType/Game/ApiResponse/Summary.php +++ b/app/ItemType/Game/ApiResponse/Summary.php @@ -4,7 +4,6 @@ use App\ItemType\ApiSummaryResponse as BaseSummaryResponse; use App\ItemType\Game\Item; -use App\ItemType\Game\Models\SummaryModel; use App\ItemType\Game\Transformers\SummaryTransformer; use Illuminate\Http\JsonResponse; use function response; @@ -27,7 +26,7 @@ public function __construct( $this->setUpCache(); - $this->model = new SummaryModel(); + $this->model = new \App\ItemType\Game\Models\Summary(); $this->fetchAllRequestParameters(new Item()); diff --git a/app/ItemType/Game/ApiResponse/SummaryResourceTypeItem.php b/app/ItemType/Game/ApiResponse/SummaryResourceTypeItem.php index 9690a652..27debfc9 100644 --- a/app/ItemType/Game/ApiResponse/SummaryResourceTypeItem.php +++ b/app/ItemType/Game/ApiResponse/SummaryResourceTypeItem.php @@ -26,7 +26,7 @@ public function __construct( $this->setUpCache(); - $this->model = new \App\ItemType\Game\Models\SummaryResourceTypeModel(); + $this->model = new \App\ItemType\Game\Models\SummaryResourceTypeItem(); $this->fetchAllRequestParameters(new Item()); diff --git a/app/ItemType/Game/Item.php b/app/ItemType/Game/Item.php index 543adf71..8efbd649 100644 --- a/app/ItemType/Game/Item.php +++ b/app/ItemType/Game/Item.php @@ -4,8 +4,6 @@ namespace App\ItemType\Game; use App\AllowedValue\Winner; -use App\ItemType\Game\AllowedValue\ResourceTypeItem; -use App\ItemType\Game\ApiResponse\Summary; use App\ItemType\ItemType; use App\Transformers\Transformer; use App\Request\Hash; @@ -143,6 +141,6 @@ protected function allowedValuesItemCollectionClass(): string protected function allowedValuesResourceTypeItemCollectionClass(): string { - return ResourceTypeItem::class; + return AllowedValue\ResourceTypeItem::class; } } diff --git a/app/ItemType/Game/Models/SummaryModel.php b/app/ItemType/Game/Models/Summary.php similarity index 99% rename from app/ItemType/Game/Models/SummaryModel.php rename to app/ItemType/Game/Models/Summary.php index 9e1d43a5..5bcb51ed 100644 --- a/app/ItemType/Game/Models/SummaryModel.php +++ b/app/ItemType/Game/Models/Summary.php @@ -9,11 +9,12 @@ /** * @mixin QueryBuilder + * * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class SummaryModel extends LaravelModel +class Summary extends LaravelModel { protected $guarded = ['id']; protected $table = 'item'; diff --git a/app/ItemType/Game/Models/SummaryResourceTypeModel.php b/app/ItemType/Game/Models/SummaryResourceTypeItem.php similarity index 99% rename from app/ItemType/Game/Models/SummaryResourceTypeModel.php rename to app/ItemType/Game/Models/SummaryResourceTypeItem.php index 95f661b3..2ca038af 100644 --- a/app/ItemType/Game/Models/SummaryResourceTypeModel.php +++ b/app/ItemType/Game/Models/SummaryResourceTypeItem.php @@ -8,11 +8,12 @@ /** * @mixin QueryBuilder + * * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class SummaryResourceTypeModel extends LaravelModel +class SummaryResourceTypeItem extends LaravelModel { protected $guarded = ['id']; protected $table = 'item'; diff --git a/app/ItemType/SimpleExpense/ApiResponse/Summary.php b/app/ItemType/SimpleExpense/ApiResponse/Summary.php index a42b1c12..88ea3104 100644 --- a/app/ItemType/SimpleExpense/ApiResponse/Summary.php +++ b/app/ItemType/SimpleExpense/ApiResponse/Summary.php @@ -4,7 +4,6 @@ use App\ItemType\ApiSummaryResponse as BaseSummaryResponse; use App\ItemType\SimpleExpense\Item; -use App\ItemType\SimpleExpense\Models\SummaryModel; use App\ItemType\SimpleExpense\Transformers\SummaryTransformer; use App\ItemType\SimpleExpense\Transformers\SummaryTransformerByCategory; use App\ItemType\SimpleExpense\Transformers\SummaryTransformerBySubcategory; @@ -30,7 +29,7 @@ public function __construct( $this->setUpCache(); - $this->model = new SummaryModel(); + $this->model = new \App\ItemType\SimpleExpense\Models\Summary(); $this->fetchAllRequestParameters(new Item()); diff --git a/app/ItemType/SimpleExpense/ApiResponse/SummaryResourceTypeItem.php b/app/ItemType/SimpleExpense/ApiResponse/SummaryResourceTypeItem.php index 75db42e1..02d2d7b2 100644 --- a/app/ItemType/SimpleExpense/ApiResponse/SummaryResourceTypeItem.php +++ b/app/ItemType/SimpleExpense/ApiResponse/SummaryResourceTypeItem.php @@ -28,7 +28,7 @@ public function __construct( $this->setUpCache(); - $this->model = new \App\ItemType\SimpleExpense\Models\SummaryResourceTypeModel(); + $this->model = new \App\ItemType\SimpleExpense\Models\SummaryResourceTypeItem(); $this->fetchAllRequestParameters(new Item()); diff --git a/app/ItemType/SimpleExpense/Models/SummaryModel.php b/app/ItemType/SimpleExpense/Models/Summary.php similarity index 99% rename from app/ItemType/SimpleExpense/Models/SummaryModel.php rename to app/ItemType/SimpleExpense/Models/Summary.php index d1c7c4e8..5eb6f7fa 100644 --- a/app/ItemType/SimpleExpense/Models/SummaryModel.php +++ b/app/ItemType/SimpleExpense/Models/Summary.php @@ -13,7 +13,7 @@ * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class SummaryModel extends LaravelModel +class Summary extends LaravelModel { protected $guarded = ['id', 'created_at', 'updated_at']; protected $table = 'item'; diff --git a/app/ItemType/SimpleExpense/Models/SummaryResourceTypeModel.php b/app/ItemType/SimpleExpense/Models/SummaryResourceTypeItem.php similarity index 99% rename from app/ItemType/SimpleExpense/Models/SummaryResourceTypeModel.php rename to app/ItemType/SimpleExpense/Models/SummaryResourceTypeItem.php index f897b26a..31d65c8d 100644 --- a/app/ItemType/SimpleExpense/Models/SummaryResourceTypeModel.php +++ b/app/ItemType/SimpleExpense/Models/SummaryResourceTypeItem.php @@ -8,11 +8,12 @@ /** * @mixin QueryBuilder + * * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class SummaryResourceTypeModel extends LaravelModel +class SummaryResourceTypeItem extends LaravelModel { protected $guarded = ['id', 'created_at', 'updated_at']; protected $table = 'item'; diff --git a/app/ItemType/SimpleItem/ApiResponse/Summary.php b/app/ItemType/SimpleItem/ApiResponse/Summary.php index 6c00ce4b..b4fd418b 100644 --- a/app/ItemType/SimpleItem/ApiResponse/Summary.php +++ b/app/ItemType/SimpleItem/ApiResponse/Summary.php @@ -4,7 +4,6 @@ use App\ItemType\ApiSummaryResponse as BaseSummaryResponse; use App\ItemType\SimpleItem\Item; -use App\ItemType\SimpleItem\Models\SummaryModel; use App\ItemType\SimpleItem\Transformers\SummaryTransformer; use Illuminate\Http\JsonResponse; use function response; @@ -27,7 +26,7 @@ public function __construct( $this->setUpCache(); - $this->model = new SummaryModel(); + $this->model = new \App\ItemType\SimpleItem\Models\Summary(); $this->fetchAllRequestParameters(new Item()); diff --git a/app/ItemType/SimpleItem/ApiResponse/SummaryResourceTypeItem.php b/app/ItemType/SimpleItem/ApiResponse/SummaryResourceTypeItem.php index 51196267..545ef81f 100644 --- a/app/ItemType/SimpleItem/ApiResponse/SummaryResourceTypeItem.php +++ b/app/ItemType/SimpleItem/ApiResponse/SummaryResourceTypeItem.php @@ -26,7 +26,7 @@ public function __construct( $this->setUpCache(); - $this->model = new \App\ItemType\SimpleItem\Models\SummaryResourceTypeModel(); + $this->model = new \App\ItemType\SimpleItem\Models\SummaryResourceTypeItem(); $this->fetchAllRequestParameters(new Item()); diff --git a/app/ItemType/SimpleItem/Models/SummaryModel.php b/app/ItemType/SimpleItem/Models/Summary.php similarity index 99% rename from app/ItemType/SimpleItem/Models/SummaryModel.php rename to app/ItemType/SimpleItem/Models/Summary.php index a7fe4c3c..4a8e14bf 100644 --- a/app/ItemType/SimpleItem/Models/SummaryModel.php +++ b/app/ItemType/SimpleItem/Models/Summary.php @@ -9,11 +9,12 @@ /** * @mixin QueryBuilder + * * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class SummaryModel extends LaravelModel +class Summary extends LaravelModel { protected $guarded = ['id', 'created_at', 'updated_at']; protected $table = 'item'; diff --git a/app/ItemType/SimpleItem/Models/SummaryResourceTypeModel.php b/app/ItemType/SimpleItem/Models/SummaryResourceTypeItem.php similarity index 98% rename from app/ItemType/SimpleItem/Models/SummaryResourceTypeModel.php rename to app/ItemType/SimpleItem/Models/SummaryResourceTypeItem.php index cc0ebb24..d32f2e86 100644 --- a/app/ItemType/SimpleItem/Models/SummaryResourceTypeModel.php +++ b/app/ItemType/SimpleItem/Models/SummaryResourceTypeItem.php @@ -8,11 +8,12 @@ /** * @mixin QueryBuilder + * * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class SummaryResourceTypeModel extends LaravelModel +class SummaryResourceTypeItem extends LaravelModel { protected $guarded = ['id', 'created_at', 'updated_at']; protected $table = 'item'; From 903531ac6a61ab11145b83a4cf9ec478163275b5 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Sun, 16 Jan 2022 00:24:46 +0000 Subject: [PATCH 26/73] Transformers - Call transformers by FQN so the renaming goes easier --- .../AllocatedExpense/ApiResponse/Item.php | 5 ++-- .../ApiResponse/ResourceTypeItem.php | 3 +- .../AllocatedExpense/ApiResponse/Summary.php | 25 +++++++---------- .../ApiResponse/SummaryResourceTypeItem.php | 28 ++++++++----------- app/ItemType/Game/ApiResponse/Item.php | 5 ++-- .../Game/ApiResponse/ResourceTypeItem.php | 3 +- app/ItemType/Game/ApiResponse/Summary.php | 5 ++-- .../ApiResponse/SummaryResourceTypeItem.php | 8 ++---- .../SimpleExpense/ApiResponse/Item.php | 5 ++-- .../ApiResponse/ResourceTypeItem.php | 3 +- .../SimpleExpense/ApiResponse/Summary.php | 15 ++++------ .../ApiResponse/SummaryResourceTypeItem.php | 18 +++++------- app/ItemType/SimpleItem/ApiResponse/Item.php | 5 ++-- .../ApiResponse/ResourceTypeItem.php | 3 +- .../SimpleItem/ApiResponse/Summary.php | 5 ++-- .../ApiResponse/SummaryResourceTypeItem.php | 8 ++---- 16 files changed, 56 insertions(+), 88 deletions(-) diff --git a/app/ItemType/AllocatedExpense/ApiResponse/Item.php b/app/ItemType/AllocatedExpense/ApiResponse/Item.php index 883a0806..72d530a9 100644 --- a/app/ItemType/AllocatedExpense/ApiResponse/Item.php +++ b/app/ItemType/AllocatedExpense/ApiResponse/Item.php @@ -3,7 +3,6 @@ namespace App\ItemType\AllocatedExpense\ApiResponse; -use App\ItemType\AllocatedExpense\Transformers\Transformer; use App\ItemType\ApiResponse as ItemTypeResponse; use App\Response\Responses; use Illuminate\Http\JsonResponse; @@ -62,7 +61,7 @@ public function collectionResponse(): JsonResponse $collection = array_map( static function ($item) { - return (new Transformer($item))->asArray(); + return (new \App\ItemType\AllocatedExpense\Transformers\Transformer($item))->asArray(); }, $items ); @@ -103,7 +102,7 @@ public function showResponse(int $item_id): JsonResponse } return response()->json( - (new Transformer($item))->asArray(), + (new \App\ItemType\AllocatedExpense\Transformers\Transformer($item))->asArray(), 200, $this->showHeaders() ); diff --git a/app/ItemType/AllocatedExpense/ApiResponse/ResourceTypeItem.php b/app/ItemType/AllocatedExpense/ApiResponse/ResourceTypeItem.php index c12d921e..ee876111 100644 --- a/app/ItemType/AllocatedExpense/ApiResponse/ResourceTypeItem.php +++ b/app/ItemType/AllocatedExpense/ApiResponse/ResourceTypeItem.php @@ -4,7 +4,6 @@ namespace App\ItemType\AllocatedExpense\ApiResponse; use App\ItemType\AllocatedExpense\Item; -use App\ItemType\AllocatedExpense\Transformers\ResourceTypeTransformer as Transformer; use App\ItemType\ApiResourceTypeResponse as BaseResourceTypeResponse; use Illuminate\Http\JsonResponse; use function request; @@ -59,7 +58,7 @@ public function response(): JsonResponse $collection = array_map( static function ($item) { - return (new Transformer($item))->asArray(); + return (new \App\ItemType\AllocatedExpense\Transformers\ResourceTypeTransformer($item))->asArray(); }, $items ); diff --git a/app/ItemType/AllocatedExpense/ApiResponse/Summary.php b/app/ItemType/AllocatedExpense/ApiResponse/Summary.php index 0bb2f2c4..a6c87848 100644 --- a/app/ItemType/AllocatedExpense/ApiResponse/Summary.php +++ b/app/ItemType/AllocatedExpense/ApiResponse/Summary.php @@ -3,11 +3,6 @@ namespace App\ItemType\AllocatedExpense\ApiResponse; use App\ItemType\AllocatedExpense\Item; -use App\ItemType\AllocatedExpense\Transformers\SummaryTransformer; -use App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByCategory; -use App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByMonth; -use App\ItemType\AllocatedExpense\Transformers\SummaryTransformerBySubcategory; -use App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByYear; use App\ItemType\ApiSummaryResponse as BaseSummaryResponse; use App\Request\Validate\Boolean; use Illuminate\Http\JsonResponse; @@ -128,7 +123,7 @@ protected function categoriesSummary(): JsonResponse $this->parameters ); - $collection = (new SummaryTransformerByCategory($summary))->asArray(); + $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByCategory($summary))->asArray(); $this->assignToCache( $summary, @@ -152,7 +147,7 @@ protected function categorySummary(): JsonResponse $this->parameters ); - $collection = (new SummaryTransformerByCategory($summary))->asArray(); + $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByCategory($summary))->asArray(); if (count($collection) === 1) { $collection = $collection[0]; @@ -189,7 +184,7 @@ protected function filteredSummary(): JsonResponse $collection = []; foreach ($summary as $subtotal) { - $collection[] = (new SummaryTransformer($subtotal))->asArray(); + $collection[] = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformer($subtotal))->asArray(); } $this->assignToCache( @@ -214,7 +209,7 @@ protected function monthsSummary(): JsonResponse $this->parameters ); - $collection = (new SummaryTransformerByMonth($summary))->asArray(); + $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByMonth($summary))->asArray(); $this->assignToCache( $summary, @@ -239,7 +234,7 @@ protected function monthSummary(): JsonResponse $this->parameters ); - $collection = (new SummaryTransformerByMonth($summary))->asArray(); + $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByMonth($summary))->asArray(); if (count($collection) === 1) { $collection = $collection[0]; @@ -328,7 +323,7 @@ protected function subcategoriesSummary(): JsonResponse $this->parameters ); - $collection = (new SummaryTransformerBySubcategory($summary))->asArray(); + $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformerBySubcategory($summary))->asArray(); $this->assignToCache( $summary, @@ -353,7 +348,7 @@ protected function subcategorySummary(): JsonResponse $this->parameters ); - $collection = (new SummaryTransformerBySubcategory($summary))->asArray(); + $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformerBySubcategory($summary))->asArray(); if (count($collection) === 1) { $collection = $collection[0]; @@ -384,7 +379,7 @@ protected function summary(): JsonResponse $collection = []; foreach ($summary as $subtotal) { - $collection[] = (new SummaryTransformer($subtotal))->asArray(); + $collection[] = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformer($subtotal))->asArray(); } $this->assignToCache( @@ -408,7 +403,7 @@ protected function yearsSummary(): JsonResponse $this->parameters ); - $collection = (new SummaryTransformerByYear($summary))->asArray(); + $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByYear($summary))->asArray(); $this->assignToCache( $summary, @@ -432,7 +427,7 @@ protected function yearSummary(): JsonResponse $this->parameters ); - $collection = (new SummaryTransformerByYear($summary))->asArray(); + $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByYear($summary))->asArray(); if (count($collection) === 1) { $collection = $collection[0]; diff --git a/app/ItemType/AllocatedExpense/ApiResponse/SummaryResourceTypeItem.php b/app/ItemType/AllocatedExpense/ApiResponse/SummaryResourceTypeItem.php index 2ff3152f..63bb978e 100644 --- a/app/ItemType/AllocatedExpense/ApiResponse/SummaryResourceTypeItem.php +++ b/app/ItemType/AllocatedExpense/ApiResponse/SummaryResourceTypeItem.php @@ -3,12 +3,6 @@ namespace App\ItemType\AllocatedExpense\ApiResponse; use App\ItemType\AllocatedExpense\Item; -use App\ItemType\AllocatedExpense\Transformers\SummaryTransformer; -use App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByCategory; -use App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByMonth; -use App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByResource; -use App\ItemType\AllocatedExpense\Transformers\SummaryTransformerBySubcategory; -use App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByYear; use App\ItemType\ApiSummaryResourceTypeResponse as BaseSummaryResourceTypeResponse; use App\Request\Validate\Boolean; use Illuminate\Http\JsonResponse; @@ -130,7 +124,7 @@ protected function categoriesSummary(): JsonResponse $this->parameters ); - $collection = (new SummaryTransformerByCategory($summary))->asArray(); + $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByCategory($summary))->asArray(); $this->assignToCache( $summary, @@ -153,7 +147,7 @@ protected function categorySummary(): JsonResponse $this->parameters ); - $collection = (new SummaryTransformerByCategory($summary))->asArray(); + $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByCategory($summary))->asArray(); if (count($collection) === 1) { $collection = $collection[0]; @@ -189,7 +183,7 @@ protected function filteredSummary(): JsonResponse $collection = []; foreach ($summary as $subtotal) { - $collection[] = (new SummaryTransformer($subtotal))->asArray(); + $collection[] = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformer($subtotal))->asArray(); } $this->assignToCache( @@ -213,7 +207,7 @@ protected function monthsSummary(): JsonResponse $this->parameters ); - $collection = (new SummaryTransformerByMonth($summary))->asArray(); + $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByMonth($summary))->asArray(); $this->assignToCache( $summary, @@ -237,7 +231,7 @@ protected function monthSummary(): JsonResponse $this->parameters ); - $collection = (new SummaryTransformerByMonth($summary))->asArray(); + $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByMonth($summary))->asArray(); if (count($collection) === 1) { $collection = $collection[0]; @@ -331,7 +325,7 @@ protected function resourcesSummary(): JsonResponse $this->parameters ); - $collection = (new SummaryTransformerByResource($summary))->asArray(); + $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByResource($summary))->asArray(); $this->assignToCache( $summary, @@ -354,7 +348,7 @@ protected function subcategoriesSummary(): JsonResponse $this->parameters ); - $collection = (new SummaryTransformerBySubcategory($summary))->asArray(); + $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformerBySubcategory($summary))->asArray(); $this->assignToCache( $summary, @@ -378,7 +372,7 @@ protected function subcategorySummary(): JsonResponse $this->parameters ); - $collection = (new SummaryTransformerBySubcategory($summary))->asArray(); + $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformerBySubcategory($summary))->asArray(); if (count($collection) === 1) { $collection = $collection[0]; @@ -408,7 +402,7 @@ protected function summary(): JsonResponse $collection = []; foreach ($summary as $subtotal) { - $collection[] = (new SummaryTransformer($subtotal))->asArray(); + $collection[] = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformer($subtotal))->asArray(); } $this->assignToCache( @@ -431,7 +425,7 @@ protected function yearsSummary(): JsonResponse $this->parameters ); - $collection = (new SummaryTransformerByYear($summary))->asArray(); + $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByYear($summary))->asArray(); $this->assignToCache( $summary, @@ -454,7 +448,7 @@ protected function yearSummary(): JsonResponse $this->parameters ); - $collection = (new SummaryTransformerByYear($summary))->asArray(); + $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByYear($summary))->asArray(); if (count($collection) === 1) { $collection = $collection[0]; diff --git a/app/ItemType/Game/ApiResponse/Item.php b/app/ItemType/Game/ApiResponse/Item.php index 88382505..92d8682e 100644 --- a/app/ItemType/Game/ApiResponse/Item.php +++ b/app/ItemType/Game/ApiResponse/Item.php @@ -4,7 +4,6 @@ namespace App\ItemType\Game\ApiResponse; use App\ItemType\ApiResponse as ItemTypeResponse; -use App\ItemType\Game\Transformers\Transformer; use App\Response\Responses; use Illuminate\Http\JsonResponse; use function request; @@ -58,7 +57,7 @@ public function collectionResponse(): JsonResponse $collection = array_map( static function ($item) { - return (new Transformer($item))->asArray(); + return (new \App\ItemType\Game\Transformers\Transformer($item))->asArray(); }, $items ); @@ -99,7 +98,7 @@ public function showResponse(int $item_id): JsonResponse } return response()->json( - (new Transformer($item))->asArray(), + (new \App\ItemType\Game\Transformers\Transformer($item))->asArray(), 200, $this->showHeaders() ); diff --git a/app/ItemType/Game/ApiResponse/ResourceTypeItem.php b/app/ItemType/Game/ApiResponse/ResourceTypeItem.php index cc402096..d57d2ad3 100644 --- a/app/ItemType/Game/ApiResponse/ResourceTypeItem.php +++ b/app/ItemType/Game/ApiResponse/ResourceTypeItem.php @@ -4,7 +4,6 @@ namespace App\ItemType\Game\ApiResponse; use App\ItemType\Game\Item; -use App\ItemType\Game\Transformers\ResourceTypeTransformer as Transformer; use App\ItemType\ApiResourceTypeResponse as BaseResourceTypeResponse; use Illuminate\Http\JsonResponse; use function request; @@ -55,7 +54,7 @@ public function response(): JsonResponse $collection = array_map( static function ($item) { - return (new Transformer($item))->asArray(); + return (new \App\ItemType\Game\Transformers\ResourceTypeTransformer($item))->asArray(); }, $items ); diff --git a/app/ItemType/Game/ApiResponse/Summary.php b/app/ItemType/Game/ApiResponse/Summary.php index 581e888d..48efd645 100644 --- a/app/ItemType/Game/ApiResponse/Summary.php +++ b/app/ItemType/Game/ApiResponse/Summary.php @@ -4,7 +4,6 @@ use App\ItemType\ApiSummaryResponse as BaseSummaryResponse; use App\ItemType\Game\Item; -use App\ItemType\Game\Transformers\SummaryTransformer; use Illuminate\Http\JsonResponse; use function response; @@ -59,7 +58,7 @@ protected function filteredSummary(): JsonResponse $collection = []; foreach ($summary as $subtotal) { - $collection[] = (new SummaryTransformer($subtotal))->asArray(); + $collection[] = (new \App\ItemType\Game\Transformers\SummaryTransformer($subtotal))->asArray(); } $this->assignToCache( @@ -90,7 +89,7 @@ protected function summary(): JsonResponse $collection = []; foreach ($summary as $subtotal) { - $collection[] = (new SummaryTransformer($subtotal))->asArray(); + $collection[] = (new \App\ItemType\Game\Transformers\SummaryTransformer($subtotal))->asArray(); } $this->assignToCache( diff --git a/app/ItemType/Game/ApiResponse/SummaryResourceTypeItem.php b/app/ItemType/Game/ApiResponse/SummaryResourceTypeItem.php index 27debfc9..860e9da3 100644 --- a/app/ItemType/Game/ApiResponse/SummaryResourceTypeItem.php +++ b/app/ItemType/Game/ApiResponse/SummaryResourceTypeItem.php @@ -3,9 +3,7 @@ namespace App\ItemType\Game\ApiResponse; use App\ItemType\Game\Item; -use App\ItemType\Game\Transformers\SummaryTransformerByResource; use App\ItemType\ApiSummaryResourceTypeResponse as BaseSummaryResourceTypeResponse; -use App\ItemType\Game\Transformers\SummaryTransformer as GameTransformer; use App\Request\Validate\Boolean; use Illuminate\Http\JsonResponse; use function response; @@ -61,7 +59,7 @@ protected function filteredSummary(): JsonResponse $collection = []; foreach ($summary as $subtotal) { - $collection[] = (new GameTransformer($subtotal))->asArray(); + $collection[] = (new \App\ItemType\Game\Transformers\SummaryTransformer($subtotal))->asArray(); } $this->assignToCache( @@ -98,7 +96,7 @@ protected function resourcesSummary(): JsonResponse $this->parameters ); - $collection = (new SummaryTransformerByResource($summary))->asArray(); + $collection = (new \App\ItemType\Game\Transformers\SummaryTransformerByResource($summary))->asArray(); $this->assignToCache( $summary, @@ -122,7 +120,7 @@ protected function summary(): JsonResponse $collection = []; foreach ($summary as $subtotal) { - $collection[] = (new GameTransformer($subtotal))->asArray(); + $collection[] = (new \App\ItemType\Game\Transformers\SummaryTransformer($subtotal))->asArray(); } $this->assignToCache( diff --git a/app/ItemType/SimpleExpense/ApiResponse/Item.php b/app/ItemType/SimpleExpense/ApiResponse/Item.php index 96f17f22..88336742 100644 --- a/app/ItemType/SimpleExpense/ApiResponse/Item.php +++ b/app/ItemType/SimpleExpense/ApiResponse/Item.php @@ -4,7 +4,6 @@ namespace App\ItemType\SimpleExpense\ApiResponse; use App\ItemType\ApiResponse as ItemTypeResponse; -use App\ItemType\SimpleExpense\Transformers\Transformer; use App\Response\Responses; use Illuminate\Http\JsonResponse; use function request; @@ -58,7 +57,7 @@ public function collectionResponse(): JsonResponse $collection = array_map( static function ($item) { - return (new Transformer($item))->asArray(); + return (new \App\ItemType\SimpleExpense\Transformers\Transformer($item))->asArray(); }, $items ); @@ -99,7 +98,7 @@ public function showResponse(int $item_id): JsonResponse } return response()->json( - (new Transformer($item))->asArray(), + (new \App\ItemType\SimpleExpense\Transformers\Transformer($item))->asArray(), 200, $this->showHeaders() ); diff --git a/app/ItemType/SimpleExpense/ApiResponse/ResourceTypeItem.php b/app/ItemType/SimpleExpense/ApiResponse/ResourceTypeItem.php index e00e1e12..b62799bd 100644 --- a/app/ItemType/SimpleExpense/ApiResponse/ResourceTypeItem.php +++ b/app/ItemType/SimpleExpense/ApiResponse/ResourceTypeItem.php @@ -5,7 +5,6 @@ use App\ItemType\ApiResourceTypeResponse as BaseResourceTypeResponse; use App\ItemType\SimpleExpense\Item; -use App\ItemType\SimpleExpense\Transformers\ResourceTypeTransformer as Transformer; use Illuminate\Http\JsonResponse; use function request; use function response; @@ -55,7 +54,7 @@ public function response(): JsonResponse $collection = array_map( static function ($item) { - return (new Transformer($item))->asArray(); + return (new \App\ItemType\SimpleExpense\Transformers\ResourceTypeTransformer($item))->asArray(); }, $items ); diff --git a/app/ItemType/SimpleExpense/ApiResponse/Summary.php b/app/ItemType/SimpleExpense/ApiResponse/Summary.php index 88ea3104..cf137f66 100644 --- a/app/ItemType/SimpleExpense/ApiResponse/Summary.php +++ b/app/ItemType/SimpleExpense/ApiResponse/Summary.php @@ -4,9 +4,6 @@ use App\ItemType\ApiSummaryResponse as BaseSummaryResponse; use App\ItemType\SimpleExpense\Item; -use App\ItemType\SimpleExpense\Transformers\SummaryTransformer; -use App\ItemType\SimpleExpense\Transformers\SummaryTransformerByCategory; -use App\ItemType\SimpleExpense\Transformers\SummaryTransformerBySubcategory; use App\Request\Validate\Boolean; use Illuminate\Http\JsonResponse; use function response; @@ -80,7 +77,7 @@ protected function categoriesSummary(): JsonResponse $this->parameters ); - $collection = (new SummaryTransformerByCategory($summary))->asArray(); + $collection = (new \App\ItemType\SimpleExpense\Transformers\SummaryTransformerByCategory($summary))->asArray(); $this->assignToCache( $summary, @@ -104,7 +101,7 @@ protected function categorySummary(): JsonResponse $this->parameters ); - $collection = (new SummaryTransformerByCategory($summary))->asArray(); + $collection = (new \App\ItemType\SimpleExpense\Transformers\SummaryTransformerByCategory($summary))->asArray(); if (count($collection) === 1) { $collection = $collection[0]; @@ -139,7 +136,7 @@ protected function filteredSummary(): JsonResponse $collection = []; foreach ($summary as $subtotal) { - $collection[] = (new SummaryTransformer($subtotal))->asArray(); + $collection[] = (new \App\ItemType\SimpleExpense\Transformers\SummaryTransformer($subtotal))->asArray(); } $this->assignToCache( @@ -197,7 +194,7 @@ protected function subcategoriesSummary(): JsonResponse $this->parameters ); - $collection = (new SummaryTransformerBySubcategory($summary))->asArray(); + $collection = (new \App\ItemType\SimpleExpense\Transformers\SummaryTransformerBySubcategory($summary))->asArray(); $this->assignToCache( $summary, @@ -222,7 +219,7 @@ protected function subcategorySummary(): JsonResponse $this->parameters ); - $collection = (new SummaryTransformerBySubcategory($summary))->asArray(); + $collection = (new \App\ItemType\SimpleExpense\Transformers\SummaryTransformerBySubcategory($summary))->asArray(); if (count($collection) === 1) { $collection = $collection[0]; @@ -253,7 +250,7 @@ protected function summary(): JsonResponse $collection = []; foreach ($summary as $subtotal) { - $collection[] = (new SummaryTransformer($subtotal))->asArray(); + $collection[] = (new \App\ItemType\SimpleExpense\Transformers\SummaryTransformer($subtotal))->asArray(); } $this->assignToCache( diff --git a/app/ItemType/SimpleExpense/ApiResponse/SummaryResourceTypeItem.php b/app/ItemType/SimpleExpense/ApiResponse/SummaryResourceTypeItem.php index 02d2d7b2..8b9b54ca 100644 --- a/app/ItemType/SimpleExpense/ApiResponse/SummaryResourceTypeItem.php +++ b/app/ItemType/SimpleExpense/ApiResponse/SummaryResourceTypeItem.php @@ -3,10 +3,6 @@ namespace App\ItemType\SimpleExpense\ApiResponse; use App\ItemType\SimpleExpense\Item; -use App\ItemType\SimpleExpense\Transformers\SummaryTransformer; -use App\ItemType\SimpleExpense\Transformers\SummaryTransformerByCategory; -use App\ItemType\SimpleExpense\Transformers\SummaryTransformerByResource; -use App\ItemType\SimpleExpense\Transformers\SummaryTransformerBySubcategory; use App\ItemType\ApiSummaryResourceTypeResponse as BaseSummaryResourceTypeResponse; use App\Request\Validate\Boolean; use Illuminate\Http\JsonResponse; @@ -81,7 +77,7 @@ protected function categoriesSummary(): JsonResponse $this->parameters ); - $collection = (new SummaryTransformerByCategory($summary))->asArray(); + $collection = (new \App\ItemType\SimpleExpense\Transformers\SummaryTransformerByCategory($summary))->asArray(); $this->assignToCache( $summary, @@ -104,7 +100,7 @@ protected function categorySummary(): JsonResponse $this->parameters ); - $collection = (new SummaryTransformerByCategory($summary))->asArray(); + $collection = (new \App\ItemType\SimpleExpense\Transformers\SummaryTransformerByCategory($summary))->asArray(); if (count($collection) === 1) { $collection = $collection[0]; @@ -137,7 +133,7 @@ protected function filteredSummary(): JsonResponse $collection = []; foreach ($summary as $subtotal) { - $collection[] = (new SummaryTransformer($subtotal))->asArray(); + $collection[] = (new \App\ItemType\SimpleExpense\Transformers\SummaryTransformer($subtotal))->asArray(); } $this->assignToCache( @@ -200,7 +196,7 @@ protected function resourcesSummary(): JsonResponse $this->parameters ); - $collection = (new SummaryTransformerByResource($summary))->asArray(); + $collection = (new \App\ItemType\SimpleExpense\Transformers\SummaryTransformerByResource($summary))->asArray(); $this->assignToCache( $summary, @@ -223,7 +219,7 @@ protected function subcategoriesSummary(): JsonResponse $this->parameters ); - $collection = (new SummaryTransformerBySubcategory($summary))->asArray(); + $collection = (new \App\ItemType\SimpleExpense\Transformers\SummaryTransformerBySubcategory($summary))->asArray(); $this->assignToCache( $summary, @@ -247,7 +243,7 @@ protected function subcategorySummary(): JsonResponse $this->parameters ); - $collection = (new SummaryTransformerBySubcategory($summary))->asArray(); + $collection = (new \App\ItemType\SimpleExpense\Transformers\SummaryTransformerBySubcategory($summary))->asArray(); if (count($collection) === 1) { $collection = $collection[0]; @@ -277,7 +273,7 @@ protected function summary(): JsonResponse $collection = []; foreach ($summary as $subtotal) { - $collection[] = (new SummaryTransformer($subtotal))->asArray(); + $collection[] = (new \App\ItemType\SimpleExpense\Transformers\SummaryTransformer($subtotal))->asArray(); } $this->assignToCache( diff --git a/app/ItemType/SimpleItem/ApiResponse/Item.php b/app/ItemType/SimpleItem/ApiResponse/Item.php index be833116..93201615 100644 --- a/app/ItemType/SimpleItem/ApiResponse/Item.php +++ b/app/ItemType/SimpleItem/ApiResponse/Item.php @@ -4,7 +4,6 @@ namespace App\ItemType\SimpleItem\ApiResponse; use App\ItemType\ApiResponse as ItemTypeResponse; -use App\ItemType\SimpleItem\Transformers\Transformer; use App\Response\Responses; use Illuminate\Http\JsonResponse; use function request; @@ -57,7 +56,7 @@ public function collectionResponse(): JsonResponse $collection = array_map( static function ($item) { - return (new Transformer($item))->asArray(); + return (new \App\ItemType\SimpleItem\Transformers\Transformer($item))->asArray(); }, $items ); @@ -98,7 +97,7 @@ public function showResponse(int $item_id): JsonResponse } return response()->json( - (new Transformer($item))->asArray(), + (new \App\ItemType\SimpleItem\Transformers\Transformer($item))->asArray(), 200, $this->showHeaders() ); diff --git a/app/ItemType/SimpleItem/ApiResponse/ResourceTypeItem.php b/app/ItemType/SimpleItem/ApiResponse/ResourceTypeItem.php index 2bf09990..f46c9766 100644 --- a/app/ItemType/SimpleItem/ApiResponse/ResourceTypeItem.php +++ b/app/ItemType/SimpleItem/ApiResponse/ResourceTypeItem.php @@ -5,7 +5,6 @@ use App\ItemType\ApiResourceTypeResponse as BaseResourceTypeResponse; use App\ItemType\SimpleItem\Item; -use App\ItemType\SimpleItem\Transformers\ResourceTypeTransformer as Transformer; use Illuminate\Http\JsonResponse; use function request; use function response; @@ -53,7 +52,7 @@ public function response(): JsonResponse $collection = array_map( static function ($item) { - return (new Transformer($item))->asArray(); + return (new \App\ItemType\SimpleItem\Transformers\ResourceTypeTransformer($item))->asArray(); }, $items ); diff --git a/app/ItemType/SimpleItem/ApiResponse/Summary.php b/app/ItemType/SimpleItem/ApiResponse/Summary.php index b4fd418b..c4a64c8c 100644 --- a/app/ItemType/SimpleItem/ApiResponse/Summary.php +++ b/app/ItemType/SimpleItem/ApiResponse/Summary.php @@ -4,7 +4,6 @@ use App\ItemType\ApiSummaryResponse as BaseSummaryResponse; use App\ItemType\SimpleItem\Item; -use App\ItemType\SimpleItem\Transformers\SummaryTransformer; use Illuminate\Http\JsonResponse; use function response; @@ -59,7 +58,7 @@ protected function filteredSummary(): JsonResponse $collection = []; foreach ($summary as $subtotal) { - $collection[] = (new SummaryTransformer($subtotal))->asArray(); + $collection[] = (new \App\ItemType\SimpleItem\Transformers\SummaryTransformer($subtotal))->asArray(); } $this->assignToCache( @@ -90,7 +89,7 @@ protected function summary(): JsonResponse $collection = []; foreach ($summary as $subtotal) { - $collection[] = (new SummaryTransformer($subtotal))->asArray(); + $collection[] = (new \App\ItemType\SimpleItem\Transformers\SummaryTransformer($subtotal))->asArray(); } $this->assignToCache( diff --git a/app/ItemType/SimpleItem/ApiResponse/SummaryResourceTypeItem.php b/app/ItemType/SimpleItem/ApiResponse/SummaryResourceTypeItem.php index 545ef81f..17c71c30 100644 --- a/app/ItemType/SimpleItem/ApiResponse/SummaryResourceTypeItem.php +++ b/app/ItemType/SimpleItem/ApiResponse/SummaryResourceTypeItem.php @@ -3,8 +3,6 @@ namespace App\ItemType\SimpleItem\ApiResponse; use App\ItemType\SimpleItem\Item; -use App\ItemType\SimpleItem\Transformers\SummaryTransformer; -use App\ItemType\SimpleItem\Transformers\SummaryTransformerByResource; use App\ItemType\ApiSummaryResourceTypeResponse as BaseSummaryResourceTypeResponse; use App\Request\Validate\Boolean; use Illuminate\Http\JsonResponse; @@ -61,7 +59,7 @@ protected function filteredSummary(): JsonResponse $collection = []; foreach ($summary as $subtotal) { - $collection[] = (new SummaryTransformer($subtotal))->asArray(); + $collection[] = (new \App\ItemType\SimpleItem\Transformers\SummaryTransformer($subtotal))->asArray(); } $this->assignToCache( @@ -98,7 +96,7 @@ protected function resourcesSummary(): JsonResponse $this->parameters ); - $collection = (new SummaryTransformerByResource($summary))->asArray(); + $collection = (new \App\ItemType\SimpleItem\Transformers\SummaryTransformerByResource($summary))->asArray(); $this->assignToCache( $summary, @@ -122,7 +120,7 @@ protected function summary(): JsonResponse $collection = []; foreach ($summary as $subtotal) { - $collection[] = (new SummaryTransformer($subtotal))->asArray(); + $collection[] = (new \App\ItemType\SimpleItem\Transformers\SummaryTransformer($subtotal))->asArray(); } $this->assignToCache( From a1fe354650edc8ec4f4b3cfed467bfbf4f525ee4 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Sun, 16 Jan 2022 14:52:27 +0000 Subject: [PATCH 27/73] Refactoring - Rename all transformers to match the rest of the setup --- .../AllocatedExpense/ApiResponse/Item.php | 4 ++-- .../ApiResponse/ResourceTypeItem.php | 2 +- .../AllocatedExpense/ApiResponse/Summary.php | 20 ++++++++--------- .../ApiResponse/SummaryResourceTypeItem.php | 22 +++++++++---------- app/ItemType/AllocatedExpense/Item.php | 2 +- .../{Transformer.php => Item.php} | 2 +- ...peTransformer.php => ResourceTypeItem.php} | 2 +- .../{SummaryTransformer.php => Summary.php} | 2 +- ...erByCategory.php => SummaryByCategory.php} | 2 +- ...nsformerByMonth.php => SummaryByMonth.php} | 2 +- ...erByResource.php => SummaryByResource.php} | 2 +- ...bcategory.php => SummaryBySubcategory.php} | 2 +- ...ransformerByYear.php => SummaryByYear.php} | 2 +- app/ItemType/Game/ApiResponse/Item.php | 4 ++-- .../Game/ApiResponse/ResourceTypeItem.php | 2 +- app/ItemType/Game/ApiResponse/Summary.php | 4 ++-- .../ApiResponse/SummaryResourceTypeItem.php | 6 ++--- app/ItemType/Game/Item.php | 2 +- .../{Transformer.php => Item.php} | 2 +- ...peTransformer.php => ResourceTypeItem.php} | 2 +- .../{SummaryTransformer.php => Summary.php} | 2 +- ...erByResource.php => SummaryByResource.php} | 2 +- .../SimpleExpense/ApiResponse/Item.php | 4 ++-- .../ApiResponse/ResourceTypeItem.php | 2 +- .../SimpleExpense/ApiResponse/Summary.php | 12 +++++----- .../ApiResponse/SummaryResourceTypeItem.php | 14 ++++++------ app/ItemType/SimpleExpense/Item.php | 2 +- .../{Transformer.php => Item.php} | 2 +- ...peTransformer.php => ResourceTypeItem.php} | 2 +- .../{SummaryTransformer.php => Summary.php} | 2 +- ...erByCategory.php => SummaryByCategory.php} | 2 +- ...erByResource.php => SummaryByResource.php} | 2 +- ...bcategory.php => SummaryBySubcategory.php} | 2 +- app/ItemType/SimpleItem/ApiResponse/Item.php | 4 ++-- .../ApiResponse/ResourceTypeItem.php | 2 +- .../SimpleItem/ApiResponse/Summary.php | 4 ++-- .../ApiResponse/SummaryResourceTypeItem.php | 6 ++--- app/ItemType/SimpleItem/Item.php | 2 +- .../{Transformer.php => Item.php} | 2 +- ...peTransformer.php => ResourceTypeItem.php} | 2 +- .../{SummaryTransformer.php => Summary.php} | 2 +- ...erByResource.php => SummaryByResource.php} | 2 +- 42 files changed, 82 insertions(+), 82 deletions(-) rename app/ItemType/AllocatedExpense/Transformers/{Transformer.php => Item.php} (97%) rename app/ItemType/AllocatedExpense/Transformers/{ResourceTypeTransformer.php => ResourceTypeItem.php} (96%) rename app/ItemType/AllocatedExpense/Transformers/{SummaryTransformer.php => Summary.php} (93%) rename app/ItemType/AllocatedExpense/Transformers/{SummaryTransformerByCategory.php => SummaryByCategory.php} (95%) rename app/ItemType/AllocatedExpense/Transformers/{SummaryTransformerByMonth.php => SummaryByMonth.php} (95%) rename app/ItemType/AllocatedExpense/Transformers/{SummaryTransformerByResource.php => SummaryByResource.php} (95%) rename app/ItemType/AllocatedExpense/Transformers/{SummaryTransformerBySubcategory.php => SummaryBySubcategory.php} (95%) rename app/ItemType/AllocatedExpense/Transformers/{SummaryTransformerByYear.php => SummaryByYear.php} (95%) rename app/ItemType/Game/Transformers/{Transformer.php => Item.php} (97%) rename app/ItemType/Game/Transformers/{ResourceTypeTransformer.php => ResourceTypeItem.php} (97%) rename app/ItemType/Game/Transformers/{SummaryTransformer.php => Summary.php} (97%) rename app/ItemType/Game/Transformers/{SummaryTransformerByResource.php => SummaryByResource.php} (96%) rename app/ItemType/SimpleExpense/Transformers/{Transformer.php => Item.php} (96%) rename app/ItemType/SimpleExpense/Transformers/{ResourceTypeTransformer.php => ResourceTypeItem.php} (96%) rename app/ItemType/SimpleExpense/Transformers/{SummaryTransformer.php => Summary.php} (93%) rename app/ItemType/SimpleExpense/Transformers/{SummaryTransformerByCategory.php => SummaryByCategory.php} (95%) rename app/ItemType/SimpleExpense/Transformers/{SummaryTransformerByResource.php => SummaryByResource.php} (95%) rename app/ItemType/SimpleExpense/Transformers/{SummaryTransformerBySubcategory.php => SummaryBySubcategory.php} (95%) rename app/ItemType/SimpleItem/Transformers/{Transformer.php => Item.php} (94%) rename app/ItemType/SimpleItem/Transformers/{ResourceTypeTransformer.php => ResourceTypeItem.php} (95%) rename app/ItemType/SimpleItem/Transformers/{SummaryTransformer.php => Summary.php} (91%) rename app/ItemType/SimpleItem/Transformers/{SummaryTransformerByResource.php => SummaryByResource.php} (92%) diff --git a/app/ItemType/AllocatedExpense/ApiResponse/Item.php b/app/ItemType/AllocatedExpense/ApiResponse/Item.php index 72d530a9..7435d82f 100644 --- a/app/ItemType/AllocatedExpense/ApiResponse/Item.php +++ b/app/ItemType/AllocatedExpense/ApiResponse/Item.php @@ -61,7 +61,7 @@ public function collectionResponse(): JsonResponse $collection = array_map( static function ($item) { - return (new \App\ItemType\AllocatedExpense\Transformers\Transformer($item))->asArray(); + return (new \App\ItemType\AllocatedExpense\Transformers\Item($item))->asArray(); }, $items ); @@ -102,7 +102,7 @@ public function showResponse(int $item_id): JsonResponse } return response()->json( - (new \App\ItemType\AllocatedExpense\Transformers\Transformer($item))->asArray(), + (new \App\ItemType\AllocatedExpense\Transformers\Item($item))->asArray(), 200, $this->showHeaders() ); diff --git a/app/ItemType/AllocatedExpense/ApiResponse/ResourceTypeItem.php b/app/ItemType/AllocatedExpense/ApiResponse/ResourceTypeItem.php index ee876111..7cd58a7b 100644 --- a/app/ItemType/AllocatedExpense/ApiResponse/ResourceTypeItem.php +++ b/app/ItemType/AllocatedExpense/ApiResponse/ResourceTypeItem.php @@ -58,7 +58,7 @@ public function response(): JsonResponse $collection = array_map( static function ($item) { - return (new \App\ItemType\AllocatedExpense\Transformers\ResourceTypeTransformer($item))->asArray(); + return (new \App\ItemType\AllocatedExpense\Transformers\ResourceTypeItem($item))->asArray(); }, $items ); diff --git a/app/ItemType/AllocatedExpense/ApiResponse/Summary.php b/app/ItemType/AllocatedExpense/ApiResponse/Summary.php index a6c87848..057d21cb 100644 --- a/app/ItemType/AllocatedExpense/ApiResponse/Summary.php +++ b/app/ItemType/AllocatedExpense/ApiResponse/Summary.php @@ -123,7 +123,7 @@ protected function categoriesSummary(): JsonResponse $this->parameters ); - $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByCategory($summary))->asArray(); + $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryByCategory($summary))->asArray(); $this->assignToCache( $summary, @@ -147,7 +147,7 @@ protected function categorySummary(): JsonResponse $this->parameters ); - $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByCategory($summary))->asArray(); + $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryByCategory($summary))->asArray(); if (count($collection) === 1) { $collection = $collection[0]; @@ -184,7 +184,7 @@ protected function filteredSummary(): JsonResponse $collection = []; foreach ($summary as $subtotal) { - $collection[] = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformer($subtotal))->asArray(); + $collection[] = (new \App\ItemType\AllocatedExpense\Transformers\Summary($subtotal))->asArray(); } $this->assignToCache( @@ -209,7 +209,7 @@ protected function monthsSummary(): JsonResponse $this->parameters ); - $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByMonth($summary))->asArray(); + $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryByMonth($summary))->asArray(); $this->assignToCache( $summary, @@ -234,7 +234,7 @@ protected function monthSummary(): JsonResponse $this->parameters ); - $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByMonth($summary))->asArray(); + $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryByMonth($summary))->asArray(); if (count($collection) === 1) { $collection = $collection[0]; @@ -323,7 +323,7 @@ protected function subcategoriesSummary(): JsonResponse $this->parameters ); - $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformerBySubcategory($summary))->asArray(); + $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryBySubcategory($summary))->asArray(); $this->assignToCache( $summary, @@ -348,7 +348,7 @@ protected function subcategorySummary(): JsonResponse $this->parameters ); - $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformerBySubcategory($summary))->asArray(); + $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryBySubcategory($summary))->asArray(); if (count($collection) === 1) { $collection = $collection[0]; @@ -379,7 +379,7 @@ protected function summary(): JsonResponse $collection = []; foreach ($summary as $subtotal) { - $collection[] = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformer($subtotal))->asArray(); + $collection[] = (new \App\ItemType\AllocatedExpense\Transformers\Summary($subtotal))->asArray(); } $this->assignToCache( @@ -403,7 +403,7 @@ protected function yearsSummary(): JsonResponse $this->parameters ); - $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByYear($summary))->asArray(); + $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryByYear($summary))->asArray(); $this->assignToCache( $summary, @@ -427,7 +427,7 @@ protected function yearSummary(): JsonResponse $this->parameters ); - $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByYear($summary))->asArray(); + $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryByYear($summary))->asArray(); if (count($collection) === 1) { $collection = $collection[0]; diff --git a/app/ItemType/AllocatedExpense/ApiResponse/SummaryResourceTypeItem.php b/app/ItemType/AllocatedExpense/ApiResponse/SummaryResourceTypeItem.php index 63bb978e..46d5d3a9 100644 --- a/app/ItemType/AllocatedExpense/ApiResponse/SummaryResourceTypeItem.php +++ b/app/ItemType/AllocatedExpense/ApiResponse/SummaryResourceTypeItem.php @@ -124,7 +124,7 @@ protected function categoriesSummary(): JsonResponse $this->parameters ); - $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByCategory($summary))->asArray(); + $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryByCategory($summary))->asArray(); $this->assignToCache( $summary, @@ -147,7 +147,7 @@ protected function categorySummary(): JsonResponse $this->parameters ); - $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByCategory($summary))->asArray(); + $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryByCategory($summary))->asArray(); if (count($collection) === 1) { $collection = $collection[0]; @@ -183,7 +183,7 @@ protected function filteredSummary(): JsonResponse $collection = []; foreach ($summary as $subtotal) { - $collection[] = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformer($subtotal))->asArray(); + $collection[] = (new \App\ItemType\AllocatedExpense\Transformers\Summary($subtotal))->asArray(); } $this->assignToCache( @@ -207,7 +207,7 @@ protected function monthsSummary(): JsonResponse $this->parameters ); - $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByMonth($summary))->asArray(); + $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryByMonth($summary))->asArray(); $this->assignToCache( $summary, @@ -231,7 +231,7 @@ protected function monthSummary(): JsonResponse $this->parameters ); - $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByMonth($summary))->asArray(); + $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryByMonth($summary))->asArray(); if (count($collection) === 1) { $collection = $collection[0]; @@ -325,7 +325,7 @@ protected function resourcesSummary(): JsonResponse $this->parameters ); - $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByResource($summary))->asArray(); + $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryByResource($summary))->asArray(); $this->assignToCache( $summary, @@ -348,7 +348,7 @@ protected function subcategoriesSummary(): JsonResponse $this->parameters ); - $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformerBySubcategory($summary))->asArray(); + $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryBySubcategory($summary))->asArray(); $this->assignToCache( $summary, @@ -372,7 +372,7 @@ protected function subcategorySummary(): JsonResponse $this->parameters ); - $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformerBySubcategory($summary))->asArray(); + $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryBySubcategory($summary))->asArray(); if (count($collection) === 1) { $collection = $collection[0]; @@ -402,7 +402,7 @@ protected function summary(): JsonResponse $collection = []; foreach ($summary as $subtotal) { - $collection[] = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformer($subtotal))->asArray(); + $collection[] = (new \App\ItemType\AllocatedExpense\Transformers\Summary($subtotal))->asArray(); } $this->assignToCache( @@ -425,7 +425,7 @@ protected function yearsSummary(): JsonResponse $this->parameters ); - $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByYear($summary))->asArray(); + $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryByYear($summary))->asArray(); $this->assignToCache( $summary, @@ -448,7 +448,7 @@ protected function yearSummary(): JsonResponse $this->parameters ); - $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryTransformerByYear($summary))->asArray(); + $collection = (new \App\ItemType\AllocatedExpense\Transformers\SummaryByYear($summary))->asArray(); if (count($collection) === 1) { $collection = $collection[0]; diff --git a/app/ItemType/AllocatedExpense/Item.php b/app/ItemType/AllocatedExpense/Item.php index 45e1933d..1104e32d 100644 --- a/app/ItemType/AllocatedExpense/Item.php +++ b/app/ItemType/AllocatedExpense/Item.php @@ -97,7 +97,7 @@ public function resourceTypeSummaryClass(): string public function transformer(array $data_to_transform): Transformer { - return new Transformers\Transformer($data_to_transform); + return new Transformers\Item($data_to_transform); } public function update(array $patch, Model $instance): bool diff --git a/app/ItemType/AllocatedExpense/Transformers/Transformer.php b/app/ItemType/AllocatedExpense/Transformers/Item.php similarity index 97% rename from app/ItemType/AllocatedExpense/Transformers/Transformer.php rename to app/ItemType/AllocatedExpense/Transformers/Item.php index 3f4f421c..f9bbeb79 100644 --- a/app/ItemType/AllocatedExpense/Transformers/Transformer.php +++ b/app/ItemType/AllocatedExpense/Transformers/Item.php @@ -10,7 +10,7 @@ * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class Transformer extends BaseTransformer +class Item extends BaseTransformer { public function format(array $to_transform): void { diff --git a/app/ItemType/AllocatedExpense/Transformers/ResourceTypeTransformer.php b/app/ItemType/AllocatedExpense/Transformers/ResourceTypeItem.php similarity index 96% rename from app/ItemType/AllocatedExpense/Transformers/ResourceTypeTransformer.php rename to app/ItemType/AllocatedExpense/Transformers/ResourceTypeItem.php index 8644d6b2..863c2be3 100644 --- a/app/ItemType/AllocatedExpense/Transformers/ResourceTypeTransformer.php +++ b/app/ItemType/AllocatedExpense/Transformers/ResourceTypeItem.php @@ -10,7 +10,7 @@ * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class ResourceTypeTransformer extends BaseTransformer +class ResourceTypeItem extends BaseTransformer { public function format(array $to_transform): void { diff --git a/app/ItemType/AllocatedExpense/Transformers/SummaryTransformer.php b/app/ItemType/AllocatedExpense/Transformers/Summary.php similarity index 93% rename from app/ItemType/AllocatedExpense/Transformers/SummaryTransformer.php rename to app/ItemType/AllocatedExpense/Transformers/Summary.php index bd19d8bc..600110d1 100644 --- a/app/ItemType/AllocatedExpense/Transformers/SummaryTransformer.php +++ b/app/ItemType/AllocatedExpense/Transformers/Summary.php @@ -10,7 +10,7 @@ * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class SummaryTransformer extends Transformer +class Summary extends Transformer { public function format(array $to_transform): void { diff --git a/app/ItemType/AllocatedExpense/Transformers/SummaryTransformerByCategory.php b/app/ItemType/AllocatedExpense/Transformers/SummaryByCategory.php similarity index 95% rename from app/ItemType/AllocatedExpense/Transformers/SummaryTransformerByCategory.php rename to app/ItemType/AllocatedExpense/Transformers/SummaryByCategory.php index 3f328b78..eefb9529 100644 --- a/app/ItemType/AllocatedExpense/Transformers/SummaryTransformerByCategory.php +++ b/app/ItemType/AllocatedExpense/Transformers/SummaryByCategory.php @@ -10,7 +10,7 @@ * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class SummaryTransformerByCategory extends Transformer +class SummaryByCategory extends Transformer { public function format(array $to_transform): void { diff --git a/app/ItemType/AllocatedExpense/Transformers/SummaryTransformerByMonth.php b/app/ItemType/AllocatedExpense/Transformers/SummaryByMonth.php similarity index 95% rename from app/ItemType/AllocatedExpense/Transformers/SummaryTransformerByMonth.php rename to app/ItemType/AllocatedExpense/Transformers/SummaryByMonth.php index 481d0f1a..c2c55714 100644 --- a/app/ItemType/AllocatedExpense/Transformers/SummaryTransformerByMonth.php +++ b/app/ItemType/AllocatedExpense/Transformers/SummaryByMonth.php @@ -10,7 +10,7 @@ * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class SummaryTransformerByMonth extends Transformer +class SummaryByMonth extends Transformer { public function format(array $to_transform): void { diff --git a/app/ItemType/AllocatedExpense/Transformers/SummaryTransformerByResource.php b/app/ItemType/AllocatedExpense/Transformers/SummaryByResource.php similarity index 95% rename from app/ItemType/AllocatedExpense/Transformers/SummaryTransformerByResource.php rename to app/ItemType/AllocatedExpense/Transformers/SummaryByResource.php index d301e6c1..67a80fcc 100644 --- a/app/ItemType/AllocatedExpense/Transformers/SummaryTransformerByResource.php +++ b/app/ItemType/AllocatedExpense/Transformers/SummaryByResource.php @@ -10,7 +10,7 @@ * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class SummaryTransformerByResource extends Transformer +class SummaryByResource extends Transformer { public function format(array $to_transform): void { diff --git a/app/ItemType/AllocatedExpense/Transformers/SummaryTransformerBySubcategory.php b/app/ItemType/AllocatedExpense/Transformers/SummaryBySubcategory.php similarity index 95% rename from app/ItemType/AllocatedExpense/Transformers/SummaryTransformerBySubcategory.php rename to app/ItemType/AllocatedExpense/Transformers/SummaryBySubcategory.php index d2a29a60..96f61de1 100644 --- a/app/ItemType/AllocatedExpense/Transformers/SummaryTransformerBySubcategory.php +++ b/app/ItemType/AllocatedExpense/Transformers/SummaryBySubcategory.php @@ -10,7 +10,7 @@ * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class SummaryTransformerBySubcategory extends Transformer +class SummaryBySubcategory extends Transformer { public function format(array $to_transform): void { diff --git a/app/ItemType/AllocatedExpense/Transformers/SummaryTransformerByYear.php b/app/ItemType/AllocatedExpense/Transformers/SummaryByYear.php similarity index 95% rename from app/ItemType/AllocatedExpense/Transformers/SummaryTransformerByYear.php rename to app/ItemType/AllocatedExpense/Transformers/SummaryByYear.php index 66af32b5..a38a50c2 100644 --- a/app/ItemType/AllocatedExpense/Transformers/SummaryTransformerByYear.php +++ b/app/ItemType/AllocatedExpense/Transformers/SummaryByYear.php @@ -10,7 +10,7 @@ * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class SummaryTransformerByYear extends Transformer +class SummaryByYear extends Transformer { public function format(array $to_transform): void { diff --git a/app/ItemType/Game/ApiResponse/Item.php b/app/ItemType/Game/ApiResponse/Item.php index 92d8682e..41b0251e 100644 --- a/app/ItemType/Game/ApiResponse/Item.php +++ b/app/ItemType/Game/ApiResponse/Item.php @@ -57,7 +57,7 @@ public function collectionResponse(): JsonResponse $collection = array_map( static function ($item) { - return (new \App\ItemType\Game\Transformers\Transformer($item))->asArray(); + return (new \App\ItemType\Game\Transformers\Item($item))->asArray(); }, $items ); @@ -98,7 +98,7 @@ public function showResponse(int $item_id): JsonResponse } return response()->json( - (new \App\ItemType\Game\Transformers\Transformer($item))->asArray(), + (new \App\ItemType\Game\Transformers\Item($item))->asArray(), 200, $this->showHeaders() ); diff --git a/app/ItemType/Game/ApiResponse/ResourceTypeItem.php b/app/ItemType/Game/ApiResponse/ResourceTypeItem.php index d57d2ad3..e329ed26 100644 --- a/app/ItemType/Game/ApiResponse/ResourceTypeItem.php +++ b/app/ItemType/Game/ApiResponse/ResourceTypeItem.php @@ -54,7 +54,7 @@ public function response(): JsonResponse $collection = array_map( static function ($item) { - return (new \App\ItemType\Game\Transformers\ResourceTypeTransformer($item))->asArray(); + return (new \App\ItemType\Game\Transformers\ResourceTypeItem($item))->asArray(); }, $items ); diff --git a/app/ItemType/Game/ApiResponse/Summary.php b/app/ItemType/Game/ApiResponse/Summary.php index 48efd645..6d416b52 100644 --- a/app/ItemType/Game/ApiResponse/Summary.php +++ b/app/ItemType/Game/ApiResponse/Summary.php @@ -58,7 +58,7 @@ protected function filteredSummary(): JsonResponse $collection = []; foreach ($summary as $subtotal) { - $collection[] = (new \App\ItemType\Game\Transformers\SummaryTransformer($subtotal))->asArray(); + $collection[] = (new \App\ItemType\Game\Transformers\Summary($subtotal))->asArray(); } $this->assignToCache( @@ -89,7 +89,7 @@ protected function summary(): JsonResponse $collection = []; foreach ($summary as $subtotal) { - $collection[] = (new \App\ItemType\Game\Transformers\SummaryTransformer($subtotal))->asArray(); + $collection[] = (new \App\ItemType\Game\Transformers\Summary($subtotal))->asArray(); } $this->assignToCache( diff --git a/app/ItemType/Game/ApiResponse/SummaryResourceTypeItem.php b/app/ItemType/Game/ApiResponse/SummaryResourceTypeItem.php index 860e9da3..51793e23 100644 --- a/app/ItemType/Game/ApiResponse/SummaryResourceTypeItem.php +++ b/app/ItemType/Game/ApiResponse/SummaryResourceTypeItem.php @@ -59,7 +59,7 @@ protected function filteredSummary(): JsonResponse $collection = []; foreach ($summary as $subtotal) { - $collection[] = (new \App\ItemType\Game\Transformers\SummaryTransformer($subtotal))->asArray(); + $collection[] = (new \App\ItemType\Game\Transformers\Summary($subtotal))->asArray(); } $this->assignToCache( @@ -96,7 +96,7 @@ protected function resourcesSummary(): JsonResponse $this->parameters ); - $collection = (new \App\ItemType\Game\Transformers\SummaryTransformerByResource($summary))->asArray(); + $collection = (new \App\ItemType\Game\Transformers\SummaryByResource($summary))->asArray(); $this->assignToCache( $summary, @@ -120,7 +120,7 @@ protected function summary(): JsonResponse $collection = []; foreach ($summary as $subtotal) { - $collection[] = (new \App\ItemType\Game\Transformers\SummaryTransformer($subtotal))->asArray(); + $collection[] = (new \App\ItemType\Game\Transformers\Summary($subtotal))->asArray(); } $this->assignToCache( diff --git a/app/ItemType/Game/Item.php b/app/ItemType/Game/Item.php index 8efbd649..5db491d2 100644 --- a/app/ItemType/Game/Item.php +++ b/app/ItemType/Game/Item.php @@ -77,7 +77,7 @@ public function type(): string public function transformer(array $data_to_transform): Transformer { - return new Transformers\Transformer($data_to_transform); + return new Transformers\Item($data_to_transform); } public function update(array $patch, Model $instance): bool diff --git a/app/ItemType/Game/Transformers/Transformer.php b/app/ItemType/Game/Transformers/Item.php similarity index 97% rename from app/ItemType/Game/Transformers/Transformer.php rename to app/ItemType/Game/Transformers/Item.php index 1b8d95dd..c2ef301a 100644 --- a/app/ItemType/Game/Transformers/Transformer.php +++ b/app/ItemType/Game/Transformers/Item.php @@ -10,7 +10,7 @@ * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class Transformer extends BaseTransformer +class Item extends BaseTransformer { public function format(array $to_transform): void { diff --git a/app/ItemType/Game/Transformers/ResourceTypeTransformer.php b/app/ItemType/Game/Transformers/ResourceTypeItem.php similarity index 97% rename from app/ItemType/Game/Transformers/ResourceTypeTransformer.php rename to app/ItemType/Game/Transformers/ResourceTypeItem.php index dfe23d29..025e820c 100644 --- a/app/ItemType/Game/Transformers/ResourceTypeTransformer.php +++ b/app/ItemType/Game/Transformers/ResourceTypeItem.php @@ -10,7 +10,7 @@ * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class ResourceTypeTransformer extends BaseTransformer +class ResourceTypeItem extends BaseTransformer { public function format(array $to_transform): void { diff --git a/app/ItemType/Game/Transformers/SummaryTransformer.php b/app/ItemType/Game/Transformers/Summary.php similarity index 97% rename from app/ItemType/Game/Transformers/SummaryTransformer.php rename to app/ItemType/Game/Transformers/Summary.php index 794a1541..3c25f934 100644 --- a/app/ItemType/Game/Transformers/SummaryTransformer.php +++ b/app/ItemType/Game/Transformers/Summary.php @@ -10,7 +10,7 @@ * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class SummaryTransformer extends Transformer +class Summary extends Transformer { public function format(array $to_transform): void { diff --git a/app/ItemType/Game/Transformers/SummaryTransformerByResource.php b/app/ItemType/Game/Transformers/SummaryByResource.php similarity index 96% rename from app/ItemType/Game/Transformers/SummaryTransformerByResource.php rename to app/ItemType/Game/Transformers/SummaryByResource.php index a94381e8..a4084ae8 100644 --- a/app/ItemType/Game/Transformers/SummaryTransformerByResource.php +++ b/app/ItemType/Game/Transformers/SummaryByResource.php @@ -10,7 +10,7 @@ * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class SummaryTransformerByResource extends Transformer +class SummaryByResource extends Transformer { public function format(array $to_transform): void { diff --git a/app/ItemType/SimpleExpense/ApiResponse/Item.php b/app/ItemType/SimpleExpense/ApiResponse/Item.php index 88336742..65950d3a 100644 --- a/app/ItemType/SimpleExpense/ApiResponse/Item.php +++ b/app/ItemType/SimpleExpense/ApiResponse/Item.php @@ -57,7 +57,7 @@ public function collectionResponse(): JsonResponse $collection = array_map( static function ($item) { - return (new \App\ItemType\SimpleExpense\Transformers\Transformer($item))->asArray(); + return (new \App\ItemType\SimpleExpense\Transformers\Item($item))->asArray(); }, $items ); @@ -98,7 +98,7 @@ public function showResponse(int $item_id): JsonResponse } return response()->json( - (new \App\ItemType\SimpleExpense\Transformers\Transformer($item))->asArray(), + (new \App\ItemType\SimpleExpense\Transformers\Item($item))->asArray(), 200, $this->showHeaders() ); diff --git a/app/ItemType/SimpleExpense/ApiResponse/ResourceTypeItem.php b/app/ItemType/SimpleExpense/ApiResponse/ResourceTypeItem.php index b62799bd..9861b665 100644 --- a/app/ItemType/SimpleExpense/ApiResponse/ResourceTypeItem.php +++ b/app/ItemType/SimpleExpense/ApiResponse/ResourceTypeItem.php @@ -54,7 +54,7 @@ public function response(): JsonResponse $collection = array_map( static function ($item) { - return (new \App\ItemType\SimpleExpense\Transformers\ResourceTypeTransformer($item))->asArray(); + return (new \App\ItemType\SimpleExpense\Transformers\ResourceTypeItem($item))->asArray(); }, $items ); diff --git a/app/ItemType/SimpleExpense/ApiResponse/Summary.php b/app/ItemType/SimpleExpense/ApiResponse/Summary.php index cf137f66..b8d21785 100644 --- a/app/ItemType/SimpleExpense/ApiResponse/Summary.php +++ b/app/ItemType/SimpleExpense/ApiResponse/Summary.php @@ -77,7 +77,7 @@ protected function categoriesSummary(): JsonResponse $this->parameters ); - $collection = (new \App\ItemType\SimpleExpense\Transformers\SummaryTransformerByCategory($summary))->asArray(); + $collection = (new \App\ItemType\SimpleExpense\Transformers\SummaryByCategory($summary))->asArray(); $this->assignToCache( $summary, @@ -101,7 +101,7 @@ protected function categorySummary(): JsonResponse $this->parameters ); - $collection = (new \App\ItemType\SimpleExpense\Transformers\SummaryTransformerByCategory($summary))->asArray(); + $collection = (new \App\ItemType\SimpleExpense\Transformers\SummaryByCategory($summary))->asArray(); if (count($collection) === 1) { $collection = $collection[0]; @@ -136,7 +136,7 @@ protected function filteredSummary(): JsonResponse $collection = []; foreach ($summary as $subtotal) { - $collection[] = (new \App\ItemType\SimpleExpense\Transformers\SummaryTransformer($subtotal))->asArray(); + $collection[] = (new \App\ItemType\SimpleExpense\Transformers\Summary($subtotal))->asArray(); } $this->assignToCache( @@ -194,7 +194,7 @@ protected function subcategoriesSummary(): JsonResponse $this->parameters ); - $collection = (new \App\ItemType\SimpleExpense\Transformers\SummaryTransformerBySubcategory($summary))->asArray(); + $collection = (new \App\ItemType\SimpleExpense\Transformers\SummaryBySubcategory($summary))->asArray(); $this->assignToCache( $summary, @@ -219,7 +219,7 @@ protected function subcategorySummary(): JsonResponse $this->parameters ); - $collection = (new \App\ItemType\SimpleExpense\Transformers\SummaryTransformerBySubcategory($summary))->asArray(); + $collection = (new \App\ItemType\SimpleExpense\Transformers\SummaryBySubcategory($summary))->asArray(); if (count($collection) === 1) { $collection = $collection[0]; @@ -250,7 +250,7 @@ protected function summary(): JsonResponse $collection = []; foreach ($summary as $subtotal) { - $collection[] = (new \App\ItemType\SimpleExpense\Transformers\SummaryTransformer($subtotal))->asArray(); + $collection[] = (new \App\ItemType\SimpleExpense\Transformers\Summary($subtotal))->asArray(); } $this->assignToCache( diff --git a/app/ItemType/SimpleExpense/ApiResponse/SummaryResourceTypeItem.php b/app/ItemType/SimpleExpense/ApiResponse/SummaryResourceTypeItem.php index 8b9b54ca..80b3e4af 100644 --- a/app/ItemType/SimpleExpense/ApiResponse/SummaryResourceTypeItem.php +++ b/app/ItemType/SimpleExpense/ApiResponse/SummaryResourceTypeItem.php @@ -77,7 +77,7 @@ protected function categoriesSummary(): JsonResponse $this->parameters ); - $collection = (new \App\ItemType\SimpleExpense\Transformers\SummaryTransformerByCategory($summary))->asArray(); + $collection = (new \App\ItemType\SimpleExpense\Transformers\SummaryByCategory($summary))->asArray(); $this->assignToCache( $summary, @@ -100,7 +100,7 @@ protected function categorySummary(): JsonResponse $this->parameters ); - $collection = (new \App\ItemType\SimpleExpense\Transformers\SummaryTransformerByCategory($summary))->asArray(); + $collection = (new \App\ItemType\SimpleExpense\Transformers\SummaryByCategory($summary))->asArray(); if (count($collection) === 1) { $collection = $collection[0]; @@ -133,7 +133,7 @@ protected function filteredSummary(): JsonResponse $collection = []; foreach ($summary as $subtotal) { - $collection[] = (new \App\ItemType\SimpleExpense\Transformers\SummaryTransformer($subtotal))->asArray(); + $collection[] = (new \App\ItemType\SimpleExpense\Transformers\Summary($subtotal))->asArray(); } $this->assignToCache( @@ -196,7 +196,7 @@ protected function resourcesSummary(): JsonResponse $this->parameters ); - $collection = (new \App\ItemType\SimpleExpense\Transformers\SummaryTransformerByResource($summary))->asArray(); + $collection = (new \App\ItemType\SimpleExpense\Transformers\SummaryByResource($summary))->asArray(); $this->assignToCache( $summary, @@ -219,7 +219,7 @@ protected function subcategoriesSummary(): JsonResponse $this->parameters ); - $collection = (new \App\ItemType\SimpleExpense\Transformers\SummaryTransformerBySubcategory($summary))->asArray(); + $collection = (new \App\ItemType\SimpleExpense\Transformers\SummaryBySubcategory($summary))->asArray(); $this->assignToCache( $summary, @@ -243,7 +243,7 @@ protected function subcategorySummary(): JsonResponse $this->parameters ); - $collection = (new \App\ItemType\SimpleExpense\Transformers\SummaryTransformerBySubcategory($summary))->asArray(); + $collection = (new \App\ItemType\SimpleExpense\Transformers\SummaryBySubcategory($summary))->asArray(); if (count($collection) === 1) { $collection = $collection[0]; @@ -273,7 +273,7 @@ protected function summary(): JsonResponse $collection = []; foreach ($summary as $subtotal) { - $collection[] = (new \App\ItemType\SimpleExpense\Transformers\SummaryTransformer($subtotal))->asArray(); + $collection[] = (new \App\ItemType\SimpleExpense\Transformers\Summary($subtotal))->asArray(); } $this->assignToCache( diff --git a/app/ItemType/SimpleExpense/Item.php b/app/ItemType/SimpleExpense/Item.php index eee421d6..ebee8f4a 100644 --- a/app/ItemType/SimpleExpense/Item.php +++ b/app/ItemType/SimpleExpense/Item.php @@ -79,7 +79,7 @@ public function resourceTypeSummaryClass(): string public function transformer(array $data_to_transform): Transformer { - return new Transformers\Transformer($data_to_transform); + return new Transformers\Item($data_to_transform); } public function update(array $patch, Model $instance): bool diff --git a/app/ItemType/SimpleExpense/Transformers/Transformer.php b/app/ItemType/SimpleExpense/Transformers/Item.php similarity index 96% rename from app/ItemType/SimpleExpense/Transformers/Transformer.php rename to app/ItemType/SimpleExpense/Transformers/Item.php index 28a8e786..dac76bd3 100644 --- a/app/ItemType/SimpleExpense/Transformers/Transformer.php +++ b/app/ItemType/SimpleExpense/Transformers/Item.php @@ -10,7 +10,7 @@ * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class Transformer extends BaseTransformer +class Item extends BaseTransformer { public function format(array $to_transform): void { diff --git a/app/ItemType/SimpleExpense/Transformers/ResourceTypeTransformer.php b/app/ItemType/SimpleExpense/Transformers/ResourceTypeItem.php similarity index 96% rename from app/ItemType/SimpleExpense/Transformers/ResourceTypeTransformer.php rename to app/ItemType/SimpleExpense/Transformers/ResourceTypeItem.php index d3be1077..fadc3b35 100644 --- a/app/ItemType/SimpleExpense/Transformers/ResourceTypeTransformer.php +++ b/app/ItemType/SimpleExpense/Transformers/ResourceTypeItem.php @@ -10,7 +10,7 @@ * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class ResourceTypeTransformer extends BaseTransformer +class ResourceTypeItem extends BaseTransformer { public function format(array $to_transform): void { diff --git a/app/ItemType/SimpleExpense/Transformers/SummaryTransformer.php b/app/ItemType/SimpleExpense/Transformers/Summary.php similarity index 93% rename from app/ItemType/SimpleExpense/Transformers/SummaryTransformer.php rename to app/ItemType/SimpleExpense/Transformers/Summary.php index a0d732c7..d3cb21b3 100644 --- a/app/ItemType/SimpleExpense/Transformers/SummaryTransformer.php +++ b/app/ItemType/SimpleExpense/Transformers/Summary.php @@ -10,7 +10,7 @@ * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class SummaryTransformer extends Transformer +class Summary extends Transformer { public function format(array $to_transform): void { diff --git a/app/ItemType/SimpleExpense/Transformers/SummaryTransformerByCategory.php b/app/ItemType/SimpleExpense/Transformers/SummaryByCategory.php similarity index 95% rename from app/ItemType/SimpleExpense/Transformers/SummaryTransformerByCategory.php rename to app/ItemType/SimpleExpense/Transformers/SummaryByCategory.php index ecf454b5..8d6271b1 100644 --- a/app/ItemType/SimpleExpense/Transformers/SummaryTransformerByCategory.php +++ b/app/ItemType/SimpleExpense/Transformers/SummaryByCategory.php @@ -10,7 +10,7 @@ * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class SummaryTransformerByCategory extends Transformer +class SummaryByCategory extends Transformer { public function format(array $to_transform): void { diff --git a/app/ItemType/SimpleExpense/Transformers/SummaryTransformerByResource.php b/app/ItemType/SimpleExpense/Transformers/SummaryByResource.php similarity index 95% rename from app/ItemType/SimpleExpense/Transformers/SummaryTransformerByResource.php rename to app/ItemType/SimpleExpense/Transformers/SummaryByResource.php index ce0afa83..9da5370f 100644 --- a/app/ItemType/SimpleExpense/Transformers/SummaryTransformerByResource.php +++ b/app/ItemType/SimpleExpense/Transformers/SummaryByResource.php @@ -10,7 +10,7 @@ * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class SummaryTransformerByResource extends Transformer +class SummaryByResource extends Transformer { public function format(array $to_transform): void { diff --git a/app/ItemType/SimpleExpense/Transformers/SummaryTransformerBySubcategory.php b/app/ItemType/SimpleExpense/Transformers/SummaryBySubcategory.php similarity index 95% rename from app/ItemType/SimpleExpense/Transformers/SummaryTransformerBySubcategory.php rename to app/ItemType/SimpleExpense/Transformers/SummaryBySubcategory.php index 226ef0bd..4f5ead2b 100644 --- a/app/ItemType/SimpleExpense/Transformers/SummaryTransformerBySubcategory.php +++ b/app/ItemType/SimpleExpense/Transformers/SummaryBySubcategory.php @@ -10,7 +10,7 @@ * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class SummaryTransformerBySubcategory extends Transformer +class SummaryBySubcategory extends Transformer { public function format(array $to_transform): void { diff --git a/app/ItemType/SimpleItem/ApiResponse/Item.php b/app/ItemType/SimpleItem/ApiResponse/Item.php index 93201615..317938c8 100644 --- a/app/ItemType/SimpleItem/ApiResponse/Item.php +++ b/app/ItemType/SimpleItem/ApiResponse/Item.php @@ -56,7 +56,7 @@ public function collectionResponse(): JsonResponse $collection = array_map( static function ($item) { - return (new \App\ItemType\SimpleItem\Transformers\Transformer($item))->asArray(); + return (new \App\ItemType\SimpleItem\Transformers\Item($item))->asArray(); }, $items ); @@ -97,7 +97,7 @@ public function showResponse(int $item_id): JsonResponse } return response()->json( - (new \App\ItemType\SimpleItem\Transformers\Transformer($item))->asArray(), + (new \App\ItemType\SimpleItem\Transformers\Item($item))->asArray(), 200, $this->showHeaders() ); diff --git a/app/ItemType/SimpleItem/ApiResponse/ResourceTypeItem.php b/app/ItemType/SimpleItem/ApiResponse/ResourceTypeItem.php index f46c9766..abe0cd9c 100644 --- a/app/ItemType/SimpleItem/ApiResponse/ResourceTypeItem.php +++ b/app/ItemType/SimpleItem/ApiResponse/ResourceTypeItem.php @@ -52,7 +52,7 @@ public function response(): JsonResponse $collection = array_map( static function ($item) { - return (new \App\ItemType\SimpleItem\Transformers\ResourceTypeTransformer($item))->asArray(); + return (new \App\ItemType\SimpleItem\Transformers\ResourceTypeItem($item))->asArray(); }, $items ); diff --git a/app/ItemType/SimpleItem/ApiResponse/Summary.php b/app/ItemType/SimpleItem/ApiResponse/Summary.php index c4a64c8c..6c778488 100644 --- a/app/ItemType/SimpleItem/ApiResponse/Summary.php +++ b/app/ItemType/SimpleItem/ApiResponse/Summary.php @@ -58,7 +58,7 @@ protected function filteredSummary(): JsonResponse $collection = []; foreach ($summary as $subtotal) { - $collection[] = (new \App\ItemType\SimpleItem\Transformers\SummaryTransformer($subtotal))->asArray(); + $collection[] = (new \App\ItemType\SimpleItem\Transformers\Summary($subtotal))->asArray(); } $this->assignToCache( @@ -89,7 +89,7 @@ protected function summary(): JsonResponse $collection = []; foreach ($summary as $subtotal) { - $collection[] = (new \App\ItemType\SimpleItem\Transformers\SummaryTransformer($subtotal))->asArray(); + $collection[] = (new \App\ItemType\SimpleItem\Transformers\Summary($subtotal))->asArray(); } $this->assignToCache( diff --git a/app/ItemType/SimpleItem/ApiResponse/SummaryResourceTypeItem.php b/app/ItemType/SimpleItem/ApiResponse/SummaryResourceTypeItem.php index 17c71c30..cda80029 100644 --- a/app/ItemType/SimpleItem/ApiResponse/SummaryResourceTypeItem.php +++ b/app/ItemType/SimpleItem/ApiResponse/SummaryResourceTypeItem.php @@ -59,7 +59,7 @@ protected function filteredSummary(): JsonResponse $collection = []; foreach ($summary as $subtotal) { - $collection[] = (new \App\ItemType\SimpleItem\Transformers\SummaryTransformer($subtotal))->asArray(); + $collection[] = (new \App\ItemType\SimpleItem\Transformers\Summary($subtotal))->asArray(); } $this->assignToCache( @@ -96,7 +96,7 @@ protected function resourcesSummary(): JsonResponse $this->parameters ); - $collection = (new \App\ItemType\SimpleItem\Transformers\SummaryTransformerByResource($summary))->asArray(); + $collection = (new \App\ItemType\SimpleItem\Transformers\SummaryByResource($summary))->asArray(); $this->assignToCache( $summary, @@ -120,7 +120,7 @@ protected function summary(): JsonResponse $collection = []; foreach ($summary as $subtotal) { - $collection[] = (new \App\ItemType\SimpleItem\Transformers\SummaryTransformer($subtotal))->asArray(); + $collection[] = (new \App\ItemType\SimpleItem\Transformers\Summary($subtotal))->asArray(); } $this->assignToCache( diff --git a/app/ItemType/SimpleItem/Item.php b/app/ItemType/SimpleItem/Item.php index 7aba5366..1b185679 100644 --- a/app/ItemType/SimpleItem/Item.php +++ b/app/ItemType/SimpleItem/Item.php @@ -83,7 +83,7 @@ public function resourceTypeSummaryClass(): string public function transformer(array $data_to_transform): Transformer { - return new Transformers\Transformer($data_to_transform); + return new Transformers\Item($data_to_transform); } public function update(array $patch, Model $instance): bool diff --git a/app/ItemType/SimpleItem/Transformers/Transformer.php b/app/ItemType/SimpleItem/Transformers/Item.php similarity index 94% rename from app/ItemType/SimpleItem/Transformers/Transformer.php rename to app/ItemType/SimpleItem/Transformers/Item.php index 21140fd1..feccdaec 100644 --- a/app/ItemType/SimpleItem/Transformers/Transformer.php +++ b/app/ItemType/SimpleItem/Transformers/Item.php @@ -10,7 +10,7 @@ * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class Transformer extends BaseTransformer +class Item extends BaseTransformer { public function format(array $to_transform): void { diff --git a/app/ItemType/SimpleItem/Transformers/ResourceTypeTransformer.php b/app/ItemType/SimpleItem/Transformers/ResourceTypeItem.php similarity index 95% rename from app/ItemType/SimpleItem/Transformers/ResourceTypeTransformer.php rename to app/ItemType/SimpleItem/Transformers/ResourceTypeItem.php index 08b1fca8..4ad09a31 100644 --- a/app/ItemType/SimpleItem/Transformers/ResourceTypeTransformer.php +++ b/app/ItemType/SimpleItem/Transformers/ResourceTypeItem.php @@ -10,7 +10,7 @@ * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class ResourceTypeTransformer extends BaseTransformer +class ResourceTypeItem extends BaseTransformer { public function format(array $to_transform): void { diff --git a/app/ItemType/SimpleItem/Transformers/SummaryTransformer.php b/app/ItemType/SimpleItem/Transformers/Summary.php similarity index 91% rename from app/ItemType/SimpleItem/Transformers/SummaryTransformer.php rename to app/ItemType/SimpleItem/Transformers/Summary.php index 891551c8..40fe2311 100644 --- a/app/ItemType/SimpleItem/Transformers/SummaryTransformer.php +++ b/app/ItemType/SimpleItem/Transformers/Summary.php @@ -10,7 +10,7 @@ * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class SummaryTransformer extends Transformer +class Summary extends Transformer { public function format(array $to_transform): void { diff --git a/app/ItemType/SimpleItem/Transformers/SummaryTransformerByResource.php b/app/ItemType/SimpleItem/Transformers/SummaryByResource.php similarity index 92% rename from app/ItemType/SimpleItem/Transformers/SummaryTransformerByResource.php rename to app/ItemType/SimpleItem/Transformers/SummaryByResource.php index ccd15b00..bef1ca17 100644 --- a/app/ItemType/SimpleItem/Transformers/SummaryTransformerByResource.php +++ b/app/ItemType/SimpleItem/Transformers/SummaryByResource.php @@ -10,7 +10,7 @@ * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class SummaryTransformerByResource extends Transformer +class SummaryByResource extends Transformer { public function format(array $to_transform): void { From 0cf97edd550e75e8aa893278ed2f6cbe4acbd116 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Sun, 16 Jan 2022 15:06:20 +0000 Subject: [PATCH 28/73] Refactoring - No need to alias all the base classes --- app/ItemType/AllocatedExpense/ApiResponse/Item.php | 4 ++-- .../AllocatedExpense/ApiResponse/ResourceTypeItem.php | 4 ++-- app/ItemType/AllocatedExpense/ApiResponse/Summary.php | 4 ++-- .../AllocatedExpense/ApiResponse/SummaryResourceTypeItem.php | 4 ++-- app/ItemType/AllocatedExpense/Transformers/Item.php | 4 ++-- .../AllocatedExpense/Transformers/ResourceTypeItem.php | 4 ++-- app/ItemType/Game/ApiResponse/Item.php | 4 ++-- app/ItemType/Game/ApiResponse/ResourceTypeItem.php | 4 ++-- app/ItemType/Game/ApiResponse/Summary.php | 4 ++-- app/ItemType/Game/ApiResponse/SummaryResourceTypeItem.php | 4 ++-- app/ItemType/Game/Transformers/Item.php | 4 ++-- app/ItemType/Game/Transformers/ResourceTypeItem.php | 4 ++-- app/ItemType/SimpleExpense/ApiResponse/Item.php | 4 ++-- app/ItemType/SimpleExpense/ApiResponse/ResourceTypeItem.php | 4 ++-- app/ItemType/SimpleExpense/ApiResponse/Summary.php | 4 ++-- .../SimpleExpense/ApiResponse/SummaryResourceTypeItem.php | 4 ++-- app/ItemType/SimpleExpense/Transformers/Item.php | 4 ++-- app/ItemType/SimpleExpense/Transformers/ResourceTypeItem.php | 4 ++-- app/ItemType/SimpleItem/ApiResponse/Item.php | 4 ++-- app/ItemType/SimpleItem/ApiResponse/ResourceTypeItem.php | 4 ++-- app/ItemType/SimpleItem/ApiResponse/Summary.php | 4 ++-- .../SimpleItem/ApiResponse/SummaryResourceTypeItem.php | 4 ++-- app/ItemType/SimpleItem/Transformers/Item.php | 4 ++-- app/ItemType/SimpleItem/Transformers/ResourceTypeItem.php | 4 ++-- 24 files changed, 48 insertions(+), 48 deletions(-) diff --git a/app/ItemType/AllocatedExpense/ApiResponse/Item.php b/app/ItemType/AllocatedExpense/ApiResponse/Item.php index 7435d82f..3291fce0 100644 --- a/app/ItemType/AllocatedExpense/ApiResponse/Item.php +++ b/app/ItemType/AllocatedExpense/ApiResponse/Item.php @@ -3,14 +3,14 @@ namespace App\ItemType\AllocatedExpense\ApiResponse; -use App\ItemType\ApiResponse as ItemTypeResponse; +use App\ItemType\ApiResponse; use App\Response\Responses; use Illuminate\Http\JsonResponse; use function request; use function response; use function trans; -class Item extends ItemTypeResponse +class Item extends ApiResponse { public function collectionResponse(): JsonResponse { diff --git a/app/ItemType/AllocatedExpense/ApiResponse/ResourceTypeItem.php b/app/ItemType/AllocatedExpense/ApiResponse/ResourceTypeItem.php index 7cd58a7b..159ad037 100644 --- a/app/ItemType/AllocatedExpense/ApiResponse/ResourceTypeItem.php +++ b/app/ItemType/AllocatedExpense/ApiResponse/ResourceTypeItem.php @@ -4,12 +4,12 @@ namespace App\ItemType\AllocatedExpense\ApiResponse; use App\ItemType\AllocatedExpense\Item; -use App\ItemType\ApiResourceTypeResponse as BaseResourceTypeResponse; +use App\ItemType\ApiResourceTypeResponse; use Illuminate\Http\JsonResponse; use function request; use function response; -class ResourceTypeItem extends BaseResourceTypeResponse +class ResourceTypeItem extends ApiResourceTypeResponse { public function response(): JsonResponse { diff --git a/app/ItemType/AllocatedExpense/ApiResponse/Summary.php b/app/ItemType/AllocatedExpense/ApiResponse/Summary.php index 057d21cb..c9bb20e2 100644 --- a/app/ItemType/AllocatedExpense/ApiResponse/Summary.php +++ b/app/ItemType/AllocatedExpense/ApiResponse/Summary.php @@ -3,13 +3,13 @@ namespace App\ItemType\AllocatedExpense\ApiResponse; use App\ItemType\AllocatedExpense\Item; -use App\ItemType\ApiSummaryResponse as BaseSummaryResponse; +use App\ItemType\ApiSummaryResponse; use App\Request\Validate\Boolean; use Illuminate\Http\JsonResponse; use function request; use function response; -class Summary extends BaseSummaryResponse +class Summary extends ApiSummaryResponse { public function __construct( int $resource_type_id, diff --git a/app/ItemType/AllocatedExpense/ApiResponse/SummaryResourceTypeItem.php b/app/ItemType/AllocatedExpense/ApiResponse/SummaryResourceTypeItem.php index 46d5d3a9..743b35e0 100644 --- a/app/ItemType/AllocatedExpense/ApiResponse/SummaryResourceTypeItem.php +++ b/app/ItemType/AllocatedExpense/ApiResponse/SummaryResourceTypeItem.php @@ -3,13 +3,13 @@ namespace App\ItemType\AllocatedExpense\ApiResponse; use App\ItemType\AllocatedExpense\Item; -use App\ItemType\ApiSummaryResourceTypeResponse as BaseSummaryResourceTypeResponse; +use App\ItemType\ApiSummaryResourceTypeResponse; use App\Request\Validate\Boolean; use Illuminate\Http\JsonResponse; use function request; use function response; -class SummaryResourceTypeItem extends BaseSummaryResourceTypeResponse +class SummaryResourceTypeItem extends ApiSummaryResourceTypeResponse { public function __construct( int $resource_type_id, diff --git a/app/ItemType/AllocatedExpense/Transformers/Item.php b/app/ItemType/AllocatedExpense/Transformers/Item.php index f9bbeb79..c356bf21 100644 --- a/app/ItemType/AllocatedExpense/Transformers/Item.php +++ b/app/ItemType/AllocatedExpense/Transformers/Item.php @@ -3,14 +3,14 @@ namespace App\ItemType\AllocatedExpense\Transformers; -use App\Transformers\Transformer as BaseTransformer; +use App\Transformers\Transformer; /** * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class Item extends BaseTransformer +class Item extends Transformer { public function format(array $to_transform): void { diff --git a/app/ItemType/AllocatedExpense/Transformers/ResourceTypeItem.php b/app/ItemType/AllocatedExpense/Transformers/ResourceTypeItem.php index 863c2be3..63799e2d 100644 --- a/app/ItemType/AllocatedExpense/Transformers/ResourceTypeItem.php +++ b/app/ItemType/AllocatedExpense/Transformers/ResourceTypeItem.php @@ -3,14 +3,14 @@ namespace App\ItemType\AllocatedExpense\Transformers; -use App\Transformers\Transformer as BaseTransformer; +use App\Transformers\Transformer; /** * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class ResourceTypeItem extends BaseTransformer +class ResourceTypeItem extends Transformer { public function format(array $to_transform): void { diff --git a/app/ItemType/Game/ApiResponse/Item.php b/app/ItemType/Game/ApiResponse/Item.php index 41b0251e..d6b87fe5 100644 --- a/app/ItemType/Game/ApiResponse/Item.php +++ b/app/ItemType/Game/ApiResponse/Item.php @@ -3,14 +3,14 @@ namespace App\ItemType\Game\ApiResponse; -use App\ItemType\ApiResponse as ItemTypeResponse; +use App\ItemType\ApiResponse; use App\Response\Responses; use Illuminate\Http\JsonResponse; use function request; use function response; use function trans; -class Item extends ItemTypeResponse +class Item extends ApiResponse { public function collectionResponse(): JsonResponse { diff --git a/app/ItemType/Game/ApiResponse/ResourceTypeItem.php b/app/ItemType/Game/ApiResponse/ResourceTypeItem.php index e329ed26..60f6bdf6 100644 --- a/app/ItemType/Game/ApiResponse/ResourceTypeItem.php +++ b/app/ItemType/Game/ApiResponse/ResourceTypeItem.php @@ -4,12 +4,12 @@ namespace App\ItemType\Game\ApiResponse; use App\ItemType\Game\Item; -use App\ItemType\ApiResourceTypeResponse as BaseResourceTypeResponse; +use App\ItemType\ApiResourceTypeResponse; use Illuminate\Http\JsonResponse; use function request; use function response; -class ResourceTypeItem extends BaseResourceTypeResponse +class ResourceTypeItem extends ApiResourceTypeResponse { public function response(): JsonResponse { diff --git a/app/ItemType/Game/ApiResponse/Summary.php b/app/ItemType/Game/ApiResponse/Summary.php index 6d416b52..9e52474d 100644 --- a/app/ItemType/Game/ApiResponse/Summary.php +++ b/app/ItemType/Game/ApiResponse/Summary.php @@ -2,12 +2,12 @@ namespace App\ItemType\Game\ApiResponse; -use App\ItemType\ApiSummaryResponse as BaseSummaryResponse; +use App\ItemType\ApiSummaryResponse; use App\ItemType\Game\Item; use Illuminate\Http\JsonResponse; use function response; -class Summary extends BaseSummaryResponse +class Summary extends ApiSummaryResponse { public function __construct( int $resource_type_id, diff --git a/app/ItemType/Game/ApiResponse/SummaryResourceTypeItem.php b/app/ItemType/Game/ApiResponse/SummaryResourceTypeItem.php index 51793e23..ac952749 100644 --- a/app/ItemType/Game/ApiResponse/SummaryResourceTypeItem.php +++ b/app/ItemType/Game/ApiResponse/SummaryResourceTypeItem.php @@ -3,12 +3,12 @@ namespace App\ItemType\Game\ApiResponse; use App\ItemType\Game\Item; -use App\ItemType\ApiSummaryResourceTypeResponse as BaseSummaryResourceTypeResponse; +use App\ItemType\ApiSummaryResourceTypeResponse; use App\Request\Validate\Boolean; use Illuminate\Http\JsonResponse; use function response; -class SummaryResourceTypeItem extends BaseSummaryResourceTypeResponse +class SummaryResourceTypeItem extends ApiSummaryResourceTypeResponse { public function __construct( int $resource_type_id, diff --git a/app/ItemType/Game/Transformers/Item.php b/app/ItemType/Game/Transformers/Item.php index c2ef301a..be2d42f9 100644 --- a/app/ItemType/Game/Transformers/Item.php +++ b/app/ItemType/Game/Transformers/Item.php @@ -3,14 +3,14 @@ namespace App\ItemType\Game\Transformers; -use App\Transformers\Transformer as BaseTransformer; +use App\Transformers\Transformer; /** * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class Item extends BaseTransformer +class Item extends Transformer { public function format(array $to_transform): void { diff --git a/app/ItemType/Game/Transformers/ResourceTypeItem.php b/app/ItemType/Game/Transformers/ResourceTypeItem.php index 025e820c..97ba865a 100644 --- a/app/ItemType/Game/Transformers/ResourceTypeItem.php +++ b/app/ItemType/Game/Transformers/ResourceTypeItem.php @@ -3,14 +3,14 @@ namespace App\ItemType\Game\Transformers; -use App\Transformers\Transformer as BaseTransformer; +use App\Transformers\Transformer; /** * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class ResourceTypeItem extends BaseTransformer +class ResourceTypeItem extends Transformer { public function format(array $to_transform): void { diff --git a/app/ItemType/SimpleExpense/ApiResponse/Item.php b/app/ItemType/SimpleExpense/ApiResponse/Item.php index 65950d3a..9b8bf970 100644 --- a/app/ItemType/SimpleExpense/ApiResponse/Item.php +++ b/app/ItemType/SimpleExpense/ApiResponse/Item.php @@ -3,14 +3,14 @@ namespace App\ItemType\SimpleExpense\ApiResponse; -use App\ItemType\ApiResponse as ItemTypeResponse; +use App\ItemType\ApiResponse; use App\Response\Responses; use Illuminate\Http\JsonResponse; use function request; use function response; use function trans; -class Item extends ItemTypeResponse +class Item extends ApiResponse { public function collectionResponse(): JsonResponse { diff --git a/app/ItemType/SimpleExpense/ApiResponse/ResourceTypeItem.php b/app/ItemType/SimpleExpense/ApiResponse/ResourceTypeItem.php index 9861b665..954194d2 100644 --- a/app/ItemType/SimpleExpense/ApiResponse/ResourceTypeItem.php +++ b/app/ItemType/SimpleExpense/ApiResponse/ResourceTypeItem.php @@ -3,13 +3,13 @@ namespace App\ItemType\SimpleExpense\ApiResponse; -use App\ItemType\ApiResourceTypeResponse as BaseResourceTypeResponse; +use App\ItemType\ApiResourceTypeResponse; use App\ItemType\SimpleExpense\Item; use Illuminate\Http\JsonResponse; use function request; use function response; -class ResourceTypeItem extends BaseResourceTypeResponse +class ResourceTypeItem extends ApiResourceTypeResponse { public function response(): JsonResponse { diff --git a/app/ItemType/SimpleExpense/ApiResponse/Summary.php b/app/ItemType/SimpleExpense/ApiResponse/Summary.php index b8d21785..8389573a 100644 --- a/app/ItemType/SimpleExpense/ApiResponse/Summary.php +++ b/app/ItemType/SimpleExpense/ApiResponse/Summary.php @@ -2,13 +2,13 @@ namespace App\ItemType\SimpleExpense\ApiResponse; -use App\ItemType\ApiSummaryResponse as BaseSummaryResponse; +use App\ItemType\ApiSummaryResponse; use App\ItemType\SimpleExpense\Item; use App\Request\Validate\Boolean; use Illuminate\Http\JsonResponse; use function response; -class Summary extends BaseSummaryResponse +class Summary extends ApiSummaryResponse { public function __construct( int $resource_type_id, diff --git a/app/ItemType/SimpleExpense/ApiResponse/SummaryResourceTypeItem.php b/app/ItemType/SimpleExpense/ApiResponse/SummaryResourceTypeItem.php index 80b3e4af..ae72d1c6 100644 --- a/app/ItemType/SimpleExpense/ApiResponse/SummaryResourceTypeItem.php +++ b/app/ItemType/SimpleExpense/ApiResponse/SummaryResourceTypeItem.php @@ -3,12 +3,12 @@ namespace App\ItemType\SimpleExpense\ApiResponse; use App\ItemType\SimpleExpense\Item; -use App\ItemType\ApiSummaryResourceTypeResponse as BaseSummaryResourceTypeResponse; +use App\ItemType\ApiSummaryResourceTypeResponse; use App\Request\Validate\Boolean; use Illuminate\Http\JsonResponse; use function response; -class SummaryResourceTypeItem extends BaseSummaryResourceTypeResponse +class SummaryResourceTypeItem extends ApiSummaryResourceTypeResponse { public function __construct( int $resource_type_id, diff --git a/app/ItemType/SimpleExpense/Transformers/Item.php b/app/ItemType/SimpleExpense/Transformers/Item.php index dac76bd3..0e19a23f 100644 --- a/app/ItemType/SimpleExpense/Transformers/Item.php +++ b/app/ItemType/SimpleExpense/Transformers/Item.php @@ -3,14 +3,14 @@ namespace App\ItemType\SimpleExpense\Transformers; -use App\Transformers\Transformer as BaseTransformer; +use App\Transformers\Transformer; /** * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class Item extends BaseTransformer +class Item extends Transformer { public function format(array $to_transform): void { diff --git a/app/ItemType/SimpleExpense/Transformers/ResourceTypeItem.php b/app/ItemType/SimpleExpense/Transformers/ResourceTypeItem.php index fadc3b35..55f95ad8 100644 --- a/app/ItemType/SimpleExpense/Transformers/ResourceTypeItem.php +++ b/app/ItemType/SimpleExpense/Transformers/ResourceTypeItem.php @@ -3,14 +3,14 @@ namespace App\ItemType\SimpleExpense\Transformers; -use App\Transformers\Transformer as BaseTransformer; +use App\Transformers\Transformer; /** * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class ResourceTypeItem extends BaseTransformer +class ResourceTypeItem extends Transformer { public function format(array $to_transform): void { diff --git a/app/ItemType/SimpleItem/ApiResponse/Item.php b/app/ItemType/SimpleItem/ApiResponse/Item.php index 317938c8..8dc521d2 100644 --- a/app/ItemType/SimpleItem/ApiResponse/Item.php +++ b/app/ItemType/SimpleItem/ApiResponse/Item.php @@ -3,14 +3,14 @@ namespace App\ItemType\SimpleItem\ApiResponse; -use App\ItemType\ApiResponse as ItemTypeResponse; +use App\ItemType\ApiResponse; use App\Response\Responses; use Illuminate\Http\JsonResponse; use function request; use function response; use function trans; -class Item extends ItemTypeResponse +class Item extends ApiResponse { public function collectionResponse(): JsonResponse { diff --git a/app/ItemType/SimpleItem/ApiResponse/ResourceTypeItem.php b/app/ItemType/SimpleItem/ApiResponse/ResourceTypeItem.php index abe0cd9c..458344d6 100644 --- a/app/ItemType/SimpleItem/ApiResponse/ResourceTypeItem.php +++ b/app/ItemType/SimpleItem/ApiResponse/ResourceTypeItem.php @@ -3,13 +3,13 @@ namespace App\ItemType\SimpleItem\ApiResponse; -use App\ItemType\ApiResourceTypeResponse as BaseResourceTypeResponse; +use App\ItemType\ApiResourceTypeResponse; use App\ItemType\SimpleItem\Item; use Illuminate\Http\JsonResponse; use function request; use function response; -class ResourceTypeItem extends BaseResourceTypeResponse +class ResourceTypeItem extends ApiResourceTypeResponse { public function response(): JsonResponse { diff --git a/app/ItemType/SimpleItem/ApiResponse/Summary.php b/app/ItemType/SimpleItem/ApiResponse/Summary.php index 6c778488..6e734c8e 100644 --- a/app/ItemType/SimpleItem/ApiResponse/Summary.php +++ b/app/ItemType/SimpleItem/ApiResponse/Summary.php @@ -2,12 +2,12 @@ namespace App\ItemType\SimpleItem\ApiResponse; -use App\ItemType\ApiSummaryResponse as BaseSummaryResponse; +use App\ItemType\ApiSummaryResponse; use App\ItemType\SimpleItem\Item; use Illuminate\Http\JsonResponse; use function response; -class Summary extends BaseSummaryResponse +class Summary extends ApiSummaryResponse { public function __construct( int $resource_type_id, diff --git a/app/ItemType/SimpleItem/ApiResponse/SummaryResourceTypeItem.php b/app/ItemType/SimpleItem/ApiResponse/SummaryResourceTypeItem.php index cda80029..46a88bdc 100644 --- a/app/ItemType/SimpleItem/ApiResponse/SummaryResourceTypeItem.php +++ b/app/ItemType/SimpleItem/ApiResponse/SummaryResourceTypeItem.php @@ -3,12 +3,12 @@ namespace App\ItemType\SimpleItem\ApiResponse; use App\ItemType\SimpleItem\Item; -use App\ItemType\ApiSummaryResourceTypeResponse as BaseSummaryResourceTypeResponse; +use App\ItemType\ApiSummaryResourceTypeResponse; use App\Request\Validate\Boolean; use Illuminate\Http\JsonResponse; use function response; -class SummaryResourceTypeItem extends BaseSummaryResourceTypeResponse +class SummaryResourceTypeItem extends ApiSummaryResourceTypeResponse { public function __construct( int $resource_type_id, diff --git a/app/ItemType/SimpleItem/Transformers/Item.php b/app/ItemType/SimpleItem/Transformers/Item.php index feccdaec..ef787a46 100644 --- a/app/ItemType/SimpleItem/Transformers/Item.php +++ b/app/ItemType/SimpleItem/Transformers/Item.php @@ -3,14 +3,14 @@ namespace App\ItemType\SimpleItem\Transformers; -use App\Transformers\Transformer as BaseTransformer; +use App\Transformers\Transformer; /** * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class Item extends BaseTransformer +class Item extends Transformer { public function format(array $to_transform): void { diff --git a/app/ItemType/SimpleItem/Transformers/ResourceTypeItem.php b/app/ItemType/SimpleItem/Transformers/ResourceTypeItem.php index 4ad09a31..e6244195 100644 --- a/app/ItemType/SimpleItem/Transformers/ResourceTypeItem.php +++ b/app/ItemType/SimpleItem/Transformers/ResourceTypeItem.php @@ -3,14 +3,14 @@ namespace App\ItemType\SimpleItem\Transformers; -use App\Transformers\Transformer as BaseTransformer; +use App\Transformers\Transformer; /** * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ -class ResourceTypeItem extends BaseTransformer +class ResourceTypeItem extends Transformer { public function format(array $to_transform): void { From 66971f320cd98b9b26dcb3d0d632daea27ec4f10 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Sun, 16 Jan 2022 15:19:54 +0000 Subject: [PATCH 29/73] Refactoring - Rename methods and classes --- app/Http/Controllers/ItemView.php | 10 +++++----- app/Http/Controllers/ResourceTypeItemView.php | 4 ++-- app/Http/Controllers/Summary/ItemView.php | 2 +- .../Controllers/Summary/ResourceTypeItemView.php | 2 +- app/ItemType/AllocatedExpense/ApiResponse/Item.php | 4 ++-- ...ResourceTypeItem.php => ResourceTypeItemItem.php} | 4 ++-- ...eTypeItem.php => SummaryResourceTypeItemItem.php} | 4 ++-- app/ItemType/AllocatedExpense/Item.php | 12 ++++++------ .../{ApiResponse.php => ApiItemResponse.php} | 2 +- ...eResponse.php => ApiResourceTypeItemResponse.php} | 2 +- ...se.php => ApiSummaryResourceTypeItemResponse.php} | 2 +- app/ItemType/Game/ApiResponse/Item.php | 4 ++-- ...ResourceTypeItem.php => ResourceTypeItemItem.php} | 4 ++-- ...eTypeItem.php => SummaryResourceTypeItemItem.php} | 4 ++-- app/ItemType/Game/Item.php | 12 ++++++------ app/ItemType/ItemType.php | 9 ++++----- app/ItemType/SimpleExpense/ApiResponse/Item.php | 4 ++-- ...ResourceTypeItem.php => ResourceTypeItemItem.php} | 4 ++-- ...eTypeItem.php => SummaryResourceTypeItemItem.php} | 4 ++-- app/ItemType/SimpleExpense/Item.php | 12 ++++++------ app/ItemType/SimpleItem/ApiResponse/Item.php | 4 ++-- ...ResourceTypeItem.php => ResourceTypeItemItem.php} | 4 ++-- ...eTypeItem.php => SummaryResourceTypeItemItem.php} | 4 ++-- app/ItemType/SimpleItem/Item.php | 12 ++++++------ 24 files changed, 64 insertions(+), 65 deletions(-) rename app/ItemType/AllocatedExpense/ApiResponse/{ResourceTypeItem.php => ResourceTypeItemItem.php} (96%) rename app/ItemType/AllocatedExpense/ApiResponse/{SummaryResourceTypeItem.php => SummaryResourceTypeItemItem.php} (99%) rename app/ItemType/{ApiResponse.php => ApiItemResponse.php} (99%) rename app/ItemType/{ApiResourceTypeResponse.php => ApiResourceTypeItemResponse.php} (98%) rename app/ItemType/{ApiSummaryResourceTypeResponse.php => ApiSummaryResourceTypeItemResponse.php} (98%) rename app/ItemType/Game/ApiResponse/{ResourceTypeItem.php => ResourceTypeItemItem.php} (95%) rename app/ItemType/Game/ApiResponse/{SummaryResourceTypeItem.php => SummaryResourceTypeItemItem.php} (96%) rename app/ItemType/SimpleExpense/ApiResponse/{ResourceTypeItem.php => ResourceTypeItemItem.php} (95%) rename app/ItemType/SimpleExpense/ApiResponse/{SummaryResourceTypeItem.php => SummaryResourceTypeItemItem.php} (98%) rename app/ItemType/SimpleItem/ApiResponse/{ResourceTypeItem.php => ResourceTypeItemItem.php} (95%) rename app/ItemType/SimpleItem/ApiResponse/{SummaryResourceTypeItem.php => SummaryResourceTypeItemItem.php} (96%) diff --git a/app/Http/Controllers/ItemView.php b/app/Http/Controllers/ItemView.php index 1f86bbb7..059c2fa9 100644 --- a/app/Http/Controllers/ItemView.php +++ b/app/Http/Controllers/ItemView.php @@ -4,7 +4,7 @@ use App\AllowedValue\Currency; use App\ItemType\Entity; -use App\ItemType\ApiResponse; +use App\ItemType\ApiItemResponse; use App\Option\ItemCollection; use App\Option\ItemItem; use Illuminate\Http\JsonResponse; @@ -27,10 +27,10 @@ public function index( $entity = Entity::item((int) $resource_type_id); - $collection_class = $entity->viewClass(); + $collection_class = $entity->apiItemResponseClass(); /** - * @var $collection ApiResponse + * @var $collection ApiItemResponse */ $collection = new $collection_class( (int) $resource_type_id, @@ -62,10 +62,10 @@ public function show( } $entity = Entity::item($resource_type_id); - $collection_class = $entity->viewClass(); + $collection_class = $entity->apiItemResponseClass(); /** - * @var $collection ApiResponse + * @var $collection ApiItemResponse */ $collection = new $collection_class( (int) $resource_type_id, diff --git a/app/Http/Controllers/ResourceTypeItemView.php b/app/Http/Controllers/ResourceTypeItemView.php index d278b9d6..9e6bca68 100644 --- a/app/Http/Controllers/ResourceTypeItemView.php +++ b/app/Http/Controllers/ResourceTypeItemView.php @@ -23,10 +23,10 @@ public function index(string $resource_type_id): JsonResponse $entity = Entity::item((int) $resource_type_id); - $collection_class = $entity->resourceTypeItemCollectionClass(); + $collection_class = $entity->apiResourceTypeItemResponseClass(); /** - * @var $collection \App\ItemType\ApiResourceTypeResponse + * @var $collection \App\ItemType\ApiResourceTypeItemResponse */ $collection = new $collection_class( (int) $resource_type_id, diff --git a/app/Http/Controllers/Summary/ItemView.php b/app/Http/Controllers/Summary/ItemView.php index 46ce0d1f..91524212 100644 --- a/app/Http/Controllers/Summary/ItemView.php +++ b/app/Http/Controllers/Summary/ItemView.php @@ -18,7 +18,7 @@ public function index(string $resource_type_id, string $resource_id): JsonRespon $entity = Entity::item((int) $resource_type_id); - $summary_class = $entity->summaryClass(); + $summary_class = $entity->apiSummaryResponseClass(); $summary = new $summary_class( (int) $resource_type_id, (int) $resource_id, diff --git a/app/Http/Controllers/Summary/ResourceTypeItemView.php b/app/Http/Controllers/Summary/ResourceTypeItemView.php index f02c6545..dd4945f3 100644 --- a/app/Http/Controllers/Summary/ResourceTypeItemView.php +++ b/app/Http/Controllers/Summary/ResourceTypeItemView.php @@ -25,7 +25,7 @@ public function index(string $resource_type_id): JsonResponse $entity = Entity::item((int)$resource_type_id); - $summary_class = $entity->resourceTypeSummaryClass(); + $summary_class = $entity->apiSummaryResourceTypeItemResponseClass(); $summary = new $summary_class( (int) $resource_type_id, $this->writeAccessToResourceType($resource_type_id), diff --git a/app/ItemType/AllocatedExpense/ApiResponse/Item.php b/app/ItemType/AllocatedExpense/ApiResponse/Item.php index 3291fce0..55b9f968 100644 --- a/app/ItemType/AllocatedExpense/ApiResponse/Item.php +++ b/app/ItemType/AllocatedExpense/ApiResponse/Item.php @@ -3,14 +3,14 @@ namespace App\ItemType\AllocatedExpense\ApiResponse; -use App\ItemType\ApiResponse; +use App\ItemType\ApiItemResponse; use App\Response\Responses; use Illuminate\Http\JsonResponse; use function request; use function response; use function trans; -class Item extends ApiResponse +class Item extends ApiItemResponse { public function collectionResponse(): JsonResponse { diff --git a/app/ItemType/AllocatedExpense/ApiResponse/ResourceTypeItem.php b/app/ItemType/AllocatedExpense/ApiResponse/ResourceTypeItemItem.php similarity index 96% rename from app/ItemType/AllocatedExpense/ApiResponse/ResourceTypeItem.php rename to app/ItemType/AllocatedExpense/ApiResponse/ResourceTypeItemItem.php index 159ad037..3befe0b4 100644 --- a/app/ItemType/AllocatedExpense/ApiResponse/ResourceTypeItem.php +++ b/app/ItemType/AllocatedExpense/ApiResponse/ResourceTypeItemItem.php @@ -4,12 +4,12 @@ namespace App\ItemType\AllocatedExpense\ApiResponse; use App\ItemType\AllocatedExpense\Item; -use App\ItemType\ApiResourceTypeResponse; +use App\ItemType\ApiResourceTypeItemResponse; use Illuminate\Http\JsonResponse; use function request; use function response; -class ResourceTypeItem extends ApiResourceTypeResponse +class ResourceTypeItemItem extends ApiResourceTypeItemResponse { public function response(): JsonResponse { diff --git a/app/ItemType/AllocatedExpense/ApiResponse/SummaryResourceTypeItem.php b/app/ItemType/AllocatedExpense/ApiResponse/SummaryResourceTypeItemItem.php similarity index 99% rename from app/ItemType/AllocatedExpense/ApiResponse/SummaryResourceTypeItem.php rename to app/ItemType/AllocatedExpense/ApiResponse/SummaryResourceTypeItemItem.php index 743b35e0..6a31e0b3 100644 --- a/app/ItemType/AllocatedExpense/ApiResponse/SummaryResourceTypeItem.php +++ b/app/ItemType/AllocatedExpense/ApiResponse/SummaryResourceTypeItemItem.php @@ -3,13 +3,13 @@ namespace App\ItemType\AllocatedExpense\ApiResponse; use App\ItemType\AllocatedExpense\Item; -use App\ItemType\ApiSummaryResourceTypeResponse; +use App\ItemType\ApiSummaryResourceTypeItemResponse; use App\Request\Validate\Boolean; use Illuminate\Http\JsonResponse; use function request; use function response; -class SummaryResourceTypeItem extends ApiSummaryResourceTypeResponse +class SummaryResourceTypeItemItem extends ApiSummaryResourceTypeItemResponse { public function __construct( int $resource_type_id, diff --git a/app/ItemType/AllocatedExpense/Item.php b/app/ItemType/AllocatedExpense/Item.php index 1104e32d..7588f8b9 100644 --- a/app/ItemType/AllocatedExpense/Item.php +++ b/app/ItemType/AllocatedExpense/Item.php @@ -85,14 +85,14 @@ public function model() return new Models\Item(); } - public function summaryClass(): string + public function apiSummaryResponseClass(): string { return ApiResponse\Summary::class; } - public function resourceTypeSummaryClass(): string + public function apiSummaryResourceTypeItemResponseClass(): string { - return ApiResponse\SummaryResourceTypeItem::class; + return ApiResponse\SummaryResourceTypeItemItem::class; } public function transformer(array $data_to_transform): Transformer @@ -130,14 +130,14 @@ public function validator(): Validator return new \App\ItemType\AllocatedExpense\Validator(); } - public function viewClass(): string + public function apiItemResponseClass(): string { return \App\ItemType\AllocatedExpense\ApiResponse\Item::class; } - public function resourceTypeItemCollectionClass(): string + public function apiResourceTypeItemResponseClass(): string { - return ApiResponse\ResourceTypeItem::class; + return ApiResponse\ResourceTypeItemItem::class; } protected function allowedValuesItemCollectionClass(): string diff --git a/app/ItemType/ApiResponse.php b/app/ItemType/ApiItemResponse.php similarity index 99% rename from app/ItemType/ApiResponse.php rename to app/ItemType/ApiItemResponse.php index 351a37a4..f5614265 100644 --- a/app/ItemType/ApiResponse.php +++ b/app/ItemType/ApiItemResponse.php @@ -11,7 +11,7 @@ use App\Response\Pagination as UtilityPagination; use Illuminate\Http\JsonResponse; -abstract class ApiResponse +abstract class ApiItemResponse { protected int $resource_type_id; diff --git a/app/ItemType/ApiResourceTypeResponse.php b/app/ItemType/ApiResourceTypeItemResponse.php similarity index 98% rename from app/ItemType/ApiResourceTypeResponse.php rename to app/ItemType/ApiResourceTypeItemResponse.php index dedf1702..c3bb287c 100644 --- a/app/ItemType/ApiResourceTypeResponse.php +++ b/app/ItemType/ApiResourceTypeItemResponse.php @@ -11,7 +11,7 @@ use App\Response\Pagination as UtilityPagination; use Illuminate\Http\JsonResponse; -abstract class ApiResourceTypeResponse +abstract class ApiResourceTypeItemResponse { protected int $resource_type_id; diff --git a/app/ItemType/ApiSummaryResourceTypeResponse.php b/app/ItemType/ApiSummaryResourceTypeItemResponse.php similarity index 98% rename from app/ItemType/ApiSummaryResourceTypeResponse.php rename to app/ItemType/ApiSummaryResourceTypeItemResponse.php index 035bb7b3..8aab2930 100644 --- a/app/ItemType/ApiSummaryResourceTypeResponse.php +++ b/app/ItemType/ApiSummaryResourceTypeItemResponse.php @@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Http\JsonResponse; -abstract class ApiSummaryResourceTypeResponse +abstract class ApiSummaryResourceTypeItemResponse { protected int $resource_type_id; diff --git a/app/ItemType/Game/ApiResponse/Item.php b/app/ItemType/Game/ApiResponse/Item.php index d6b87fe5..75ce20bb 100644 --- a/app/ItemType/Game/ApiResponse/Item.php +++ b/app/ItemType/Game/ApiResponse/Item.php @@ -3,14 +3,14 @@ namespace App\ItemType\Game\ApiResponse; -use App\ItemType\ApiResponse; +use App\ItemType\ApiItemResponse; use App\Response\Responses; use Illuminate\Http\JsonResponse; use function request; use function response; use function trans; -class Item extends ApiResponse +class Item extends ApiItemResponse { public function collectionResponse(): JsonResponse { diff --git a/app/ItemType/Game/ApiResponse/ResourceTypeItem.php b/app/ItemType/Game/ApiResponse/ResourceTypeItemItem.php similarity index 95% rename from app/ItemType/Game/ApiResponse/ResourceTypeItem.php rename to app/ItemType/Game/ApiResponse/ResourceTypeItemItem.php index 60f6bdf6..f5c47406 100644 --- a/app/ItemType/Game/ApiResponse/ResourceTypeItem.php +++ b/app/ItemType/Game/ApiResponse/ResourceTypeItemItem.php @@ -4,12 +4,12 @@ namespace App\ItemType\Game\ApiResponse; use App\ItemType\Game\Item; -use App\ItemType\ApiResourceTypeResponse; +use App\ItemType\ApiResourceTypeItemResponse; use Illuminate\Http\JsonResponse; use function request; use function response; -class ResourceTypeItem extends ApiResourceTypeResponse +class ResourceTypeItemItem extends ApiResourceTypeItemResponse { public function response(): JsonResponse { diff --git a/app/ItemType/Game/ApiResponse/SummaryResourceTypeItem.php b/app/ItemType/Game/ApiResponse/SummaryResourceTypeItemItem.php similarity index 96% rename from app/ItemType/Game/ApiResponse/SummaryResourceTypeItem.php rename to app/ItemType/Game/ApiResponse/SummaryResourceTypeItemItem.php index ac952749..19f73bdd 100644 --- a/app/ItemType/Game/ApiResponse/SummaryResourceTypeItem.php +++ b/app/ItemType/Game/ApiResponse/SummaryResourceTypeItemItem.php @@ -3,12 +3,12 @@ namespace App\ItemType\Game\ApiResponse; use App\ItemType\Game\Item; -use App\ItemType\ApiSummaryResourceTypeResponse; +use App\ItemType\ApiSummaryResourceTypeItemResponse; use App\Request\Validate\Boolean; use Illuminate\Http\JsonResponse; use function response; -class SummaryResourceTypeItem extends ApiSummaryResourceTypeResponse +class SummaryResourceTypeItemItem extends ApiSummaryResourceTypeItemResponse { public function __construct( int $resource_type_id, diff --git a/app/ItemType/Game/Item.php b/app/ItemType/Game/Item.php index 5db491d2..e48a9513 100644 --- a/app/ItemType/Game/Item.php +++ b/app/ItemType/Game/Item.php @@ -114,24 +114,24 @@ public function patchFields(): array return LaravelConfig::get($this->base_path . '.fields-patch', []); } - public function summaryClass(): string + public function apiSummaryResponseClass(): string { return ApiResponse\Summary::class; } - public function viewClass(): string + public function apiItemResponseClass(): string { return ApiResponse\Item::class; } - public function resourceTypeSummaryClass(): string + public function apiSummaryResourceTypeItemResponseClass(): string { - return ApiResponse\SummaryResourceTypeItem::class; + return ApiResponse\SummaryResourceTypeItemItem::class; } - public function resourceTypeItemCollectionClass(): string + public function apiResourceTypeItemResponseClass(): string { - return ApiResponse\ResourceTypeItem::class; + return ApiResponse\ResourceTypeItemItem::class; } protected function allowedValuesItemCollectionClass(): string diff --git a/app/ItemType/ItemType.php b/app/ItemType/ItemType.php index 419070c1..e9d79edb 100644 --- a/app/ItemType/ItemType.php +++ b/app/ItemType/ItemType.php @@ -183,11 +183,10 @@ public function subcategoryAssignmentLimit(): int return 1; } - abstract public function summaryClass(): string; - - abstract public function resourceTypeSummaryClass(): string; - abstract public function viewClass(): string; - abstract public function resourceTypeItemCollectionClass(): string; + abstract public function apiSummaryResponseClass(): string; + abstract public function apiSummaryResourceTypeItemResponseClass(): string; + abstract public function apiItemResponseClass(): string; + abstract public function apiResourceTypeItemResponseClass(): string; public function summaryFilterParameters(): array { diff --git a/app/ItemType/SimpleExpense/ApiResponse/Item.php b/app/ItemType/SimpleExpense/ApiResponse/Item.php index 9b8bf970..a9b3e600 100644 --- a/app/ItemType/SimpleExpense/ApiResponse/Item.php +++ b/app/ItemType/SimpleExpense/ApiResponse/Item.php @@ -3,14 +3,14 @@ namespace App\ItemType\SimpleExpense\ApiResponse; -use App\ItemType\ApiResponse; +use App\ItemType\ApiItemResponse; use App\Response\Responses; use Illuminate\Http\JsonResponse; use function request; use function response; use function trans; -class Item extends ApiResponse +class Item extends ApiItemResponse { public function collectionResponse(): JsonResponse { diff --git a/app/ItemType/SimpleExpense/ApiResponse/ResourceTypeItem.php b/app/ItemType/SimpleExpense/ApiResponse/ResourceTypeItemItem.php similarity index 95% rename from app/ItemType/SimpleExpense/ApiResponse/ResourceTypeItem.php rename to app/ItemType/SimpleExpense/ApiResponse/ResourceTypeItemItem.php index 954194d2..df7a4d58 100644 --- a/app/ItemType/SimpleExpense/ApiResponse/ResourceTypeItem.php +++ b/app/ItemType/SimpleExpense/ApiResponse/ResourceTypeItemItem.php @@ -3,13 +3,13 @@ namespace App\ItemType\SimpleExpense\ApiResponse; -use App\ItemType\ApiResourceTypeResponse; +use App\ItemType\ApiResourceTypeItemResponse; use App\ItemType\SimpleExpense\Item; use Illuminate\Http\JsonResponse; use function request; use function response; -class ResourceTypeItem extends ApiResourceTypeResponse +class ResourceTypeItemItem extends ApiResourceTypeItemResponse { public function response(): JsonResponse { diff --git a/app/ItemType/SimpleExpense/ApiResponse/SummaryResourceTypeItem.php b/app/ItemType/SimpleExpense/ApiResponse/SummaryResourceTypeItemItem.php similarity index 98% rename from app/ItemType/SimpleExpense/ApiResponse/SummaryResourceTypeItem.php rename to app/ItemType/SimpleExpense/ApiResponse/SummaryResourceTypeItemItem.php index ae72d1c6..e132ae2f 100644 --- a/app/ItemType/SimpleExpense/ApiResponse/SummaryResourceTypeItem.php +++ b/app/ItemType/SimpleExpense/ApiResponse/SummaryResourceTypeItemItem.php @@ -3,12 +3,12 @@ namespace App\ItemType\SimpleExpense\ApiResponse; use App\ItemType\SimpleExpense\Item; -use App\ItemType\ApiSummaryResourceTypeResponse; +use App\ItemType\ApiSummaryResourceTypeItemResponse; use App\Request\Validate\Boolean; use Illuminate\Http\JsonResponse; use function response; -class SummaryResourceTypeItem extends ApiSummaryResourceTypeResponse +class SummaryResourceTypeItemItem extends ApiSummaryResourceTypeItemResponse { public function __construct( int $resource_type_id, diff --git a/app/ItemType/SimpleExpense/Item.php b/app/ItemType/SimpleExpense/Item.php index ebee8f4a..4ed911fd 100644 --- a/app/ItemType/SimpleExpense/Item.php +++ b/app/ItemType/SimpleExpense/Item.php @@ -67,14 +67,14 @@ public function type(): string return 'simple-expense'; } - public function summaryClass(): string + public function apiSummaryResponseClass(): string { return ApiResponse\Summary::class; } - public function resourceTypeSummaryClass(): string + public function apiSummaryResourceTypeItemResponseClass(): string { - return ApiResponse\SummaryResourceTypeItem::class; + return ApiResponse\SummaryResourceTypeItemItem::class; } public function transformer(array $data_to_transform): Transformer @@ -103,14 +103,14 @@ public function validator(): Validator return new \App\ItemType\SimpleExpense\Validator(); } - public function viewClass(): string + public function apiItemResponseClass(): string { return ApiResponse\Item::class; } - public function resourceTypeItemCollectionClass(): string + public function apiResourceTypeItemResponseClass(): string { - return ApiResponse\ResourceTypeItem::class; + return ApiResponse\ResourceTypeItemItem::class; } protected function allowedValuesItemCollectionClass(): string diff --git a/app/ItemType/SimpleItem/ApiResponse/Item.php b/app/ItemType/SimpleItem/ApiResponse/Item.php index 8dc521d2..4dadeaef 100644 --- a/app/ItemType/SimpleItem/ApiResponse/Item.php +++ b/app/ItemType/SimpleItem/ApiResponse/Item.php @@ -3,14 +3,14 @@ namespace App\ItemType\SimpleItem\ApiResponse; -use App\ItemType\ApiResponse; +use App\ItemType\ApiItemResponse; use App\Response\Responses; use Illuminate\Http\JsonResponse; use function request; use function response; use function trans; -class Item extends ApiResponse +class Item extends ApiItemResponse { public function collectionResponse(): JsonResponse { diff --git a/app/ItemType/SimpleItem/ApiResponse/ResourceTypeItem.php b/app/ItemType/SimpleItem/ApiResponse/ResourceTypeItemItem.php similarity index 95% rename from app/ItemType/SimpleItem/ApiResponse/ResourceTypeItem.php rename to app/ItemType/SimpleItem/ApiResponse/ResourceTypeItemItem.php index 458344d6..bd135cf5 100644 --- a/app/ItemType/SimpleItem/ApiResponse/ResourceTypeItem.php +++ b/app/ItemType/SimpleItem/ApiResponse/ResourceTypeItemItem.php @@ -3,13 +3,13 @@ namespace App\ItemType\SimpleItem\ApiResponse; -use App\ItemType\ApiResourceTypeResponse; +use App\ItemType\ApiResourceTypeItemResponse; use App\ItemType\SimpleItem\Item; use Illuminate\Http\JsonResponse; use function request; use function response; -class ResourceTypeItem extends ApiResourceTypeResponse +class ResourceTypeItemItem extends ApiResourceTypeItemResponse { public function response(): JsonResponse { diff --git a/app/ItemType/SimpleItem/ApiResponse/SummaryResourceTypeItem.php b/app/ItemType/SimpleItem/ApiResponse/SummaryResourceTypeItemItem.php similarity index 96% rename from app/ItemType/SimpleItem/ApiResponse/SummaryResourceTypeItem.php rename to app/ItemType/SimpleItem/ApiResponse/SummaryResourceTypeItemItem.php index 46a88bdc..7331c6b1 100644 --- a/app/ItemType/SimpleItem/ApiResponse/SummaryResourceTypeItem.php +++ b/app/ItemType/SimpleItem/ApiResponse/SummaryResourceTypeItemItem.php @@ -3,12 +3,12 @@ namespace App\ItemType\SimpleItem\ApiResponse; use App\ItemType\SimpleItem\Item; -use App\ItemType\ApiSummaryResourceTypeResponse; +use App\ItemType\ApiSummaryResourceTypeItemResponse; use App\Request\Validate\Boolean; use Illuminate\Http\JsonResponse; use function response; -class SummaryResourceTypeItem extends ApiSummaryResourceTypeResponse +class SummaryResourceTypeItemItem extends ApiSummaryResourceTypeItemResponse { public function __construct( int $resource_type_id, diff --git a/app/ItemType/SimpleItem/Item.php b/app/ItemType/SimpleItem/Item.php index 1b185679..34ec330d 100644 --- a/app/ItemType/SimpleItem/Item.php +++ b/app/ItemType/SimpleItem/Item.php @@ -71,14 +71,14 @@ public function type(): string return 'simple-item'; } - public function summaryClass(): string + public function apiSummaryResponseClass(): string { return ApiResponse\Summary::class; } - public function resourceTypeSummaryClass(): string + public function apiSummaryResourceTypeItemResponseClass(): string { - return ApiResponse\SummaryResourceTypeItem::class; + return ApiResponse\SummaryResourceTypeItemItem::class; } public function transformer(array $data_to_transform): Transformer @@ -102,14 +102,14 @@ public function validator(): Validator return new \App\ItemType\SimpleItem\Validator(); } - public function viewClass(): string + public function apiItemResponseClass(): string { return ApiResponse\Item::class; } - public function resourceTypeItemCollectionClass(): string + public function apiResourceTypeItemResponseClass(): string { - return ApiResponse\ResourceTypeItem::class; + return ApiResponse\ResourceTypeItemItem::class; } protected function allowedValuesItemCollectionClass(): string From d3d2a0c933f1baef97cfda0ff84551eb4c3446e8 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Sun, 16 Jan 2022 16:00:06 +0000 Subject: [PATCH 30/73] Refactoring - Method per item type --- app/Http/Controllers/ItemView.php | 135 +++++++++++++++++++++++------- app/ItemType/Entity.php | 11 +++ 2 files changed, 116 insertions(+), 30 deletions(-) diff --git a/app/Http/Controllers/ItemView.php b/app/Http/Controllers/ItemView.php index 059c2fa9..97f9df01 100644 --- a/app/Http/Controllers/ItemView.php +++ b/app/Http/Controllers/ItemView.php @@ -4,7 +4,6 @@ use App\AllowedValue\Currency; use App\ItemType\Entity; -use App\ItemType\ApiItemResponse; use App\Option\ItemCollection; use App\Option\ItemItem; use Illuminate\Http\JsonResponse; @@ -25,32 +24,65 @@ public function index( \App\Response\Responses::notFoundOrNotAccessible(trans('entities.resource')); } - $entity = Entity::item((int) $resource_type_id); + $item_type = Entity::itemType((int) $resource_type_id); - $collection_class = $entity->apiItemResponseClass(); + return match ($item_type) { + 'allocated-expense' => $this->allocatedExpenseCollection((int) $resource_type_id, (int) $resource_id), + 'simple-expense' => $this->simpleExpenseCollection((int) $resource_type_id, (int) $resource_id), + 'simple-item' => $this->simpleItemCollection((int) $resource_type_id, (int) $resource_id), + 'game' => $this->gameCollection((int) $resource_type_id, (int) $resource_id), + default => throw new \OutOfRangeException('No entity definition for ' . $item_type, 500), + }; + } - /** - * @var $collection ApiItemResponse - */ - $collection = new $collection_class( - (int) $resource_type_id, - (int) $resource_id, + private function allocatedExpenseCollection(int $resource_type_id, int $resource_id): JsonResponse + { + $response = new \App\ItemType\AllocatedExpense\ApiResponse\Item( + $resource_type_id, + $resource_id, $this->writeAccessToResourceType($resource_type_id), $this->user_id ); - return $collection->collectionResponse(); + return $response->collectionResponse(); + } + + private function gameCollection(int $resource_type_id, int $resource_id): JsonResponse + { + $response = new \App\ItemType\Game\ApiResponse\Item( + $resource_type_id, + $resource_id, + $this->writeAccessToResourceType($resource_type_id), + $this->user_id + ); + + return $response->collectionResponse(); + } + + private function simpleExpenseCollection(int $resource_type_id, int $resource_id): JsonResponse + { + $response = new \App\ItemType\SimpleExpense\ApiResponse\Item( + $resource_type_id, + $resource_id, + $this->writeAccessToResourceType($resource_type_id), + $this->user_id + ); + + return $response->collectionResponse(); + } + + private function simpleItemCollection(int $resource_type_id, int $resource_id): JsonResponse + { + $response = new \App\ItemType\SimpleItem\ApiResponse\Item( + $resource_type_id, + $resource_id, + $this->writeAccessToResourceType($resource_type_id), + $this->user_id + ); + + return $response->collectionResponse(); } - /** - * Return a single item - * - * @param string $resource_id - * @param string $resource_type_id - * @param string $item_id - * - * @return JsonResponse - */ public function show( $resource_type_id, $resource_id, @@ -58,23 +90,66 @@ public function show( ): JsonResponse { if ($this->viewAccessToResourceType((int) $resource_type_id) === false) { - \App\Response\Responses::notFoundOrNotAccessible(trans('entities.item')); + \App\Response\Responses::notFoundOrNotAccessible(trans('entities.resource')); } - $entity = Entity::item($resource_type_id); - $collection_class = $entity->apiItemResponseClass(); - - /** - * @var $collection ApiItemResponse - */ - $collection = new $collection_class( - (int) $resource_type_id, - (int) $resource_id, + $item_type = Entity::itemType((int) $resource_type_id); + + return match ($item_type) { + 'allocated-expense' => $this->allocatedExpense((int) $resource_type_id, (int) $resource_id, (int) $item_id), + 'simple-expense' => $this->simpleExpense((int) $resource_type_id, (int) $resource_id, (int) $item_id), + 'simple-item' => $this->simpleItem((int) $resource_type_id, (int) $resource_id, (int) $item_id), + 'game' => $this->game((int) $resource_type_id, (int) $resource_id, (int) $item_id), + default => throw new \OutOfRangeException('No entity definition for ' . $item_type, 500), + }; + } + + private function allocatedExpense(int $resource_type_id, int $resource_id, int $item_id): JsonResponse + { + $response = new \App\ItemType\AllocatedExpense\ApiResponse\Item( + $resource_type_id, + $resource_id, + $this->writeAccessToResourceType($resource_type_id), + $this->user_id + ); + + return $response->showResponse($item_id); + } + + private function game(int $resource_type_id, int $resource_id, int $item_id): JsonResponse + { + $response = new \App\ItemType\Game\ApiResponse\Item( + $resource_type_id, + $resource_id, + $this->writeAccessToResourceType($resource_type_id), + $this->user_id + ); + + return $response->showResponse($item_id); + } + + private function simpleExpense(int $resource_type_id, int $resource_id, int $item_id): JsonResponse + { + $response = new \App\ItemType\SimpleExpense\ApiResponse\Item( + $resource_type_id, + $resource_id, + $this->writeAccessToResourceType($resource_type_id), + $this->user_id + ); + + return $response->showResponse($item_id); + } + + private function simpleItem(int $resource_type_id, int $resource_id, int $item_id): JsonResponse + { + $response = new \App\ItemType\SimpleItem\ApiResponse\Item( + $resource_type_id, + $resource_id, $this->writeAccessToResourceType($resource_type_id), $this->user_id ); - return $collection->showResponse($item_id); + return $response->showResponse($item_id); } /** diff --git a/app/ItemType/Entity.php b/app/ItemType/Entity.php index d4fb4fcd..b1ca9587 100644 --- a/app/ItemType/Entity.php +++ b/app/ItemType/Entity.php @@ -10,6 +10,17 @@ class Entity { + public static function itemType(int $resource_type_id): string + { + $type = (new ResourceTypeItemType())->itemType($resource_type_id); + + if ($type !== null) { + return $type; + } + + throw new \RuntimeException('No entity definition for ' . $type, 500); + } + public static function item(int $resource_type_id): ItemType { $type = (new ResourceTypeItemType())->itemType($resource_type_id); From b2d267008ca483f340f5833f2b21670882254a1b Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Sun, 16 Jan 2022 23:14:34 +0000 Subject: [PATCH 31/73] Refactoring - Customer options request per item type collection - Renamed the allowedValues and allowedParameter methods --- app/AllowedValue/Currency.php | 6 -- app/Http/Controllers/ItemCategoryView.php | 2 +- .../Controllers/ItemPartialTransferView.php | 2 +- app/Http/Controllers/ItemSubcategoryView.php | 2 +- app/Http/Controllers/ItemTransferView.php | 2 +- app/Http/Controllers/ItemView.php | 82 ++++++++++++++++++- app/Http/Controllers/ResourceTypeItemView.php | 2 +- app/Http/Controllers/ResourceTypeView.php | 2 +- app/Http/Controllers/ResourceView.php | 2 +- app/Http/Controllers/Summary/ItemView.php | 2 +- .../Summary/ResourceTypeItemView.php | 2 +- .../Item/AllocatedExpenseCollection.php | 36 ++++++++ app/Option/Item/GameCollection.php | 36 ++++++++ app/Option/Item/SimpleExpenseCollection.php | 36 ++++++++ app/Option/Item/SimpleItemCollection.php | 36 ++++++++ app/Option/Response.php | 4 +- 16 files changed, 234 insertions(+), 20 deletions(-) create mode 100644 app/Option/Item/AllocatedExpenseCollection.php create mode 100644 app/Option/Item/GameCollection.php create mode 100644 app/Option/Item/SimpleExpenseCollection.php create mode 100644 app/Option/Item/SimpleItemCollection.php diff --git a/app/AllowedValue/Currency.php b/app/AllowedValue/Currency.php index fa1bc6c4..20df611f 100644 --- a/app/AllowedValue/Currency.php +++ b/app/AllowedValue/Currency.php @@ -14,12 +14,6 @@ public function __construct() $this->hash = new Hash(); } - /** - * Generate the allowed values item type array, will be passed to the - * Option classes and merged with the fields/parameters - * - * @return array - */ public function allowedValues(): array { $parameters = ['currency_id' => ['allowed_values' => []]]; diff --git a/app/Http/Controllers/ItemCategoryView.php b/app/Http/Controllers/ItemCategoryView.php index f70af0d3..cffedf85 100644 --- a/app/Http/Controllers/ItemCategoryView.php +++ b/app/Http/Controllers/ItemCategoryView.php @@ -111,7 +111,7 @@ public function optionsIndex(string $resource_type_id, string $resource_id, stri return $response ->setEntity(Entity::item($resource_type_id)) - ->setAllowedFields( + ->setDynamicAllowedFields( (new \App\AllowedValue\Category())->allowedValues($resource_type_id)) ->create() ->response(); diff --git a/app/Http/Controllers/ItemPartialTransferView.php b/app/Http/Controllers/ItemPartialTransferView.php index 8bfcf880..9539e72d 100644 --- a/app/Http/Controllers/ItemPartialTransferView.php +++ b/app/Http/Controllers/ItemPartialTransferView.php @@ -192,7 +192,7 @@ public function optionsTransfer( $response = new ItemPartialTransferTransfer($this->permissions((int) $resource_type_id)); - return $response->setAllowedFields( + return $response->setDynamicAllowedFields( (new \App\AllowedValue\Resource())->allowedValues( $resource_type_id, $resource_id diff --git a/app/Http/Controllers/ItemSubcategoryView.php b/app/Http/Controllers/ItemSubcategoryView.php index 64c57e5b..385f233d 100644 --- a/app/Http/Controllers/ItemSubcategoryView.php +++ b/app/Http/Controllers/ItemSubcategoryView.php @@ -144,7 +144,7 @@ public function optionsIndex( return $response ->setEntity(Entity::item($resource_type_id)) - ->setAllowedFields( + ->setDynamicAllowedFields( (new \App\AllowedValue\Subcategory())->allowedValues($item_category->category_id) ) ->create() diff --git a/app/Http/Controllers/ItemTransferView.php b/app/Http/Controllers/ItemTransferView.php index 32a03fc0..69969b40 100644 --- a/app/Http/Controllers/ItemTransferView.php +++ b/app/Http/Controllers/ItemTransferView.php @@ -129,7 +129,7 @@ public function optionsTransfer( $response = new ItemTransferTransfer($this->permissions((int) $resource_type_id)); - return $response->setAllowedFields( + return $response->setDynamicAllowedFields( (new \App\AllowedValue\Resource())->allowedValues( $resource_type_id, $resource_id diff --git a/app/Http/Controllers/ItemView.php b/app/Http/Controllers/ItemView.php index 97f9df01..dde44d63 100644 --- a/app/Http/Controllers/ItemView.php +++ b/app/Http/Controllers/ItemView.php @@ -169,7 +169,7 @@ public function optionsIndex( \App\Response\Responses::notFoundOrNotAccessible(trans('entities.resource')); } - $entity = Entity::item($resource_type_id); + /*$entity = Entity::item($resource_type_id); $response = new ItemCollection($this->permissions((int) $resource_type_id)); @@ -184,7 +184,83 @@ public function optionsIndex( ) ->setAllowedFields((new Currency())->allowedValues()) ->create() - ->response(); + ->response();*/ + + $item_type = Entity::itemType((int) $resource_type_id); + + return match ($item_type) { + 'allocated-expense' => $this->optionsAllocatedExpenseCollection((int) $resource_type_id, (int) $resource_id), + 'game' => $this->optionsGameCollection((int) $resource_type_id, (int) $resource_id), + 'simple-expense' => $this->optionsSimpleExpenseCollection((int) $resource_type_id, (int) $resource_id), + 'simple-item' => $this->optionsSimpleItemCollection((int) $resource_type_id, (int) $resource_id), + default => throw new \OutOfRangeException('No entity definition for ' . $item_type, 500), + }; + } + + private function optionsAllocatedExpenseCollection(int $resource_type_id, int $resource_id): JsonResponse + { + $item = new \App\ItemType\AllocatedExpense\Item(); + $response = new \App\Option\Item\AllocatedExpenseCollection($this->permissions($resource_type_id)); + + return $response->setDynamicAllowedParameters( + $item->allowedValuesForItemCollection( + $resource_type_id, + $resource_id, + $this->viewable_resource_types + ) + ) + ->setDynamicAllowedFields((new Currency())->allowedValues()) + ->create() + ->response(); + } + + private function optionsGameCollection(int $resource_type_id, int $resource_id): JsonResponse + { + $item = new \App\ItemType\Game\Item(); + $response = new \App\Option\Item\GameCollection($this->permissions($resource_type_id)); + + return $response->setDynamicAllowedParameters( + $item->allowedValuesForItemCollection( + $resource_type_id, + $resource_id, + $this->viewable_resource_types + ) + ) + ->create() + ->response(); + } + + private function optionsSimpleExpenseCollection(int $resource_type_id, int $resource_id): JsonResponse + { + $item = new \App\ItemType\SimpleExpense\Item(); + $response = new \App\Option\Item\SimpleExpenseCollection($this->permissions($resource_type_id)); + + return $response->setDynamicAllowedParameters( + $item->allowedValuesForItemCollection( + $resource_type_id, + $resource_id, + $this->viewable_resource_types + ) + ) + ->setDynamicAllowedFields((new Currency())->allowedValues()) + ->create() + ->response(); + } + + private function optionsSimpleItemCollection(int $resource_type_id, int $resource_id): JsonResponse + { + $item = new \App\ItemType\SimpleItem\Item(); + $response = new \App\Option\Item\SimpleItemCollection($this->permissions($resource_type_id)); + + return $response->setDynamicAllowedParameters( + $item->allowedValuesForItemCollection( + $resource_type_id, + $resource_id, + $this->viewable_resource_types + ) + ) + ->create() + ->response(); } /** @@ -220,7 +296,7 @@ public function optionsShow( return $response ->setEntity($entity) - ->setAllowedFields($entity->allowedValuesForItem((int) $resource_type_id)) + ->setDynamicAllowedFields($entity->allowedValuesForItem((int) $resource_type_id)) ->create() ->response(); } diff --git a/app/Http/Controllers/ResourceTypeItemView.php b/app/Http/Controllers/ResourceTypeItemView.php index 9e6bca68..f1dc7f3f 100644 --- a/app/Http/Controllers/ResourceTypeItemView.php +++ b/app/Http/Controllers/ResourceTypeItemView.php @@ -49,7 +49,7 @@ public function optionsIndex(string $resource_type_id): JsonResponse return $response ->setEntity($entity) - ->setAllowedParameters( + ->setDynamicAllowedParameters( $entity->allowedValuesForResourceTypeItemCollection( $resource_type_id, $this->viewable_resource_types diff --git a/app/Http/Controllers/ResourceTypeView.php b/app/Http/Controllers/ResourceTypeView.php index 09a45c35..b3c71957 100644 --- a/app/Http/Controllers/ResourceTypeView.php +++ b/app/Http/Controllers/ResourceTypeView.php @@ -133,7 +133,7 @@ public function optionsIndex(): JsonResponse { $response = new ResourceTypeCollection(['view'=> $this->user_id !== null, 'manage'=> $this->user_id !== null]); - return $response->setAllowedFields((new ItemType())->allowedValues()) + return $response->setDynamicAllowedFields((new ItemType())->allowedValues()) ->create() ->response(); } diff --git a/app/Http/Controllers/ResourceView.php b/app/Http/Controllers/ResourceView.php index acb1d94f..690c47f8 100644 --- a/app/Http/Controllers/ResourceView.php +++ b/app/Http/Controllers/ResourceView.php @@ -154,7 +154,7 @@ public function optionsIndex(string $resource_type_id): JsonResponse $response = new ResourceCollection($this->permissions((int) $resource_type_id)); - return $response->setAllowedFields((new ItemSubtype())->allowedValues($resource_type['resource_type_item_type_id'])) + return $response->setDynamicAllowedFields((new ItemSubtype())->allowedValues($resource_type['resource_type_item_type_id'])) ->create() ->response(); } diff --git a/app/Http/Controllers/Summary/ItemView.php b/app/Http/Controllers/Summary/ItemView.php index 91524212..bee96101 100644 --- a/app/Http/Controllers/Summary/ItemView.php +++ b/app/Http/Controllers/Summary/ItemView.php @@ -46,7 +46,7 @@ public function optionsIndex(string $resource_type_id, string $resource_id): Jso $response = new SummaryItemCollection($this->permissions((int) $resource_type_id)); return $response->setEntity($entity) - ->setAllowedParameters($allowed_values) + ->setDynamicAllowedParameters($allowed_values) ->create() ->response(); } diff --git a/app/Http/Controllers/Summary/ResourceTypeItemView.php b/app/Http/Controllers/Summary/ResourceTypeItemView.php index dd4945f3..e455f21a 100644 --- a/app/Http/Controllers/Summary/ResourceTypeItemView.php +++ b/app/Http/Controllers/Summary/ResourceTypeItemView.php @@ -51,7 +51,7 @@ public function optionsIndex(string $resource_type_id): JsonResponse $response = new SummaryResourceTypeItemCollection($this->permissions((int) $resource_type_id)); return $response->setEntity($entity) - ->setAllowedParameters($allowed_values) + ->setDynamicAllowedParameters($allowed_values) ->create() ->response(); } diff --git a/app/Option/Item/AllocatedExpenseCollection.php b/app/Option/Item/AllocatedExpenseCollection.php new file mode 100644 index 00000000..4712db79 --- /dev/null +++ b/app/Option/Item/AllocatedExpenseCollection.php @@ -0,0 +1,36 @@ +verbs['GET'] = $get->setSortableParameters($item->sortParameters()) + ->setSearchableParameters($item->searchParameters()) + ->setFilterableParameters($item->filterParameters()) + ->setParameters($item->requestParameters()) + ->setDynamicParameters($this->allowed_parameters) + ->setPaginationStatus(true) + ->setAuthenticationStatus($this->permissions['view']) + ->setDescription('route-descriptions.item_GET_index') + ->option(); + + $post = new \App\Method\PostRequest(); + $this->verbs['POST'] = $post->setFields($item->postFields()) + ->setDescription( 'route-descriptions.item_POST') + ->setAuthenticationRequirement(true) + ->setAuthenticationStatus($this->permissions['manage']) + ->setDynamicFields($this->allowed_fields) + ->option(); + + return $this; + } +} diff --git a/app/Option/Item/GameCollection.php b/app/Option/Item/GameCollection.php new file mode 100644 index 00000000..2c84e07b --- /dev/null +++ b/app/Option/Item/GameCollection.php @@ -0,0 +1,36 @@ +verbs['GET'] = $get->setSortableParameters($item->sortParameters()) + ->setSearchableParameters($item->searchParameters()) + ->setFilterableParameters($item->filterParameters()) + ->setParameters($item->requestParameters()) + ->setDynamicParameters($this->allowed_parameters) + ->setPaginationStatus(true) + ->setAuthenticationStatus($this->permissions['view']) + ->setDescription('route-descriptions.item_GET_index') + ->option(); + + $post = new \App\Method\PostRequest(); + $this->verbs['POST'] = $post->setFields($item->postFields()) + ->setDescription( 'route-descriptions.item_POST') + ->setAuthenticationRequirement(true) + ->setAuthenticationStatus($this->permissions['manage']) + ->setDynamicFields($this->allowed_fields) + ->option(); + + return $this; + } +} diff --git a/app/Option/Item/SimpleExpenseCollection.php b/app/Option/Item/SimpleExpenseCollection.php new file mode 100644 index 00000000..95b065bd --- /dev/null +++ b/app/Option/Item/SimpleExpenseCollection.php @@ -0,0 +1,36 @@ +verbs['GET'] = $get->setSortableParameters($item->sortParameters()) + ->setSearchableParameters($item->searchParameters()) + ->setFilterableParameters($item->filterParameters()) + ->setParameters($item->requestParameters()) + ->setDynamicParameters($this->allowed_parameters) + ->setPaginationStatus(true) + ->setAuthenticationStatus($this->permissions['view']) + ->setDescription('route-descriptions.item_GET_index') + ->option(); + + $post = new \App\Method\PostRequest(); + $this->verbs['POST'] = $post->setFields($item->postFields()) + ->setDescription( 'route-descriptions.item_POST') + ->setAuthenticationRequirement(true) + ->setAuthenticationStatus($this->permissions['manage']) + ->setDynamicFields($this->allowed_fields) + ->option(); + + return $this; + } +} diff --git a/app/Option/Item/SimpleItemCollection.php b/app/Option/Item/SimpleItemCollection.php new file mode 100644 index 00000000..17b9e537 --- /dev/null +++ b/app/Option/Item/SimpleItemCollection.php @@ -0,0 +1,36 @@ +verbs['GET'] = $get->setSortableParameters($item->sortParameters()) + ->setSearchableParameters($item->searchParameters()) + ->setFilterableParameters($item->filterParameters()) + ->setParameters($item->requestParameters()) + ->setDynamicParameters($this->allowed_parameters) + ->setPaginationStatus(true) + ->setAuthenticationStatus($this->permissions['view']) + ->setDescription('route-descriptions.item_GET_index') + ->option(); + + $post = new \App\Method\PostRequest(); + $this->verbs['POST'] = $post->setFields($item->postFields()) + ->setDescription( 'route-descriptions.item_POST') + ->setAuthenticationRequirement(true) + ->setAuthenticationStatus($this->permissions['manage']) + ->setDynamicFields($this->allowed_fields) + ->option(); + + return $this; + } +} diff --git a/app/Option/Response.php b/app/Option/Response.php index ce967c6c..4c8d52fb 100644 --- a/app/Option/Response.php +++ b/app/Option/Response.php @@ -52,14 +52,14 @@ public function response(int $http_status_code = 200): JsonResponse exit; } - public function setAllowedFields(array $allowed_fields): Response + public function setDynamicAllowedFields(array $allowed_fields): Response { $this->allowed_fields = $allowed_fields; return $this; } - public function setAllowedParameters(array $allowed_parameters): Response + public function setDynamicAllowedParameters(array $allowed_parameters): Response { $this->allowed_parameters = $allowed_parameters; From dc23e1ef0af0c2ae470f917915ebaa2e02f1dc8a Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Sun, 16 Jan 2022 23:50:24 +0000 Subject: [PATCH 32/73] Refactoing - Updated all option routes, one per item type --- app/Http/Controllers/ItemView.php | 144 +++++++++++++++------ app/Option/Item/AllocatedExpense.php | 37 ++++++ app/Option/{ItemItem.php => Item/Game.php} | 13 +- app/Option/Item/SimpleExpense.php | 37 ++++++ app/Option/Item/SimpleItem.php | 37 ++++++ app/Option/ItemCollection.php | 31 ----- 6 files changed, 228 insertions(+), 71 deletions(-) create mode 100644 app/Option/Item/AllocatedExpense.php rename app/Option/{ItemItem.php => Item/Game.php} (75%) create mode 100644 app/Option/Item/SimpleExpense.php create mode 100644 app/Option/Item/SimpleItem.php delete mode 100644 app/Option/ItemCollection.php diff --git a/app/Http/Controllers/ItemView.php b/app/Http/Controllers/ItemView.php index dde44d63..b5ef7ce9 100644 --- a/app/Http/Controllers/ItemView.php +++ b/app/Http/Controllers/ItemView.php @@ -4,8 +4,6 @@ use App\AllowedValue\Currency; use App\ItemType\Entity; -use App\Option\ItemCollection; -use App\Option\ItemItem; use Illuminate\Http\JsonResponse; /** @@ -169,23 +167,6 @@ public function optionsIndex( \App\Response\Responses::notFoundOrNotAccessible(trans('entities.resource')); } - /*$entity = Entity::item($resource_type_id); - - $response = new ItemCollection($this->permissions((int) $resource_type_id)); - - return $response - ->setEntity($entity) - ->setAllowedParameters( - $entity->allowedValuesForItemCollection( - $resource_type_id, - $resource_id, - $this->viewable_resource_types - ) - ) - ->setAllowedFields((new Currency())->allowedValues()) - ->create() - ->response();*/ - $item_type = Entity::itemType((int) $resource_type_id); return match ($item_type) { @@ -263,40 +244,131 @@ private function optionsSimpleItemCollection(int $resource_type_id, int $resourc ->response(); } - /** - * Generate the OPTIONS request for a specific item - * - * @param string $resource_id - * @param string $resource_type_id - * @param string $item_id - * - * @return JsonResponse - */ public function optionsShow( string $resource_type_id, string $resource_id, string $item_id ): JsonResponse + { + if ($this->viewAccessToResourceType((int) $resource_type_id) === false) { + \App\Response\Responses::notFoundOrNotAccessible(trans('entities.resource')); + } + + $item_type = Entity::itemType((int) $resource_type_id); + + return match ($item_type) { + 'allocated-expense' => $this->optionsAllocatedExpenseShow((int) $resource_type_id, (int) $resource_id, (int) $item_id), + 'game' => $this->optionsGameShow((int) $resource_type_id, (int) $resource_id, (int) $item_id), + 'simple-expense' => $this->optionsSimpleExpenseShow((int) $resource_type_id, (int) $resource_id, (int) $item_id), + 'simple-item' => $this->optionsSimpleItemShow((int) $resource_type_id, (int) $resource_id, (int) $item_id), + default => throw new \OutOfRangeException('No entity definition for ' . $item_type, 500), + }; + } + + public function optionsAllocatedExpenseShow( + string $resource_type_id, + string $resource_id, + string $item_id + ): JsonResponse + { + if ($this->viewAccessToResourceType((int) $resource_type_id) === false) { + \App\Response\Responses::notFoundOrNotAccessible(trans('entities.item')); + } + + $item = new \App\ItemType\AllocatedExpense\Item(); + $model = new \App\ItemType\AllocatedExpense\Models\Item(); + $item_data = $model->single($resource_type_id, $resource_id, $item_id); + + if ($item_data === null) { + return \App\Response\Responses::notFound(trans('entities.item')); + } + + $response = new \App\Option\Item\AllocatedExpense($this->permissions((int) $resource_type_id)); + + return $response->setDynamicAllowedFields( + $item->allowedValuesForItem((int) $resource_type_id) + ) + ->create() + ->response(); + } + + public function optionsGameShow( + string $resource_type_id, + string $resource_id, + string $item_id + ): JsonResponse + { + if ($this->viewAccessToResourceType((int) $resource_type_id) === false) { + \App\Response\Responses::notFoundOrNotAccessible(trans('entities.item')); + } + + $item = new \App\ItemType\Game\Item(); + $model = new \App\ItemType\Game\Models\Item(); + $item_data = $model->single($resource_type_id, $resource_id, $item_id); + + if ($item_data === null) { + return \App\Response\Responses::notFound(trans('entities.item')); + } + + $response = new \App\Option\Item\Game($this->permissions((int) $resource_type_id)); + + return $response->setDynamicAllowedFields( + $item->allowedValuesForItem((int) $resource_type_id) + ) + ->create() + ->response(); + } + + public function optionsSimpleExpenseShow( + string $resource_type_id, + string $resource_id, + string $item_id + ): JsonResponse { if ($this->viewAccessToResourceType((int) $resource_type_id) === false) { \App\Response\Responses::notFoundOrNotAccessible(trans('entities.item')); } - $entity = Entity::item($resource_type_id); + $item = new \App\ItemType\SimpleExpense\Item(); + $model = new \App\ItemType\SimpleExpense\Models\Item(); + $item_data = $model->single($resource_type_id, $resource_id, $item_id); + + if ($item_data === null) { + return \App\Response\Responses::notFound(trans('entities.item')); + } + + $response = new \App\Option\Item\SimpleExpense($this->permissions((int) $resource_type_id)); + + return $response->setDynamicAllowedFields( + $item->allowedValuesForItem((int) $resource_type_id) + ) + ->create() + ->response(); + } - $item_model = $entity->model(); + public function optionsSimpleItemShow( + string $resource_type_id, + string $resource_id, + string $item_id + ): JsonResponse + { + if ($this->viewAccessToResourceType((int) $resource_type_id) === false) { + \App\Response\Responses::notFoundOrNotAccessible(trans('entities.item')); + } - $item = $item_model->single($resource_type_id, $resource_id, $item_id); + $item = new \App\ItemType\SimpleItem\Item(); + $model = new \App\ItemType\SimpleItem\Models\Item(); + $item_data = $model->single($resource_type_id, $resource_id, $item_id); - if ($item === null) { + if ($item_data === null) { return \App\Response\Responses::notFound(trans('entities.item')); } - $response = new ItemItem($this->permissions((int) $resource_type_id)); + $response = new \App\Option\Item\SimpleItem($this->permissions((int) $resource_type_id)); - return $response - ->setEntity($entity) - ->setDynamicAllowedFields($entity->allowedValuesForItem((int) $resource_type_id)) + return $response->setDynamicAllowedFields( + $item->allowedValuesForItem((int) $resource_type_id) + ) ->create() ->response(); } diff --git a/app/Option/Item/AllocatedExpense.php b/app/Option/Item/AllocatedExpense.php new file mode 100644 index 00000000..f702339e --- /dev/null +++ b/app/Option/Item/AllocatedExpense.php @@ -0,0 +1,37 @@ +verbs['GET'] = $get->setParameters($item->itemRequestParameters()) + ->setAuthenticationStatus($this->permissions['view']) + ->setDescription('route-descriptions.item_GET_show') + ->option(); + + $delete = new \App\Method\DeleteRequest(); + $this->verbs['DELETE'] = $delete->setDescription('route-descriptions.item_DELETE') + ->setAuthenticationStatus($this->permissions['manage']) + ->setAuthenticationRequirement(true) + ->option(); + + $patch = new \App\Method\PatchRequest(); + $this->verbs['PATCH'] = $patch->setFields($item->patchFields()) + ->setDescription('route-descriptions.item_PATCH') + ->setAuthenticationStatus($this->permissions['manage']) + ->setAuthenticationRequirement(true) + ->setDynamicFields($this->allowed_fields) + ->option(); + + return $this; + } +} diff --git a/app/Option/ItemItem.php b/app/Option/Item/Game.php similarity index 75% rename from app/Option/ItemItem.php rename to app/Option/Item/Game.php index 294a76b0..edb13da6 100644 --- a/app/Option/ItemItem.php +++ b/app/Option/Item/Game.php @@ -1,14 +1,19 @@ verbs['GET'] = $get->setParameters($this->entity->itemRequestParameters()) + $this->verbs['GET'] = $get->setParameters($item->itemRequestParameters()) ->setAuthenticationStatus($this->permissions['view']) ->setDescription('route-descriptions.item_GET_show') ->option(); @@ -20,7 +25,7 @@ public function create() ->option(); $patch = new \App\Method\PatchRequest(); - $this->verbs['PATCH'] = $patch->setFields($this->entity->patchFields()) + $this->verbs['PATCH'] = $patch->setFields($item->patchFields()) ->setDescription('route-descriptions.item_PATCH') ->setAuthenticationStatus($this->permissions['manage']) ->setAuthenticationRequirement(true) diff --git a/app/Option/Item/SimpleExpense.php b/app/Option/Item/SimpleExpense.php new file mode 100644 index 00000000..62e971bc --- /dev/null +++ b/app/Option/Item/SimpleExpense.php @@ -0,0 +1,37 @@ +verbs['GET'] = $get->setParameters($item->itemRequestParameters()) + ->setAuthenticationStatus($this->permissions['view']) + ->setDescription('route-descriptions.item_GET_show') + ->option(); + + $delete = new \App\Method\DeleteRequest(); + $this->verbs['DELETE'] = $delete->setDescription('route-descriptions.item_DELETE') + ->setAuthenticationStatus($this->permissions['manage']) + ->setAuthenticationRequirement(true) + ->option(); + + $patch = new \App\Method\PatchRequest(); + $this->verbs['PATCH'] = $patch->setFields($item->patchFields()) + ->setDescription('route-descriptions.item_PATCH') + ->setAuthenticationStatus($this->permissions['manage']) + ->setAuthenticationRequirement(true) + ->setDynamicFields($this->allowed_fields) + ->option(); + + return $this; + } +} diff --git a/app/Option/Item/SimpleItem.php b/app/Option/Item/SimpleItem.php new file mode 100644 index 00000000..3f517f89 --- /dev/null +++ b/app/Option/Item/SimpleItem.php @@ -0,0 +1,37 @@ +verbs['GET'] = $get->setParameters($item->itemRequestParameters()) + ->setAuthenticationStatus($this->permissions['view']) + ->setDescription('route-descriptions.item_GET_show') + ->option(); + + $delete = new \App\Method\DeleteRequest(); + $this->verbs['DELETE'] = $delete->setDescription('route-descriptions.item_DELETE') + ->setAuthenticationStatus($this->permissions['manage']) + ->setAuthenticationRequirement(true) + ->option(); + + $patch = new \App\Method\PatchRequest(); + $this->verbs['PATCH'] = $patch->setFields($item->patchFields()) + ->setDescription('route-descriptions.item_PATCH') + ->setAuthenticationStatus($this->permissions['manage']) + ->setAuthenticationRequirement(true) + ->setDynamicFields($this->allowed_fields) + ->option(); + + return $this; + } +} diff --git a/app/Option/ItemCollection.php b/app/Option/ItemCollection.php deleted file mode 100644 index 88b06ef9..00000000 --- a/app/Option/ItemCollection.php +++ /dev/null @@ -1,31 +0,0 @@ -verbs['GET'] = $get->setSortableParameters($this->entity->sortParameters()) - ->setSearchableParameters($this->entity->searchParameters()) - ->setFilterableParameters($this->entity->filterParameters()) - ->setParameters($this->entity->requestParameters()) - ->setDynamicParameters($this->allowed_parameters) - ->setPaginationStatus(true) - ->setAuthenticationStatus($this->permissions['view']) - ->setDescription('route-descriptions.item_GET_index') - ->option(); - - $post = new \App\Method\PostRequest(); - $this->verbs['POST'] = $post->setFields($this->entity->postFields()) - ->setDescription( 'route-descriptions.item_POST') - ->setAuthenticationRequirement(true) - ->setAuthenticationStatus($this->permissions['manage']) - ->setDynamicFields($this->allowed_fields) - ->option(); - - return $this; - } -} From 90ab6587b3f3033f8f5cc64a41294de26dd44539 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Mon, 17 Jan 2022 22:54:45 +0000 Subject: [PATCH 33/73] Resource type item - Updated the resource type item collection to match the item collection --- app/Http/Controllers/ItemView.php | 6 +- app/Http/Controllers/ResourceTypeItemView.php | 133 +++++++++++++++--- .../AllocatedExpenseCollection.php | 28 ++++ .../ResourceTypeItem/GameCollection.php | 28 ++++ .../SimpleExpenseCollection.php | 28 ++++ .../ResourceTypeItem/SimpleItemCollection.php | 28 ++++ 6 files changed, 228 insertions(+), 23 deletions(-) create mode 100644 app/Option/ResourceTypeItem/AllocatedExpenseCollection.php create mode 100644 app/Option/ResourceTypeItem/GameCollection.php create mode 100644 app/Option/ResourceTypeItem/SimpleExpenseCollection.php create mode 100644 app/Option/ResourceTypeItem/SimpleItemCollection.php diff --git a/app/Http/Controllers/ItemView.php b/app/Http/Controllers/ItemView.php index b5ef7ce9..3e5030ac 100644 --- a/app/Http/Controllers/ItemView.php +++ b/app/Http/Controllers/ItemView.php @@ -29,7 +29,7 @@ public function index( 'simple-expense' => $this->simpleExpenseCollection((int) $resource_type_id, (int) $resource_id), 'simple-item' => $this->simpleItemCollection((int) $resource_type_id, (int) $resource_id), 'game' => $this->gameCollection((int) $resource_type_id, (int) $resource_id), - default => throw new \OutOfRangeException('No entity definition for ' . $item_type, 500), + default => throw new \OutOfRangeException('No item type definition for ' . $item_type, 500), }; } @@ -98,7 +98,7 @@ public function show( 'simple-expense' => $this->simpleExpense((int) $resource_type_id, (int) $resource_id, (int) $item_id), 'simple-item' => $this->simpleItem((int) $resource_type_id, (int) $resource_id, (int) $item_id), 'game' => $this->game((int) $resource_type_id, (int) $resource_id, (int) $item_id), - default => throw new \OutOfRangeException('No entity definition for ' . $item_type, 500), + default => throw new \OutOfRangeException('No item type definition for ' . $item_type, 500), }; } @@ -174,7 +174,7 @@ public function optionsIndex( 'game' => $this->optionsGameCollection((int) $resource_type_id, (int) $resource_id), 'simple-expense' => $this->optionsSimpleExpenseCollection((int) $resource_type_id, (int) $resource_id), 'simple-item' => $this->optionsSimpleItemCollection((int) $resource_type_id, (int) $resource_id), - default => throw new \OutOfRangeException('No entity definition for ' . $item_type, 500), + default => throw new \OutOfRangeException('No options item type definition for ' . $item_type, 500), }; } diff --git a/app/Http/Controllers/ResourceTypeItemView.php b/app/Http/Controllers/ResourceTypeItemView.php index f1dc7f3f..b9624174 100644 --- a/app/Http/Controllers/ResourceTypeItemView.php +++ b/app/Http/Controllers/ResourceTypeItemView.php @@ -3,7 +3,6 @@ namespace App\Http\Controllers; use App\ItemType\Entity; -use App\Option\ResourceTypeItemCollection; use Illuminate\Http\JsonResponse; /** @@ -21,20 +20,59 @@ public function index(string $resource_type_id): JsonResponse \App\Response\Responses::notFoundOrNotAccessible(trans('entities.resource-type')); } - $entity = Entity::item((int) $resource_type_id); + $item_type = Entity::itemType((int) $resource_type_id); - $collection_class = $entity->apiResourceTypeItemResponseClass(); + return match ($item_type) { + 'allocated-expense' => $this->allocatedExpenseCollection((int) $resource_type_id), + 'game' => $this->gameCollection((int) $resource_type_id), + 'simple-expense' => $this->simpleExpenseCollection((int) $resource_type_id), + 'simple-item' => $this->simpleItemCollection((int) $resource_type_id), + default => throw new \OutOfRangeException('No item type definition for ' . $item_type, 500), + }; + } - /** - * @var $collection \App\ItemType\ApiResourceTypeItemResponse - */ - $collection = new $collection_class( - (int) $resource_type_id, + private function allocatedExpenseCollection(int $resource_type_id): JsonResponse + { + $response = new \App\ItemType\AllocatedExpense\ApiResponse\ResourceTypeItemItem( + $resource_type_id, $this->writeAccessToResourceType($resource_type_id), $this->user_id ); - return $collection->response(); + return $response->response(); + } + + private function gameCollection(int $resource_type_id): JsonResponse + { + $response = new \App\ItemType\Game\ApiResponse\ResourceTypeItemItem( + $resource_type_id, + $this->writeAccessToResourceType($resource_type_id), + $this->user_id + ); + + return $response->response(); + } + + private function simpleExpenseCollection(int $resource_type_id): JsonResponse + { + $response = new \App\ItemType\SimpleExpense\ApiResponse\ResourceTypeItemItem( + $resource_type_id, + $this->writeAccessToResourceType($resource_type_id), + $this->user_id + ); + + return $response->response(); + } + + private function simpleItemCollection(int $resource_type_id): JsonResponse + { + $response = new \App\ItemType\SimpleItem\ApiResponse\ResourceTypeItemItem( + $resource_type_id, + $this->writeAccessToResourceType($resource_type_id), + $this->user_id + ); + + return $response->response(); } public function optionsIndex(string $resource_type_id): JsonResponse @@ -43,19 +81,74 @@ public function optionsIndex(string $resource_type_id): JsonResponse \App\Response\Responses::notFoundOrNotAccessible(trans('entities.resource-type')); } - $entity = Entity::item($resource_type_id); + $item_type = Entity::itemType((int) $resource_type_id); + + return match ($item_type) { + 'allocated-expense' => $this->optionsAllocatedExpenseCollection((int) $resource_type_id), + 'game' => $this->optionsGameCollection((int) $resource_type_id), + 'simple-expense' => $this->optionsSimpleExpenseCollection((int) $resource_type_id), + 'simple-item' => $this->optionsSimpleItemCollection((int) $resource_type_id), + default => throw new \OutOfRangeException('No options item type definition for ' . $item_type, 500), + }; + } + + private function optionsAllocatedExpenseCollection(int $resource_type_id): JsonResponse + { + $item = new \App\ItemType\AllocatedExpense\Item(); + $response = new \App\Option\ResourceTypeItem\AllocatedExpenseCollection($this->permissions($resource_type_id)); + + return $response->setDynamicAllowedParameters( + $item->allowedValuesForResourceTypeItemCollection( + $resource_type_id, + $this->viewable_resource_types + ) + ) + ->create() + ->response(); + } + + private function optionsGameCollection(int $resource_type_id): JsonResponse + { + $item = new \App\ItemType\Game\Item(); + $response = new \App\Option\ResourceTypeItem\GameCollection($this->permissions($resource_type_id)); + + return $response->setDynamicAllowedParameters( + $item->allowedValuesForResourceTypeItemCollection( + $resource_type_id, + $this->viewable_resource_types + ) + ) + ->create() + ->response(); + } + + private function optionsSimpleExpenseCollection(int $resource_type_id): JsonResponse + { + $item = new \App\ItemType\SimpleExpense\Item(); + $response = new \App\Option\ResourceTypeItem\SimpleExpenseCollection($this->permissions($resource_type_id)); - $response = new ResourceTypeItemCollection($this->permissions((int) $resource_type_id)); + return $response->setDynamicAllowedParameters( + $item->allowedValuesForResourceTypeItemCollection( + $resource_type_id, + $this->viewable_resource_types + ) + ) + ->create() + ->response(); + } + + private function optionsSimpleItemCollection(int $resource_type_id): JsonResponse + { + $item = new \App\ItemType\SimpleItem\Item(); + $response = new \App\Option\ResourceTypeItem\SimpleItemCollection($this->permissions($resource_type_id)); - return $response - ->setEntity($entity) - ->setDynamicAllowedParameters( - $entity->allowedValuesForResourceTypeItemCollection( - $resource_type_id, - $this->viewable_resource_types - ) + return $response->setDynamicAllowedParameters( + $item->allowedValuesForResourceTypeItemCollection( + $resource_type_id, + $this->viewable_resource_types ) - ->create() - ->response(); + ) + ->create() + ->response(); } } diff --git a/app/Option/ResourceTypeItem/AllocatedExpenseCollection.php b/app/Option/ResourceTypeItem/AllocatedExpenseCollection.php new file mode 100644 index 00000000..235d05a4 --- /dev/null +++ b/app/Option/ResourceTypeItem/AllocatedExpenseCollection.php @@ -0,0 +1,28 @@ +verbs['GET'] = $get->setSortableParameters($item->resourceTypeSortParameters())-> + setSearchableParameters($item->resourceTypeSearchParameters())-> + setFilterableParameters($item->resourceTypeFilterParameters())-> + setPaginationStatus(true)-> + setParameters($item->resourceTypeRequestParameters())-> + setDynamicParameters($this->allowed_parameters)-> + setDescription('route-descriptions.resource_type_item_GET_index')-> + setAuthenticationStatus($this->permissions['view'])-> + option(); + + return $this; + } +} diff --git a/app/Option/ResourceTypeItem/GameCollection.php b/app/Option/ResourceTypeItem/GameCollection.php new file mode 100644 index 00000000..ce04fb40 --- /dev/null +++ b/app/Option/ResourceTypeItem/GameCollection.php @@ -0,0 +1,28 @@ +verbs['GET'] = $get->setSortableParameters($item->resourceTypeSortParameters())-> + setSearchableParameters($item->resourceTypeSearchParameters())-> + setFilterableParameters($item->resourceTypeFilterParameters())-> + setPaginationStatus(true)-> + setParameters($item->resourceTypeRequestParameters())-> + setDynamicParameters($this->allowed_parameters)-> + setDescription('route-descriptions.resource_type_item_GET_index')-> + setAuthenticationStatus($this->permissions['view'])-> + option(); + + return $this; + } +} diff --git a/app/Option/ResourceTypeItem/SimpleExpenseCollection.php b/app/Option/ResourceTypeItem/SimpleExpenseCollection.php new file mode 100644 index 00000000..93d3f46c --- /dev/null +++ b/app/Option/ResourceTypeItem/SimpleExpenseCollection.php @@ -0,0 +1,28 @@ +verbs['GET'] = $get->setSortableParameters($item->resourceTypeSortParameters())-> + setSearchableParameters($item->resourceTypeSearchParameters())-> + setFilterableParameters($item->resourceTypeFilterParameters())-> + setPaginationStatus(true)-> + setParameters($item->resourceTypeRequestParameters())-> + setDynamicParameters($this->allowed_parameters)-> + setDescription('route-descriptions.resource_type_item_GET_index')-> + setAuthenticationStatus($this->permissions['view'])-> + option(); + + return $this; + } +} diff --git a/app/Option/ResourceTypeItem/SimpleItemCollection.php b/app/Option/ResourceTypeItem/SimpleItemCollection.php new file mode 100644 index 00000000..08fc8ae7 --- /dev/null +++ b/app/Option/ResourceTypeItem/SimpleItemCollection.php @@ -0,0 +1,28 @@ +verbs['GET'] = $get->setSortableParameters($item->resourceTypeSortParameters())-> + setSearchableParameters($item->resourceTypeSearchParameters())-> + setFilterableParameters($item->resourceTypeFilterParameters())-> + setPaginationStatus(true)-> + setParameters($item->resourceTypeRequestParameters())-> + setDynamicParameters($this->allowed_parameters)-> + setDescription('route-descriptions.resource_type_item_GET_index')-> + setAuthenticationStatus($this->permissions['view'])-> + option(); + + return $this; + } +} From 4033142d38f79c47f0dc4e3e076cff0e6684fa63 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Mon, 17 Jan 2022 23:05:10 +0000 Subject: [PATCH 34/73] Refactoring - Rename classes, double item some how got in. --- app/Http/Controllers/ResourceTypeItemView.php | 8 ++++---- .../{ResourceTypeItemItem.php => ResourceTypeItem.php} | 2 +- ...sourceTypeItemItem.php => SummaryResourceTypeItem.php} | 2 +- app/ItemType/AllocatedExpense/Item.php | 4 ++-- .../{ResourceTypeItemItem.php => ResourceTypeItem.php} | 2 +- ...sourceTypeItemItem.php => SummaryResourceTypeItem.php} | 2 +- app/ItemType/Game/Item.php | 4 ++-- .../{ResourceTypeItemItem.php => ResourceTypeItem.php} | 2 +- ...sourceTypeItemItem.php => SummaryResourceTypeItem.php} | 2 +- app/ItemType/SimpleExpense/Item.php | 4 ++-- .../{ResourceTypeItemItem.php => ResourceTypeItem.php} | 2 +- ...sourceTypeItemItem.php => SummaryResourceTypeItem.php} | 2 +- app/ItemType/SimpleItem/Item.php | 4 ++-- 13 files changed, 20 insertions(+), 20 deletions(-) rename app/ItemType/AllocatedExpense/ApiResponse/{ResourceTypeItemItem.php => ResourceTypeItem.php} (97%) rename app/ItemType/AllocatedExpense/ApiResponse/{SummaryResourceTypeItemItem.php => SummaryResourceTypeItem.php} (99%) rename app/ItemType/Game/ApiResponse/{ResourceTypeItemItem.php => ResourceTypeItem.php} (97%) rename app/ItemType/Game/ApiResponse/{SummaryResourceTypeItemItem.php => SummaryResourceTypeItem.php} (98%) rename app/ItemType/SimpleExpense/ApiResponse/{ResourceTypeItemItem.php => ResourceTypeItem.php} (97%) rename app/ItemType/SimpleExpense/ApiResponse/{SummaryResourceTypeItemItem.php => SummaryResourceTypeItem.php} (99%) rename app/ItemType/SimpleItem/ApiResponse/{ResourceTypeItemItem.php => ResourceTypeItem.php} (97%) rename app/ItemType/SimpleItem/ApiResponse/{SummaryResourceTypeItemItem.php => SummaryResourceTypeItem.php} (98%) diff --git a/app/Http/Controllers/ResourceTypeItemView.php b/app/Http/Controllers/ResourceTypeItemView.php index b9624174..6886de6c 100644 --- a/app/Http/Controllers/ResourceTypeItemView.php +++ b/app/Http/Controllers/ResourceTypeItemView.php @@ -33,7 +33,7 @@ public function index(string $resource_type_id): JsonResponse private function allocatedExpenseCollection(int $resource_type_id): JsonResponse { - $response = new \App\ItemType\AllocatedExpense\ApiResponse\ResourceTypeItemItem( + $response = new \App\ItemType\AllocatedExpense\ApiResponse\ResourceTypeItem( $resource_type_id, $this->writeAccessToResourceType($resource_type_id), $this->user_id @@ -44,7 +44,7 @@ private function allocatedExpenseCollection(int $resource_type_id): JsonResponse private function gameCollection(int $resource_type_id): JsonResponse { - $response = new \App\ItemType\Game\ApiResponse\ResourceTypeItemItem( + $response = new \App\ItemType\Game\ApiResponse\ResourceTypeItem( $resource_type_id, $this->writeAccessToResourceType($resource_type_id), $this->user_id @@ -55,7 +55,7 @@ private function gameCollection(int $resource_type_id): JsonResponse private function simpleExpenseCollection(int $resource_type_id): JsonResponse { - $response = new \App\ItemType\SimpleExpense\ApiResponse\ResourceTypeItemItem( + $response = new \App\ItemType\SimpleExpense\ApiResponse\ResourceTypeItem( $resource_type_id, $this->writeAccessToResourceType($resource_type_id), $this->user_id @@ -66,7 +66,7 @@ private function simpleExpenseCollection(int $resource_type_id): JsonResponse private function simpleItemCollection(int $resource_type_id): JsonResponse { - $response = new \App\ItemType\SimpleItem\ApiResponse\ResourceTypeItemItem( + $response = new \App\ItemType\SimpleItem\ApiResponse\ResourceTypeItem( $resource_type_id, $this->writeAccessToResourceType($resource_type_id), $this->user_id diff --git a/app/ItemType/AllocatedExpense/ApiResponse/ResourceTypeItemItem.php b/app/ItemType/AllocatedExpense/ApiResponse/ResourceTypeItem.php similarity index 97% rename from app/ItemType/AllocatedExpense/ApiResponse/ResourceTypeItemItem.php rename to app/ItemType/AllocatedExpense/ApiResponse/ResourceTypeItem.php index 3befe0b4..c90bcf08 100644 --- a/app/ItemType/AllocatedExpense/ApiResponse/ResourceTypeItemItem.php +++ b/app/ItemType/AllocatedExpense/ApiResponse/ResourceTypeItem.php @@ -9,7 +9,7 @@ use function request; use function response; -class ResourceTypeItemItem extends ApiResourceTypeItemResponse +class ResourceTypeItem extends ApiResourceTypeItemResponse { public function response(): JsonResponse { diff --git a/app/ItemType/AllocatedExpense/ApiResponse/SummaryResourceTypeItemItem.php b/app/ItemType/AllocatedExpense/ApiResponse/SummaryResourceTypeItem.php similarity index 99% rename from app/ItemType/AllocatedExpense/ApiResponse/SummaryResourceTypeItemItem.php rename to app/ItemType/AllocatedExpense/ApiResponse/SummaryResourceTypeItem.php index 6a31e0b3..4f9b93c9 100644 --- a/app/ItemType/AllocatedExpense/ApiResponse/SummaryResourceTypeItemItem.php +++ b/app/ItemType/AllocatedExpense/ApiResponse/SummaryResourceTypeItem.php @@ -9,7 +9,7 @@ use function request; use function response; -class SummaryResourceTypeItemItem extends ApiSummaryResourceTypeItemResponse +class SummaryResourceTypeItem extends ApiSummaryResourceTypeItemResponse { public function __construct( int $resource_type_id, diff --git a/app/ItemType/AllocatedExpense/Item.php b/app/ItemType/AllocatedExpense/Item.php index 7588f8b9..e85d4b72 100644 --- a/app/ItemType/AllocatedExpense/Item.php +++ b/app/ItemType/AllocatedExpense/Item.php @@ -92,7 +92,7 @@ public function apiSummaryResponseClass(): string public function apiSummaryResourceTypeItemResponseClass(): string { - return ApiResponse\SummaryResourceTypeItemItem::class; + return ApiResponse\SummaryResourceTypeItem::class; } public function transformer(array $data_to_transform): Transformer @@ -137,7 +137,7 @@ public function apiItemResponseClass(): string public function apiResourceTypeItemResponseClass(): string { - return ApiResponse\ResourceTypeItemItem::class; + return ApiResponse\ResourceTypeItem::class; } protected function allowedValuesItemCollectionClass(): string diff --git a/app/ItemType/Game/ApiResponse/ResourceTypeItemItem.php b/app/ItemType/Game/ApiResponse/ResourceTypeItem.php similarity index 97% rename from app/ItemType/Game/ApiResponse/ResourceTypeItemItem.php rename to app/ItemType/Game/ApiResponse/ResourceTypeItem.php index f5c47406..e2937988 100644 --- a/app/ItemType/Game/ApiResponse/ResourceTypeItemItem.php +++ b/app/ItemType/Game/ApiResponse/ResourceTypeItem.php @@ -9,7 +9,7 @@ use function request; use function response; -class ResourceTypeItemItem extends ApiResourceTypeItemResponse +class ResourceTypeItem extends ApiResourceTypeItemResponse { public function response(): JsonResponse { diff --git a/app/ItemType/Game/ApiResponse/SummaryResourceTypeItemItem.php b/app/ItemType/Game/ApiResponse/SummaryResourceTypeItem.php similarity index 98% rename from app/ItemType/Game/ApiResponse/SummaryResourceTypeItemItem.php rename to app/ItemType/Game/ApiResponse/SummaryResourceTypeItem.php index 19f73bdd..6afcd34f 100644 --- a/app/ItemType/Game/ApiResponse/SummaryResourceTypeItemItem.php +++ b/app/ItemType/Game/ApiResponse/SummaryResourceTypeItem.php @@ -8,7 +8,7 @@ use Illuminate\Http\JsonResponse; use function response; -class SummaryResourceTypeItemItem extends ApiSummaryResourceTypeItemResponse +class SummaryResourceTypeItem extends ApiSummaryResourceTypeItemResponse { public function __construct( int $resource_type_id, diff --git a/app/ItemType/Game/Item.php b/app/ItemType/Game/Item.php index e48a9513..7cbde84b 100644 --- a/app/ItemType/Game/Item.php +++ b/app/ItemType/Game/Item.php @@ -126,12 +126,12 @@ public function apiItemResponseClass(): string public function apiSummaryResourceTypeItemResponseClass(): string { - return ApiResponse\SummaryResourceTypeItemItem::class; + return ApiResponse\SummaryResourceTypeItem::class; } public function apiResourceTypeItemResponseClass(): string { - return ApiResponse\ResourceTypeItemItem::class; + return ApiResponse\ResourceTypeItem::class; } protected function allowedValuesItemCollectionClass(): string diff --git a/app/ItemType/SimpleExpense/ApiResponse/ResourceTypeItemItem.php b/app/ItemType/SimpleExpense/ApiResponse/ResourceTypeItem.php similarity index 97% rename from app/ItemType/SimpleExpense/ApiResponse/ResourceTypeItemItem.php rename to app/ItemType/SimpleExpense/ApiResponse/ResourceTypeItem.php index df7a4d58..72c288f8 100644 --- a/app/ItemType/SimpleExpense/ApiResponse/ResourceTypeItemItem.php +++ b/app/ItemType/SimpleExpense/ApiResponse/ResourceTypeItem.php @@ -9,7 +9,7 @@ use function request; use function response; -class ResourceTypeItemItem extends ApiResourceTypeItemResponse +class ResourceTypeItem extends ApiResourceTypeItemResponse { public function response(): JsonResponse { diff --git a/app/ItemType/SimpleExpense/ApiResponse/SummaryResourceTypeItemItem.php b/app/ItemType/SimpleExpense/ApiResponse/SummaryResourceTypeItem.php similarity index 99% rename from app/ItemType/SimpleExpense/ApiResponse/SummaryResourceTypeItemItem.php rename to app/ItemType/SimpleExpense/ApiResponse/SummaryResourceTypeItem.php index e132ae2f..240a5031 100644 --- a/app/ItemType/SimpleExpense/ApiResponse/SummaryResourceTypeItemItem.php +++ b/app/ItemType/SimpleExpense/ApiResponse/SummaryResourceTypeItem.php @@ -8,7 +8,7 @@ use Illuminate\Http\JsonResponse; use function response; -class SummaryResourceTypeItemItem extends ApiSummaryResourceTypeItemResponse +class SummaryResourceTypeItem extends ApiSummaryResourceTypeItemResponse { public function __construct( int $resource_type_id, diff --git a/app/ItemType/SimpleExpense/Item.php b/app/ItemType/SimpleExpense/Item.php index 4ed911fd..2792380e 100644 --- a/app/ItemType/SimpleExpense/Item.php +++ b/app/ItemType/SimpleExpense/Item.php @@ -74,7 +74,7 @@ public function apiSummaryResponseClass(): string public function apiSummaryResourceTypeItemResponseClass(): string { - return ApiResponse\SummaryResourceTypeItemItem::class; + return ApiResponse\SummaryResourceTypeItem::class; } public function transformer(array $data_to_transform): Transformer @@ -110,7 +110,7 @@ public function apiItemResponseClass(): string public function apiResourceTypeItemResponseClass(): string { - return ApiResponse\ResourceTypeItemItem::class; + return ApiResponse\ResourceTypeItem::class; } protected function allowedValuesItemCollectionClass(): string diff --git a/app/ItemType/SimpleItem/ApiResponse/ResourceTypeItemItem.php b/app/ItemType/SimpleItem/ApiResponse/ResourceTypeItem.php similarity index 97% rename from app/ItemType/SimpleItem/ApiResponse/ResourceTypeItemItem.php rename to app/ItemType/SimpleItem/ApiResponse/ResourceTypeItem.php index bd135cf5..5b381157 100644 --- a/app/ItemType/SimpleItem/ApiResponse/ResourceTypeItemItem.php +++ b/app/ItemType/SimpleItem/ApiResponse/ResourceTypeItem.php @@ -9,7 +9,7 @@ use function request; use function response; -class ResourceTypeItemItem extends ApiResourceTypeItemResponse +class ResourceTypeItem extends ApiResourceTypeItemResponse { public function response(): JsonResponse { diff --git a/app/ItemType/SimpleItem/ApiResponse/SummaryResourceTypeItemItem.php b/app/ItemType/SimpleItem/ApiResponse/SummaryResourceTypeItem.php similarity index 98% rename from app/ItemType/SimpleItem/ApiResponse/SummaryResourceTypeItemItem.php rename to app/ItemType/SimpleItem/ApiResponse/SummaryResourceTypeItem.php index 7331c6b1..3c5f44ee 100644 --- a/app/ItemType/SimpleItem/ApiResponse/SummaryResourceTypeItemItem.php +++ b/app/ItemType/SimpleItem/ApiResponse/SummaryResourceTypeItem.php @@ -8,7 +8,7 @@ use Illuminate\Http\JsonResponse; use function response; -class SummaryResourceTypeItemItem extends ApiSummaryResourceTypeItemResponse +class SummaryResourceTypeItem extends ApiSummaryResourceTypeItemResponse { public function __construct( int $resource_type_id, diff --git a/app/ItemType/SimpleItem/Item.php b/app/ItemType/SimpleItem/Item.php index 34ec330d..91a4fa71 100644 --- a/app/ItemType/SimpleItem/Item.php +++ b/app/ItemType/SimpleItem/Item.php @@ -78,7 +78,7 @@ public function apiSummaryResponseClass(): string public function apiSummaryResourceTypeItemResponseClass(): string { - return ApiResponse\SummaryResourceTypeItemItem::class; + return ApiResponse\SummaryResourceTypeItem::class; } public function transformer(array $data_to_transform): Transformer @@ -109,7 +109,7 @@ public function apiItemResponseClass(): string public function apiResourceTypeItemResponseClass(): string { - return ApiResponse\ResourceTypeItemItem::class; + return ApiResponse\ResourceTypeItem::class; } protected function allowedValuesItemCollectionClass(): string From 8152a2a633b99ce701f5fb0cdce419f9d7592056 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Tue, 18 Jan 2022 23:28:42 +0000 Subject: [PATCH 35/73] Split create items - Split the create item code into different methods, easier to handle the differences going forward. --- app/Http/Controllers/ItemManage.php | 236 ++++++++++++++++++++++++++-- 1 file changed, 222 insertions(+), 14 deletions(-) diff --git a/app/Http/Controllers/ItemManage.php b/app/Http/Controllers/ItemManage.php index f50ae7a4..9836af42 100644 --- a/app/Http/Controllers/ItemManage.php +++ b/app/Http/Controllers/ItemManage.php @@ -10,7 +10,9 @@ use Exception; use Illuminate\Database\QueryException; use Illuminate\Http\JsonResponse; +use Illuminate\Support\Facades\Config as LaravelConfig; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Validator as ValidatorFacade; /** * Manage items @@ -30,18 +32,47 @@ public function create( \App\Response\Responses::notFoundOrNotAccessible(trans('entities.resource')); } - $user_id = $this->user_id; + $item_type = Entity::itemType((int) $resource_type_id); - $entity = Entity::item($resource_type_id); + return match ($item_type) { + 'allocated-expense' => $this->createAllocatedExpense((int) $resource_type_id, (int) $resource_id), + 'simple-expense' => $this->createSimpleExpense((int) $resource_type_id, (int) $resource_id), + 'simple-item' => $this->createSimpleItem((int) $resource_type_id, (int) $resource_id), + 'game' => $this->createGame((int) $resource_type_id, (int) $resource_id), + default => throw new \OutOfRangeException('No item type definition for ' . $item_type, 500), + }; + } - $validation = $entity->validator(); - $validator = $validation->create(); + private function createAllocatedExpense( + int $resource_type_id, + int $resource_id + ): JsonResponse + { + $messages = []; + foreach (LaravelConfig::get('api.item-type-allocated-expense.validation.POST.messages', []) as $key => $custom_message) { + $messages[$key] = trans($custom_message); + } + + $decode = $this->hash->currency()->decode(request()->input('currency_id')); + $currency_id = null; + if (count($decode) === 1) { + $currency_id = $decode[0]; + } + + $validator = ValidatorFacade::make( + array_merge( + request()->all(), + ['currency_id' => $currency_id] + ), + LaravelConfig::get('api.item-type-allocated-expense.validation.POST.fields', []), + $messages + ); if ($validator->fails()) { return \App\Request\BodyValidation::returnValidationErrors($validator); } - $model = $entity->model(); + $item = new \App\ItemType\AllocatedExpense\Item(); $cache_job_payload = (new \App\Cache\JobPayload()) ->setGroupKey(\App\Cache\KeyGroup::ITEM_CREATE) @@ -49,20 +80,196 @@ public function create( 'resource_type_id' => $resource_type_id, 'resource_id' => $resource_id ]) - ->setPermittedUser($this->writeAccessToResourceType((int) $resource_type_id)) - ->setUserId($user_id); + ->setPermittedUser($this->writeAccessToResourceType($resource_type_id)) + ->setUserId($this->user_id); try { - [$item, $item_type] = DB::transaction(static function() use ($resource_id, $user_id, $entity) { - $item = new Item([ + [$item_instance, $item_type_instance] = DB::transaction(function() use ($resource_id, $item) { + $item_instance = new Item([ 'resource_id' => $resource_id, - 'created_by' => $user_id + 'created_by' => $this->user_id ]); - $item->save(); + $item_instance->save(); + $item_type_instance = $item->create($item_instance->id); + + return [$item_instance, $item_type_instance]; + }); + + ClearCache::dispatch($cache_job_payload->payload()); + + } catch (Exception $e) { + return \App\Response\Responses::failedToSaveModelForCreate(); + } + + $model = new \App\ItemType\AllocatedExpense\Models\Item(); + return response()->json( + $item->transformer($model->instanceToArray($item_instance, $item_type_instance))->asArray(), + 201 + ); + } + + private function createGame( + int $resource_type_id, + int $resource_id + ): JsonResponse + { + $messages = []; + foreach (LaravelConfig::get('api.item-type-game.validation.POST.messages', []) as $key => $custom_message) { + $messages[$key] = trans($custom_message); + } + + $validator = ValidatorFacade::make( + request()->all(), + LaravelConfig::get('api.item-type-game.validation.POST.fields', []), + $messages + ); + + if ($validator->fails()) { + return \App\Request\BodyValidation::returnValidationErrors($validator); + } + + $item = new \App\ItemType\Game\Item(); + + $cache_job_payload = (new \App\Cache\JobPayload()) + ->setGroupKey(\App\Cache\KeyGroup::ITEM_CREATE) + ->setRouteParameters([ + 'resource_type_id' => $resource_type_id, + 'resource_id' => $resource_id + ]) + ->setPermittedUser($this->writeAccessToResourceType($resource_type_id)) + ->setUserId($this->user_id); + + try { + [$item_instance, $item_type_instance] = DB::transaction(function() use ($resource_id, $item) { + $item_instance = new Item([ + 'resource_id' => $resource_id, + 'created_by' => $this->user_id + ]); + $item_instance->save(); + $item_type_instance = $item->create($item_instance->id); + + return [$item_instance, $item_type_instance]; + }); + + ClearCache::dispatch($cache_job_payload->payload()); + + } catch (Exception $e) { + return \App\Response\Responses::failedToSaveModelForCreate(); + } + + $model = new \App\ItemType\Game\Models\Item(); + return response()->json( + $item->transformer($model->instanceToArray($item_instance, $item_type_instance))->asArray(), + 201 + ); + } - $item_type = $entity->create((int) $item->id); + private function createSimpleExpense( + int $resource_type_id, + int $resource_id + ): JsonResponse + { + $messages = []; + foreach (LaravelConfig::get('api.item-type-simple-expense.validation.POST.messages', []) as $key => $custom_message) { + $messages[$key] = trans($custom_message); + } + + $decode = $this->hash->currency()->decode(request()->input('currency_id')); + $currency_id = null; + if (count($decode) === 1) { + $currency_id = $decode[0]; + } + + $validator = ValidatorFacade::make( + array_merge( + request()->all(), + ['currency_id' => $currency_id] + ), + LaravelConfig::get('api.item-type-simple-expense.validation.POST.fields', []), + $messages + ); + + if ($validator->fails()) { + return \App\Request\BodyValidation::returnValidationErrors($validator); + } + + $item = new \App\ItemType\SimpleExpense\Item(); + + $cache_job_payload = (new \App\Cache\JobPayload()) + ->setGroupKey(\App\Cache\KeyGroup::ITEM_CREATE) + ->setRouteParameters([ + 'resource_type_id' => $resource_type_id, + 'resource_id' => $resource_id + ]) + ->setPermittedUser($this->writeAccessToResourceType($resource_type_id)) + ->setUserId($this->user_id); + + try { + [$item_instance, $item_type_instance] = DB::transaction(function() use ($resource_id, $item) { + $item_instance = new Item([ + 'resource_id' => $resource_id, + 'created_by' => $this->user_id + ]); + $item_instance->save(); + $item_type_instance = $item->create($item_instance->id); + + return [$item_instance, $item_type_instance]; + }); + + ClearCache::dispatch($cache_job_payload->payload()); + + } catch (Exception $e) { + return \App\Response\Responses::failedToSaveModelForCreate(); + } + + $model = new \App\ItemType\SimpleExpense\Models\Item(); + return response()->json( + $item->transformer($model->instanceToArray($item_instance, $item_type_instance))->asArray(), + 201 + ); + } + + private function createSimpleItem( + int $resource_type_id, + int $resource_id + ): JsonResponse + { + $messages = []; + foreach (LaravelConfig::get('api.item-type-simple-item.validation.POST.messages', []) as $key => $custom_message) { + $messages[$key] = trans($custom_message); + } + + $validator = ValidatorFacade::make( + request()->all(), + LaravelConfig::get('api.item-type-simple-item.validation.POST.fields', []), + $messages + ); + + if ($validator->fails()) { + return \App\Request\BodyValidation::returnValidationErrors($validator); + } + + $item = new \App\ItemType\SimpleItem\Item(); + + $cache_job_payload = (new \App\Cache\JobPayload()) + ->setGroupKey(\App\Cache\KeyGroup::ITEM_CREATE) + ->setRouteParameters([ + 'resource_type_id' => $resource_type_id, + 'resource_id' => $resource_id + ]) + ->setPermittedUser($this->writeAccessToResourceType($resource_type_id)) + ->setUserId($this->user_id); + + try { + [$item_instance, $item_type_instance] = DB::transaction(function() use ($resource_id, $item) { + $item_instance = new Item([ + 'resource_id' => $resource_id, + 'created_by' => $this->user_id + ]); + $item_instance->save(); + $item_type_instance = $item->create($item_instance->id); - return [$item, $item_type]; + return [$item_instance, $item_type_instance]; }); ClearCache::dispatch($cache_job_payload->payload()); @@ -71,8 +278,9 @@ public function create( return \App\Response\Responses::failedToSaveModelForCreate(); } + $model = new \App\ItemType\SimpleItem\Models\Item(); return response()->json( - $entity->transformer($model->instanceToArray($item, $item_type))->asArray(), + $item->transformer($model->instanceToArray($item_instance, $item_type_instance))->asArray(), 201 ); } From fd4d69503905626b6ee1b6e784bea085e30c554f Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Wed, 19 Jan 2022 23:25:23 +0000 Subject: [PATCH 36/73] Updates - Add update methods for each item type --- app/Http/Controllers/ItemManage.php | 318 +++++++++++++++++++++++++++- 1 file changed, 308 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/ItemManage.php b/app/Http/Controllers/ItemManage.php index 9836af42..b8649352 100644 --- a/app/Http/Controllers/ItemManage.php +++ b/app/Http/Controllers/ItemManage.php @@ -15,8 +15,6 @@ use Illuminate\Support\Facades\Validator as ValidatorFacade; /** - * Manage items - * * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE @@ -48,8 +46,10 @@ private function createAllocatedExpense( int $resource_id ): JsonResponse { + $config_base_path = 'api.item-type-allocated-expense'; + $messages = []; - foreach (LaravelConfig::get('api.item-type-allocated-expense.validation.POST.messages', []) as $key => $custom_message) { + foreach (LaravelConfig::get($config_base_path . '.validation.POST.messages', []) as $key => $custom_message) { $messages[$key] = trans($custom_message); } @@ -64,7 +64,7 @@ private function createAllocatedExpense( request()->all(), ['currency_id' => $currency_id] ), - LaravelConfig::get('api.item-type-allocated-expense.validation.POST.fields', []), + LaravelConfig::get($config_base_path . '.validation.POST.fields', []), $messages ); @@ -113,14 +113,16 @@ private function createGame( int $resource_id ): JsonResponse { + $config_base_path = 'api.item-type-game'; + $messages = []; - foreach (LaravelConfig::get('api.item-type-game.validation.POST.messages', []) as $key => $custom_message) { + foreach (LaravelConfig::get($config_base_path . '.validation.POST.messages', []) as $key => $custom_message) { $messages[$key] = trans($custom_message); } $validator = ValidatorFacade::make( request()->all(), - LaravelConfig::get('api.item-type-game.validation.POST.fields', []), + LaravelConfig::get($config_base_path . '.validation.POST.fields', []), $messages ); @@ -169,8 +171,10 @@ private function createSimpleExpense( int $resource_id ): JsonResponse { + $config_base_path = 'api.item-type-simple-expense'; + $messages = []; - foreach (LaravelConfig::get('api.item-type-simple-expense.validation.POST.messages', []) as $key => $custom_message) { + foreach (LaravelConfig::get($config_base_path . '.validation.POST.messages', []) as $key => $custom_message) { $messages[$key] = trans($custom_message); } @@ -185,7 +189,7 @@ private function createSimpleExpense( request()->all(), ['currency_id' => $currency_id] ), - LaravelConfig::get('api.item-type-simple-expense.validation.POST.fields', []), + LaravelConfig::get($config_base_path . '.validation.POST.fields', []), $messages ); @@ -234,14 +238,16 @@ private function createSimpleItem( int $resource_id ): JsonResponse { + $config_base_path = 'api.item-type-simple-item'; + $messages = []; - foreach (LaravelConfig::get('api.item-type-simple-item.validation.POST.messages', []) as $key => $custom_message) { + foreach (LaravelConfig::get($config_base_path . '.validation.POST.messages', []) as $key => $custom_message) { $messages[$key] = trans($custom_message); } $validator = ValidatorFacade::make( request()->all(), - LaravelConfig::get('api.item-type-simple-item.validation.POST.fields', []), + LaravelConfig::get($config_base_path . '.validation.POST.fields', []), $messages ); @@ -348,6 +354,298 @@ public function update( return \App\Response\Responses::successNoContent(); } + private function updateAllocatedExpense(int $resource_type_id, int $resource_id, int $item_id): JsonResponse + { + $config_base_path = 'api.item-type-allocated-expense'; + + if (count(request()->all()) === 0) { + return \App\Response\Responses::nothingToPatch(); + } + + $invalid_fields = \App\Request\BodyValidation::checkForInvalidFields( + array_keys(LaravelConfig::get($config_base_path . '.validation.PATCH.fields', [])) + ); + + if (count($invalid_fields) > 0) { + return Responses::invalidFieldsInRequest($invalid_fields); + } + + $merge_array = []; + if (array_key_exists('currency_id', request()->all())) { + $decode = $this->hash->currency()->decode(request()->input('currency_id')); + $currency_id = null; + if (count($decode) === 1) { + $currency_id = $decode[0]; + } + + $merge_array = ['currency_id' => $currency_id]; + } + + $messages = []; + foreach (LaravelConfig::get($config_base_path . '.validation.PATCH.messages', []) as $key => $custom_message) { + $messages[$key] = trans($custom_message); + } + + $validator = ValidatorFacade::make( + array_merge( + request()->all(), + $merge_array + ), + LaravelConfig::get($config_base_path . '.validation.PATCH.fields', []), + $messages + ); + + if ($validator->fails()) { + return \App\Request\BodyValidation::returnValidationErrors($validator); + } + + $cache_job_payload = (new \App\Cache\JobPayload()) + ->setGroupKey(\App\Cache\KeyGroup::ITEM_DELETE) + ->setRouteParameters([ + 'resource_type_id' => $resource_type_id, + 'resource_id' => $resource_id + ]) + ->setPermittedUser($this->writeAccessToResourceType($resource_type_id)) + ->setUserId($this->user_id); + + $item_instance = (new Item())->instance($resource_type_id, $resource_id, $item_id); + $item_type_instance = (new \App\ItemType\AllocatedExpense\Models\Item())->instance($item_id); + + if ($item_instance === null || $item_type_instance === null) { + return \App\Response\Responses::failedToSelectModelForUpdateOrDelete(); + } + + try { + $item_instance->updated_by = $this->user_id; + + DB::transaction(static function() use ($item_instance, $item_type_instance) { + if ($item_instance->save() === true) { + $allocated_expense = new \App\ItemType\AllocatedExpense\Item(); + $allocated_expense->update(request()->all(), $item_type_instance); + } + }); + + ClearCache::dispatch($cache_job_payload->payload()); + + } catch (Exception $e) { + return \App\Response\Responses::failedToSaveModelForUpdate(); + } + + return \App\Response\Responses::successNoContent(); + } + + private function updateGame(int $resource_type_id, int $resource_id, int $item_id): JsonResponse + { + $config_base_path = 'api.item-type-game'; + + if (count(request()->all()) === 0) { + return \App\Response\Responses::nothingToPatch(); + } + + $invalid_fields = \App\Request\BodyValidation::checkForInvalidFields( + array_keys(LaravelConfig::get($config_base_path . '.validation.PATCH.fields', [])) + ); + + if (count($invalid_fields) > 0) { + return Responses::invalidFieldsInRequest($invalid_fields); + } + + $messages = []; + foreach (LaravelConfig::get($config_base_path . '.validation.PATCH.messages', []) as $key => $custom_message) { + $messages[$key] = trans($custom_message); + } + + $validator = ValidatorFacade::make( + request()->all(), + LaravelConfig::get($config_base_path . '.validation.PATCH.fields', []), + $messages + ); + + if ($validator->fails()) { + return \App\Request\BodyValidation::returnValidationErrors($validator); + } + + $cache_job_payload = (new \App\Cache\JobPayload()) + ->setGroupKey(\App\Cache\KeyGroup::ITEM_DELETE) + ->setRouteParameters([ + 'resource_type_id' => $resource_type_id, + 'resource_id' => $resource_id + ]) + ->setPermittedUser($this->writeAccessToResourceType($resource_type_id)) + ->setUserId($this->user_id); + + $item_instance = (new Item())->instance($resource_type_id, $resource_id, $item_id); + $item_type_instance = (new \App\ItemType\Game\Models\Item())->instance($item_id); + + if ($item_instance === null || $item_type_instance === null) { + return \App\Response\Responses::failedToSelectModelForUpdateOrDelete(); + } + + try { + $item_instance->updated_by = $this->user_id; + + DB::transaction(static function() use ($item_instance, $item_type_instance) { + if ($item_instance->save() === true) { + $allocated_expense = new \App\ItemType\Game\Item(); + $allocated_expense->update(request()->all(), $item_type_instance); + } + }); + + ClearCache::dispatch($cache_job_payload->payload()); + + } catch (Exception $e) { + return \App\Response\Responses::failedToSaveModelForUpdate(); + } + + return \App\Response\Responses::successNoContent(); + } + + private function updateSimpleExpense(int $resource_type_id, int $resource_id, int $item_id): JsonResponse + { + $config_base_path = 'api.item-type-simple-expense'; + + if (count(request()->all()) === 0) { + return \App\Response\Responses::nothingToPatch(); + } + + $invalid_fields = \App\Request\BodyValidation::checkForInvalidFields( + array_keys(LaravelConfig::get($config_base_path . '.validation.PATCH.fields', [])) + ); + + if (count($invalid_fields) > 0) { + return Responses::invalidFieldsInRequest($invalid_fields); + } + + $merge_array = []; + if (array_key_exists('currency_id', request()->all())) { + $decode = $this->hash->currency()->decode(request()->input('currency_id')); + $currency_id = null; + if (count($decode) === 1) { + $currency_id = $decode[0]; + } + + $merge_array = ['currency_id' => $currency_id]; + } + + $messages = []; + foreach (LaravelConfig::get($config_base_path . '.validation.PATCH.messages', []) as $key => $custom_message) { + $messages[$key] = trans($custom_message); + } + + $validator = ValidatorFacade::make( + array_merge( + request()->all(), + $merge_array + ), + LaravelConfig::get($config_base_path . '.validation.PATCH.fields', []), + $messages + ); + + if ($validator->fails()) { + return \App\Request\BodyValidation::returnValidationErrors($validator); + } + + $cache_job_payload = (new \App\Cache\JobPayload()) + ->setGroupKey(\App\Cache\KeyGroup::ITEM_DELETE) + ->setRouteParameters([ + 'resource_type_id' => $resource_type_id, + 'resource_id' => $resource_id + ]) + ->setPermittedUser($this->writeAccessToResourceType($resource_type_id)) + ->setUserId($this->user_id); + + $item_instance = (new Item())->instance($resource_type_id, $resource_id, $item_id); + $item_type_instance = (new \App\ItemType\SimpleExpense\Models\Item())->instance($item_id); + + if ($item_instance === null || $item_type_instance === null) { + return \App\Response\Responses::failedToSelectModelForUpdateOrDelete(); + } + + try { + $item_instance->updated_by = $this->user_id; + + DB::transaction(static function() use ($item_instance, $item_type_instance) { + if ($item_instance->save() === true) { + $allocated_expense = new \App\ItemType\SimpleExpense\Item(); + $allocated_expense->update(request()->all(), $item_type_instance); + } + }); + + ClearCache::dispatch($cache_job_payload->payload()); + + } catch (Exception $e) { + return \App\Response\Responses::failedToSaveModelForUpdate(); + } + + return \App\Response\Responses::successNoContent(); + } + + private function updateSimpleItem(int $resource_type_id, int $resource_id, int $item_id): JsonResponse + { + $config_base_path = 'api.item-type-simple-item'; + + if (count(request()->all()) === 0) { + return \App\Response\Responses::nothingToPatch(); + } + + $invalid_fields = \App\Request\BodyValidation::checkForInvalidFields( + array_keys(LaravelConfig::get($config_base_path . '.validation.PATCH.fields', [])) + ); + + if (count($invalid_fields) > 0) { + return Responses::invalidFieldsInRequest($invalid_fields); + } + + $messages = []; + foreach (LaravelConfig::get($config_base_path . '.validation.PATCH.messages', []) as $key => $custom_message) { + $messages[$key] = trans($custom_message); + } + + $validator = ValidatorFacade::make( + request()->all(), + LaravelConfig::get($config_base_path . '.validation.PATCH.fields', []), + $messages + ); + + if ($validator->fails()) { + return \App\Request\BodyValidation::returnValidationErrors($validator); + } + + $cache_job_payload = (new \App\Cache\JobPayload()) + ->setGroupKey(\App\Cache\KeyGroup::ITEM_DELETE) + ->setRouteParameters([ + 'resource_type_id' => $resource_type_id, + 'resource_id' => $resource_id + ]) + ->setPermittedUser($this->writeAccessToResourceType($resource_type_id)) + ->setUserId($this->user_id); + + $item_instance = (new Item())->instance($resource_type_id, $resource_id, $item_id); + $item_type_instance = (new \App\ItemType\SimpleItem\Models\Item())->instance($item_id); + + if ($item_instance === null || $item_type_instance === null) { + return \App\Response\Responses::failedToSelectModelForUpdateOrDelete(); + } + + try { + $item_instance->updated_by = $this->user_id; + + DB::transaction(static function() use ($item_instance, $item_type_instance) { + if ($item_instance->save() === true) { + $allocated_expense = new \App\ItemType\SimpleItem\Item(); + $allocated_expense->update(request()->all(), $item_type_instance); + } + }); + + ClearCache::dispatch($cache_job_payload->payload()); + + } catch (Exception $e) { + return \App\Response\Responses::failedToSaveModelForUpdate(); + } + + return \App\Response\Responses::successNoContent(); + } + public function delete( string $resource_type_id, string $resource_id, From 6d24040e91a477e8047c5f7eff7e4084af993cff Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Wed, 19 Jan 2022 23:38:42 +0000 Subject: [PATCH 37/73] Update method - Update method per item type --- app/Http/Controllers/ItemManage.php | 58 ++++------------------------- 1 file changed, 8 insertions(+), 50 deletions(-) diff --git a/app/Http/Controllers/ItemManage.php b/app/Http/Controllers/ItemManage.php index b8649352..678457b8 100644 --- a/app/Http/Controllers/ItemManage.php +++ b/app/Http/Controllers/ItemManage.php @@ -301,57 +301,15 @@ public function update( \App\Response\Responses::notFoundOrNotAccessible(trans('entities.item')); } - $entity = Entity::item($resource_type_id); - - if (count(request()->all()) === 0) { - return \App\Response\Responses::nothingToPatch(); - } - - $invalid_fields = \App\Request\BodyValidation::checkForInvalidFields(array_keys($entity->patchValidation())); - - if (count($invalid_fields) > 0) { - return Responses::invalidFieldsInRequest($invalid_fields); - } - - $validation = $entity->validator(); - $validator = $validation->update(); - - if ($validator->fails()) { - return \App\Request\BodyValidation::returnValidationErrors($validator); - } - - $cache_job_payload = (new \App\Cache\JobPayload()) - ->setGroupKey(\App\Cache\KeyGroup::ITEM_DELETE) - ->setRouteParameters([ - 'resource_type_id' => $resource_type_id, - 'resource_id' => $resource_id - ]) - ->setPermittedUser($this->writeAccessToResourceType((int) $resource_type_id)) - ->setUserId($this->user_id); - - $item = (new Item())->instance($resource_type_id, $resource_id, $item_id); - $item_type = $entity->instance((int) $item_id); - - if ($item === null || $item_type === null) { - return \App\Response\Responses::failedToSelectModelForUpdateOrDelete(); - } - - try { - $item->updated_by = $this->user_id; - - DB::transaction(static function() use ($item, $entity, $item_type) { - if ($item->save() === true) { - $entity->update(request()->all(), $item_type); - } - }); - - ClearCache::dispatch($cache_job_payload->payload()); - - } catch (Exception $e) { - return \App\Response\Responses::failedToSaveModelForUpdate(); - } + $item_type = Entity::itemType((int) $resource_type_id); - return \App\Response\Responses::successNoContent(); + return match ($item_type) { + 'allocated-expense' => $this->updateAllocatedExpense((int) $resource_type_id, (int) $resource_id, (int) $item_id), + 'game' => $this->updateGame((int) $resource_type_id, (int) $resource_id, (int) $item_id), + 'simple-expense' => $this->updateSimpleExpense((int) $resource_type_id, (int) $resource_id, (int) $item_id), + 'simple-item' => $this->updateSimpleItem((int) $resource_type_id, (int) $resource_id, (int) $item_id), + default => throw new \OutOfRangeException('No item type definition for ' . $item_type, 500), + }; } private function updateAllocatedExpense(int $resource_type_id, int $resource_id, int $item_id): JsonResponse From 3a28ab166eb9c7edb5d6fc653efff2056cebd874 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Wed, 19 Jan 2022 23:50:47 +0000 Subject: [PATCH 38/73] Tidy - Tidy up the methods --- app/Http/Controllers/ItemManage.php | 31 ++++++----------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/app/Http/Controllers/ItemManage.php b/app/Http/Controllers/ItemManage.php index 678457b8..0662de24 100644 --- a/app/Http/Controllers/ItemManage.php +++ b/app/Http/Controllers/ItemManage.php @@ -21,10 +21,7 @@ */ class ItemManage extends Controller { - public function create( - string $resource_type_id, - string $resource_id - ): JsonResponse + public function create(string $resource_type_id, string $resource_id): JsonResponse { if ($this->writeAccessToResourceType((int) $resource_type_id) === false) { \App\Response\Responses::notFoundOrNotAccessible(trans('entities.resource')); @@ -41,10 +38,7 @@ public function create( }; } - private function createAllocatedExpense( - int $resource_type_id, - int $resource_id - ): JsonResponse + private function createAllocatedExpense(int $resource_type_id, int $resource_id): JsonResponse { $config_base_path = 'api.item-type-allocated-expense'; @@ -108,10 +102,7 @@ private function createAllocatedExpense( ); } - private function createGame( - int $resource_type_id, - int $resource_id - ): JsonResponse + private function createGame(int $resource_type_id, int $resource_id): JsonResponse { $config_base_path = 'api.item-type-game'; @@ -166,10 +157,7 @@ private function createGame( ); } - private function createSimpleExpense( - int $resource_type_id, - int $resource_id - ): JsonResponse + private function createSimpleExpense(int $resource_type_id, int $resource_id): JsonResponse { $config_base_path = 'api.item-type-simple-expense'; @@ -233,10 +221,7 @@ private function createSimpleExpense( ); } - private function createSimpleItem( - int $resource_type_id, - int $resource_id - ): JsonResponse + private function createSimpleItem(int $resource_type_id, int $resource_id): JsonResponse { $config_base_path = 'api.item-type-simple-item'; @@ -291,11 +276,7 @@ private function createSimpleItem( ); } - public function update( - string $resource_type_id, - string $resource_id, - string $item_id - ): JsonResponse + public function update(string $resource_type_id, string $resource_id,string $item_id): JsonResponse { if ($this->writeAccessToResourceType((int) $resource_type_id) === false) { \App\Response\Responses::notFoundOrNotAccessible(trans('entities.item')); From 8516be8e7e82883562d50843f7ef7c0a4b0e6264 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Fri, 21 Jan 2022 10:53:35 +0000 Subject: [PATCH 39/73] Method per item type - Add a method per item type --- app/Http/Controllers/ItemManage.php | 263 ++++++++++++++++++++++------ 1 file changed, 205 insertions(+), 58 deletions(-) diff --git a/app/Http/Controllers/ItemManage.php b/app/Http/Controllers/ItemManage.php index 0662de24..f4556689 100644 --- a/app/Http/Controllers/ItemManage.php +++ b/app/Http/Controllers/ItemManage.php @@ -2,6 +2,8 @@ namespace App\Http\Controllers; +use App\Cache\JobPayload; +use App\Cache\KeyGroup; use App\ItemType\Entity; use App\Jobs\ClearCache; use App\Models\Item; @@ -24,7 +26,7 @@ class ItemManage extends Controller public function create(string $resource_type_id, string $resource_id): JsonResponse { if ($this->writeAccessToResourceType((int) $resource_type_id) === false) { - \App\Response\Responses::notFoundOrNotAccessible(trans('entities.resource')); + Responses::notFoundOrNotAccessible(trans('entities.resource')); } $item_type = Entity::itemType((int) $resource_type_id); @@ -68,8 +70,8 @@ private function createAllocatedExpense(int $resource_type_id, int $resource_id) $item = new \App\ItemType\AllocatedExpense\Item(); - $cache_job_payload = (new \App\Cache\JobPayload()) - ->setGroupKey(\App\Cache\KeyGroup::ITEM_CREATE) + $cache_job_payload = (new JobPayload()) + ->setGroupKey(KeyGroup::ITEM_CREATE) ->setRouteParameters([ 'resource_type_id' => $resource_type_id, 'resource_id' => $resource_id @@ -92,7 +94,7 @@ private function createAllocatedExpense(int $resource_type_id, int $resource_id) ClearCache::dispatch($cache_job_payload->payload()); } catch (Exception $e) { - return \App\Response\Responses::failedToSaveModelForCreate(); + return Responses::failedToSaveModelForCreate(); } $model = new \App\ItemType\AllocatedExpense\Models\Item(); @@ -123,8 +125,8 @@ private function createGame(int $resource_type_id, int $resource_id): JsonRespon $item = new \App\ItemType\Game\Item(); - $cache_job_payload = (new \App\Cache\JobPayload()) - ->setGroupKey(\App\Cache\KeyGroup::ITEM_CREATE) + $cache_job_payload = (new JobPayload()) + ->setGroupKey(KeyGroup::ITEM_CREATE) ->setRouteParameters([ 'resource_type_id' => $resource_type_id, 'resource_id' => $resource_id @@ -147,7 +149,7 @@ private function createGame(int $resource_type_id, int $resource_id): JsonRespon ClearCache::dispatch($cache_job_payload->payload()); } catch (Exception $e) { - return \App\Response\Responses::failedToSaveModelForCreate(); + return Responses::failedToSaveModelForCreate(); } $model = new \App\ItemType\Game\Models\Item(); @@ -187,8 +189,8 @@ private function createSimpleExpense(int $resource_type_id, int $resource_id): J $item = new \App\ItemType\SimpleExpense\Item(); - $cache_job_payload = (new \App\Cache\JobPayload()) - ->setGroupKey(\App\Cache\KeyGroup::ITEM_CREATE) + $cache_job_payload = (new JobPayload()) + ->setGroupKey(KeyGroup::ITEM_CREATE) ->setRouteParameters([ 'resource_type_id' => $resource_type_id, 'resource_id' => $resource_id @@ -211,7 +213,7 @@ private function createSimpleExpense(int $resource_type_id, int $resource_id): J ClearCache::dispatch($cache_job_payload->payload()); } catch (Exception $e) { - return \App\Response\Responses::failedToSaveModelForCreate(); + return Responses::failedToSaveModelForCreate(); } $model = new \App\ItemType\SimpleExpense\Models\Item(); @@ -242,8 +244,8 @@ private function createSimpleItem(int $resource_type_id, int $resource_id): Json $item = new \App\ItemType\SimpleItem\Item(); - $cache_job_payload = (new \App\Cache\JobPayload()) - ->setGroupKey(\App\Cache\KeyGroup::ITEM_CREATE) + $cache_job_payload = (new JobPayload()) + ->setGroupKey(KeyGroup::ITEM_CREATE) ->setRouteParameters([ 'resource_type_id' => $resource_type_id, 'resource_id' => $resource_id @@ -266,7 +268,7 @@ private function createSimpleItem(int $resource_type_id, int $resource_id): Json ClearCache::dispatch($cache_job_payload->payload()); } catch (Exception $e) { - return \App\Response\Responses::failedToSaveModelForCreate(); + return Responses::failedToSaveModelForCreate(); } $model = new \App\ItemType\SimpleItem\Models\Item(); @@ -279,7 +281,7 @@ private function createSimpleItem(int $resource_type_id, int $resource_id): Json public function update(string $resource_type_id, string $resource_id,string $item_id): JsonResponse { if ($this->writeAccessToResourceType((int) $resource_type_id) === false) { - \App\Response\Responses::notFoundOrNotAccessible(trans('entities.item')); + Responses::notFoundOrNotAccessible(trans('entities.item')); } $item_type = Entity::itemType((int) $resource_type_id); @@ -298,7 +300,7 @@ private function updateAllocatedExpense(int $resource_type_id, int $resource_id, $config_base_path = 'api.item-type-allocated-expense'; if (count(request()->all()) === 0) { - return \App\Response\Responses::nothingToPatch(); + return Responses::nothingToPatch(); } $invalid_fields = \App\Request\BodyValidation::checkForInvalidFields( @@ -338,8 +340,8 @@ private function updateAllocatedExpense(int $resource_type_id, int $resource_id, return \App\Request\BodyValidation::returnValidationErrors($validator); } - $cache_job_payload = (new \App\Cache\JobPayload()) - ->setGroupKey(\App\Cache\KeyGroup::ITEM_DELETE) + $cache_job_payload = (new JobPayload()) + ->setGroupKey(KeyGroup::ITEM_DELETE) ->setRouteParameters([ 'resource_type_id' => $resource_type_id, 'resource_id' => $resource_id @@ -351,7 +353,7 @@ private function updateAllocatedExpense(int $resource_type_id, int $resource_id, $item_type_instance = (new \App\ItemType\AllocatedExpense\Models\Item())->instance($item_id); if ($item_instance === null || $item_type_instance === null) { - return \App\Response\Responses::failedToSelectModelForUpdateOrDelete(); + return Responses::failedToSelectModelForUpdateOrDelete(); } try { @@ -367,10 +369,10 @@ private function updateAllocatedExpense(int $resource_type_id, int $resource_id, ClearCache::dispatch($cache_job_payload->payload()); } catch (Exception $e) { - return \App\Response\Responses::failedToSaveModelForUpdate(); + return Responses::failedToSaveModelForUpdate(); } - return \App\Response\Responses::successNoContent(); + return Responses::successNoContent(); } private function updateGame(int $resource_type_id, int $resource_id, int $item_id): JsonResponse @@ -378,7 +380,7 @@ private function updateGame(int $resource_type_id, int $resource_id, int $item_i $config_base_path = 'api.item-type-game'; if (count(request()->all()) === 0) { - return \App\Response\Responses::nothingToPatch(); + return Responses::nothingToPatch(); } $invalid_fields = \App\Request\BodyValidation::checkForInvalidFields( @@ -404,8 +406,8 @@ private function updateGame(int $resource_type_id, int $resource_id, int $item_i return \App\Request\BodyValidation::returnValidationErrors($validator); } - $cache_job_payload = (new \App\Cache\JobPayload()) - ->setGroupKey(\App\Cache\KeyGroup::ITEM_DELETE) + $cache_job_payload = (new JobPayload()) + ->setGroupKey(KeyGroup::ITEM_DELETE) ->setRouteParameters([ 'resource_type_id' => $resource_type_id, 'resource_id' => $resource_id @@ -417,7 +419,7 @@ private function updateGame(int $resource_type_id, int $resource_id, int $item_i $item_type_instance = (new \App\ItemType\Game\Models\Item())->instance($item_id); if ($item_instance === null || $item_type_instance === null) { - return \App\Response\Responses::failedToSelectModelForUpdateOrDelete(); + return Responses::failedToSelectModelForUpdateOrDelete(); } try { @@ -433,10 +435,10 @@ private function updateGame(int $resource_type_id, int $resource_id, int $item_i ClearCache::dispatch($cache_job_payload->payload()); } catch (Exception $e) { - return \App\Response\Responses::failedToSaveModelForUpdate(); + return Responses::failedToSaveModelForUpdate(); } - return \App\Response\Responses::successNoContent(); + return Responses::successNoContent(); } private function updateSimpleExpense(int $resource_type_id, int $resource_id, int $item_id): JsonResponse @@ -444,7 +446,7 @@ private function updateSimpleExpense(int $resource_type_id, int $resource_id, in $config_base_path = 'api.item-type-simple-expense'; if (count(request()->all()) === 0) { - return \App\Response\Responses::nothingToPatch(); + return Responses::nothingToPatch(); } $invalid_fields = \App\Request\BodyValidation::checkForInvalidFields( @@ -484,8 +486,8 @@ private function updateSimpleExpense(int $resource_type_id, int $resource_id, in return \App\Request\BodyValidation::returnValidationErrors($validator); } - $cache_job_payload = (new \App\Cache\JobPayload()) - ->setGroupKey(\App\Cache\KeyGroup::ITEM_DELETE) + $cache_job_payload = (new JobPayload()) + ->setGroupKey(KeyGroup::ITEM_DELETE) ->setRouteParameters([ 'resource_type_id' => $resource_type_id, 'resource_id' => $resource_id @@ -497,7 +499,7 @@ private function updateSimpleExpense(int $resource_type_id, int $resource_id, in $item_type_instance = (new \App\ItemType\SimpleExpense\Models\Item())->instance($item_id); if ($item_instance === null || $item_type_instance === null) { - return \App\Response\Responses::failedToSelectModelForUpdateOrDelete(); + return Responses::failedToSelectModelForUpdateOrDelete(); } try { @@ -513,10 +515,10 @@ private function updateSimpleExpense(int $resource_type_id, int $resource_id, in ClearCache::dispatch($cache_job_payload->payload()); } catch (Exception $e) { - return \App\Response\Responses::failedToSaveModelForUpdate(); + return Responses::failedToSaveModelForUpdate(); } - return \App\Response\Responses::successNoContent(); + return Responses::successNoContent(); } private function updateSimpleItem(int $resource_type_id, int $resource_id, int $item_id): JsonResponse @@ -524,7 +526,7 @@ private function updateSimpleItem(int $resource_type_id, int $resource_id, int $ $config_base_path = 'api.item-type-simple-item'; if (count(request()->all()) === 0) { - return \App\Response\Responses::nothingToPatch(); + return Responses::nothingToPatch(); } $invalid_fields = \App\Request\BodyValidation::checkForInvalidFields( @@ -550,8 +552,8 @@ private function updateSimpleItem(int $resource_type_id, int $resource_id, int $ return \App\Request\BodyValidation::returnValidationErrors($validator); } - $cache_job_payload = (new \App\Cache\JobPayload()) - ->setGroupKey(\App\Cache\KeyGroup::ITEM_DELETE) + $cache_job_payload = (new JobPayload()) + ->setGroupKey(KeyGroup::ITEM_DELETE) ->setRouteParameters([ 'resource_type_id' => $resource_type_id, 'resource_id' => $resource_id @@ -563,7 +565,7 @@ private function updateSimpleItem(int $resource_type_id, int $resource_id, int $ $item_type_instance = (new \App\ItemType\SimpleItem\Models\Item())->instance($item_id); if ($item_instance === null || $item_type_instance === null) { - return \App\Response\Responses::failedToSelectModelForUpdateOrDelete(); + return Responses::failedToSelectModelForUpdateOrDelete(); } try { @@ -579,26 +581,172 @@ private function updateSimpleItem(int $resource_type_id, int $resource_id, int $ ClearCache::dispatch($cache_job_payload->payload()); } catch (Exception $e) { - return \App\Response\Responses::failedToSaveModelForUpdate(); + return Responses::failedToSaveModelForUpdate(); } - return \App\Response\Responses::successNoContent(); + return Responses::successNoContent(); } - public function delete( + public function delete(string $resource_type_id, string $resource_id,string $item_id): JsonResponse + { + if ($this->writeAccessToResourceType((int) $resource_type_id) === false) { + Responses::notFoundOrNotAccessible(trans('entities.item')); + } + + $item_type = Entity::itemType((int) $resource_type_id); + + return match ($item_type) { + 'allocated-expense' => $this->deleteAllocatedExpense((int) $resource_type_id, (int) $resource_id, (int) $item_id), + 'game' => $this->deleteGame((int) $resource_type_id, (int) $resource_id, (int) $item_id), + 'simple-expense' => $this->deleteSimpleExpense((int) $resource_type_id, (int) $resource_id, (int) $item_id), + 'simple-item' => $this->deleteSimpleItem((int) $resource_type_id, (int) $resource_id, (int) $item_id), + default => throw new \OutOfRangeException('No item type definition for ' . $item_type, 500), + }; + } + + private function deleteAllocatedExpense( string $resource_type_id, string $resource_id, string $item_id ): JsonResponse { - if ($this->writeAccessToResourceType((int) $resource_type_id) === false) { - \App\Response\Responses::notFoundOrNotAccessible(trans('entities.item')); + $cache_job_payload = (new JobPayload()) + ->setGroupKey(KeyGroup::ITEM_DELETE) + ->setRouteParameters([ + 'resource_type_id' => $resource_type_id, + 'resource_id' => $resource_id + ]) + ->setPermittedUser($this->writeAccessToResourceType((int) $resource_type_id)) + ->setUserId($this->user_id); + + $item_model = new \App\ItemType\AllocatedExpense\Models\Item(); + + $item_type_instance = $item_model->instance($item_id); + $item_instance = (new Item())->instance($resource_type_id, $resource_id, $item_id); + + if ($item_instance === null || $item_type_instance === null) { + return Responses::notFound(trans('entities.item')); + } + + if ($item_model->hasCategoryAssignments($item_id) === true) { + return Responses::foreignKeyConstraintError(); + } + + try { + DB::transaction(static function() use ($item_id, $item_type_instance, $item_instance) { + (new ItemTransfer())->deleteTransfers($item_id); + $item_type_instance->delete(); + $item_instance->delete(); + }); + + ClearCache::dispatch($cache_job_payload->payload()); + + return Responses::successNoContent(); + } catch (QueryException $e) { + return Responses::foreignKeyConstraintError(); + } catch (Exception $e) { + return Responses::notFound(trans('entities.item')); + } + } + + private function deleteGame( + string $resource_type_id, + string $resource_id, + string $item_id + ): JsonResponse + { + $cache_job_payload = (new JobPayload()) + ->setGroupKey(KeyGroup::ITEM_DELETE) + ->setRouteParameters([ + 'resource_type_id' => $resource_type_id, + 'resource_id' => $resource_id + ]) + ->setPermittedUser($this->writeAccessToResourceType((int) $resource_type_id)) + ->setUserId($this->user_id); + + $item_model = new \App\ItemType\Game\Models\Item(); + + $item_type_instance = $item_model->instance($item_id); + $item_instance = (new Item())->instance($resource_type_id, $resource_id, $item_id); + + if ($item_instance === null || $item_type_instance === null) { + return Responses::notFound(trans('entities.item')); + } + + if ($item_model->hasCategoryAssignments($item_id) === true) { + return Responses::foreignKeyConstraintError(); + } + + try { + DB::transaction(static function() use ($item_id, $item_type_instance, $item_instance) { + (new ItemTransfer())->deleteTransfers($item_id); + $item_type_instance->delete(); + $item_instance->delete(); + }); + + ClearCache::dispatch($cache_job_payload->payload()); + + return Responses::successNoContent(); + } catch (QueryException $e) { + return Responses::foreignKeyConstraintError(); + } catch (Exception $e) { + return Responses::notFound(trans('entities.item')); + } + } + + private function deleteSimpleExpense( + string $resource_type_id, + string $resource_id, + string $item_id + ): JsonResponse + { + $cache_job_payload = (new JobPayload()) + ->setGroupKey(KeyGroup::ITEM_DELETE) + ->setRouteParameters([ + 'resource_type_id' => $resource_type_id, + 'resource_id' => $resource_id + ]) + ->setPermittedUser($this->writeAccessToResourceType((int) $resource_type_id)) + ->setUserId($this->user_id); + + $item_model = new \App\ItemType\SimpleExpense\Models\Item(); + + $item_type_instance = $item_model->instance($item_id); + $item_instance = (new Item())->instance($resource_type_id, $resource_id, $item_id); + + if ($item_instance === null || $item_type_instance === null) { + return Responses::notFound(trans('entities.item')); } - $entity = Entity::item($resource_type_id); + if ($item_model->hasCategoryAssignments($item_id) === true) { + return Responses::foreignKeyConstraintError(); + } + + try { + DB::transaction(static function() use ($item_id, $item_type_instance, $item_instance) { + (new ItemTransfer())->deleteTransfers($item_id); + $item_type_instance->delete(); + $item_instance->delete(); + }); + + ClearCache::dispatch($cache_job_payload->payload()); - $cache_job_payload = (new \App\Cache\JobPayload()) - ->setGroupKey(\App\Cache\KeyGroup::ITEM_DELETE) + return Responses::successNoContent(); + } catch (QueryException $e) { + return Responses::foreignKeyConstraintError(); + } catch (Exception $e) { + return Responses::notFound(trans('entities.item')); + } + } + + private function deleteSimpleItem( + string $resource_type_id, + string $resource_id, + string $item_id + ): JsonResponse + { + $cache_job_payload = (new JobPayload()) + ->setGroupKey(KeyGroup::ITEM_DELETE) ->setRouteParameters([ 'resource_type_id' => $resource_type_id, 'resource_id' => $resource_id @@ -606,34 +754,33 @@ public function delete( ->setPermittedUser($this->writeAccessToResourceType((int) $resource_type_id)) ->setUserId($this->user_id); - $item_model = $entity->model(); + $item_model = new \App\ItemType\SimpleItem\Models\Item(); - $item_type = $item_model->instance($item_id); - $item = (new Item())->instance($resource_type_id, $resource_id, $item_id); + $item_type_instance = $item_model->instance($item_id); + $item_instance = (new Item())->instance($resource_type_id, $resource_id, $item_id); - if ($item === null || $item_type === null) { - return \App\Response\Responses::notFound(trans('entities.item')); + if ($item_instance === null || $item_type_instance === null) { + return Responses::notFound(trans('entities.item')); } - if (in_array($entity->type(), ['allocated-expense', 'simple-expense']) && - $item_model->hasCategoryAssignments($item_id) === true) { - return \App\Response\Responses::foreignKeyConstraintError(); + if ($item_model->hasCategoryAssignments($item_id) === true) { + return Responses::foreignKeyConstraintError(); } try { - DB::transaction(static function() use ($item_id, $item_type, $item) { + DB::transaction(static function() use ($item_id, $item_type_instance, $item_instance) { (new ItemTransfer())->deleteTransfers($item_id); - $item_type->delete(); - $item->delete(); + $item_type_instance->delete(); + $item_instance->delete(); }); ClearCache::dispatch($cache_job_payload->payload()); - return \App\Response\Responses::successNoContent(); + return Responses::successNoContent(); } catch (QueryException $e) { - return \App\Response\Responses::foreignKeyConstraintError(); + return Responses::foreignKeyConstraintError(); } catch (Exception $e) { - return \App\Response\Responses::notFound(trans('entities.item')); + return Responses::notFound(trans('entities.item')); } } } From cc6c4b54df1c124d7532125bc21f939b764e9438 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Fri, 21 Jan 2022 11:39:04 +0000 Subject: [PATCH 40/73] Method per type - Add a method per item type, simple code and allows more customisation down the line --- app/Http/Controllers/ItemCategoryView.php | 108 +++++++++++++++++++++- 1 file changed, 105 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/ItemCategoryView.php b/app/Http/Controllers/ItemCategoryView.php index cffedf85..d3e949b0 100644 --- a/app/Http/Controllers/ItemCategoryView.php +++ b/app/Http/Controllers/ItemCategoryView.php @@ -25,6 +25,61 @@ public function index(string $resource_type_id, string $resource_id, string $ite \App\Response\Responses::notFoundOrNotAccessible(trans('entities.item')); } + $item_type = Entity::itemType((int) $resource_type_id); + + return match ($item_type) { + 'allocated-expense' => $this->allocatedExpenseCollection((int) $resource_type_id, (int) $resource_id, (int) $item_id), + 'game' => $this->gameCollection((int) $resource_type_id, (int) $resource_id, (int) $item_id), + 'simple-expense' => $this->simpleExpenseCollection((int) $resource_type_id, (int) $resource_id, (int) $item_id), + 'simple-item' => $this->simpleItemCollection((int) $resource_type_id, (int) $resource_id, (int) $item_id), + default => throw new \OutOfRangeException('No item type definition for ' . $item_type, 500), + }; + } + + public function allocatedExpenseCollection(string $resource_type_id, string $resource_id, string $item_id): JsonResponse + { + $cache_control = new \App\Cache\Control( + $this->writeAccessToResourceType((int) $resource_type_id), + $this->user_id + ); + $cache_control->setTtlOneWeek(); + + $cache_collection = new \App\Cache\Collection(); + $cache_collection->setFromCache($cache_control->getByKey(request()->getRequestUri())); + + if ($cache_control->isRequestCacheable() === false || $cache_collection->valid() === false) { + + $item_category = (new ItemCategory())->paginatedCollection( + $resource_type_id, + $resource_id, + $item_id + ); + + if ((count($item_category) === 0)) { + $collection = []; + } else { + $collection = array_map( + static function ($category) { + return (new ItemCategoryTransformer($category))->asArray(); + }, + $item_category + ); + } + + $headers = new Header(); + $headers->add('X-Total-Count', count($collection)); + $headers->add('X-Count', count($collection)); + $headers->addCacheControl($cache_control->visibility(), $cache_control->ttl()); + + $cache_collection->create(count($collection), $collection, [], $headers->headers()); + $cache_control->putByKey(request()->getRequestUri(), $cache_collection->content()); + } + + return response()->json($cache_collection->collection(), 200, $cache_collection->headers()); + } + + public function gameCollection(string $resource_type_id, string $resource_id, string $item_id): JsonResponse + { $cache_control = new \App\Cache\Control( $this->writeAccessToResourceType((int) $resource_type_id), $this->user_id @@ -42,7 +97,7 @@ public function index(string $resource_type_id, string $resource_id, string $ite $item_id ); - if ($item_category === null || (is_array($item_category) === true && count($item_category) === 0)) { + if ((count($item_category) === 0)) { $collection = []; } else { $collection = array_map( @@ -54,8 +109,8 @@ static function ($category) { } $headers = new Header(); - $headers->add('X-Total-Count', 1); - $headers->add('X-Count', 1); + $headers->add('X-Total-Count', count($collection)); + $headers->add('X-Count', count($collection)); $headers->addCacheControl($cache_control->visibility(), $cache_control->ttl()); $cache_collection->create(count($collection), $collection, [], $headers->headers()); @@ -65,6 +120,53 @@ static function ($category) { return response()->json($cache_collection->collection(), 200, $cache_collection->headers()); } + public function simpleExpenseCollection(string $resource_type_id, string $resource_id, string $item_id): JsonResponse + { + $cache_control = new \App\Cache\Control( + $this->writeAccessToResourceType((int) $resource_type_id), + $this->user_id + ); + $cache_control->setTtlOneWeek(); + + $cache_collection = new \App\Cache\Collection(); + $cache_collection->setFromCache($cache_control->getByKey(request()->getRequestUri())); + + if ($cache_control->isRequestCacheable() === false || $cache_collection->valid() === false) { + + $item_category = (new ItemCategory())->paginatedCollection( + $resource_type_id, + $resource_id, + $item_id + ); + + if ((count($item_category) === 0)) { + $collection = []; + } else { + $collection = array_map( + static function ($category) { + return (new ItemCategoryTransformer($category))->asArray(); + }, + $item_category + ); + } + + $headers = new Header(); + $headers->add('X-Total-Count', count($collection)); + $headers->add('X-Count', count($collection)); + $headers->addCacheControl($cache_control->visibility(), $cache_control->ttl()); + + $cache_collection->create(count($collection), $collection, [], $headers->headers()); + $cache_control->putByKey(request()->getRequestUri(), $cache_collection->content()); + } + + return response()->json($cache_collection->collection(), 200, $cache_collection->headers()); + } + + public function simpleItemCollection(string $resource_type_id, string $resource_id, string $item_id): JsonResponse + { + return \App\Response\Responses::notSupported(); + } + public function show( string $resource_type_id, string $resource_id, From e518da503cb0a4895c9dea15a8f8ebddc12dda74 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Fri, 21 Jan 2022 11:58:22 +0000 Subject: [PATCH 41/73] Refactoring - Upgrading item category option requests for the collection --- app/Http/Controllers/ItemCategoryView.php | 68 ++++++++++++++++++++--- app/Option/ItemCategoryCollection.php | 28 ---------- 2 files changed, 61 insertions(+), 35 deletions(-) delete mode 100644 app/Option/ItemCategoryCollection.php diff --git a/app/Http/Controllers/ItemCategoryView.php b/app/Http/Controllers/ItemCategoryView.php index d3e949b0..e7bbeeb5 100644 --- a/app/Http/Controllers/ItemCategoryView.php +++ b/app/Http/Controllers/ItemCategoryView.php @@ -4,9 +4,12 @@ use App\ItemType\Entity; use App\Models\ItemCategory; -use App\Option\ItemCategoryCollection; +use App\Option\ItemCategory\AllocatedExpenseCollection; +use App\Option\ItemCategory\GameCollection; +use App\Option\ItemCategory\SimpleExpenseCollection; use App\Option\ItemCategoryItem; use App\Response\Header; +use App\Response\Responses; use App\Transformers\ItemCategory as ItemCategoryTransformer; use Illuminate\Http\JsonResponse; @@ -36,7 +39,7 @@ public function index(string $resource_type_id, string $resource_id, string $ite }; } - public function allocatedExpenseCollection(string $resource_type_id, string $resource_id, string $item_id): JsonResponse + private function allocatedExpenseCollection(string $resource_type_id, string $resource_id, string $item_id): JsonResponse { $cache_control = new \App\Cache\Control( $this->writeAccessToResourceType((int) $resource_type_id), @@ -78,7 +81,7 @@ static function ($category) { return response()->json($cache_collection->collection(), 200, $cache_collection->headers()); } - public function gameCollection(string $resource_type_id, string $resource_id, string $item_id): JsonResponse + private function gameCollection(string $resource_type_id, string $resource_id, string $item_id): JsonResponse { $cache_control = new \App\Cache\Control( $this->writeAccessToResourceType((int) $resource_type_id), @@ -120,7 +123,7 @@ static function ($category) { return response()->json($cache_collection->collection(), 200, $cache_collection->headers()); } - public function simpleExpenseCollection(string $resource_type_id, string $resource_id, string $item_id): JsonResponse + private function simpleExpenseCollection(string $resource_type_id, string $resource_id, string $item_id): JsonResponse { $cache_control = new \App\Cache\Control( $this->writeAccessToResourceType((int) $resource_type_id), @@ -162,7 +165,7 @@ static function ($category) { return response()->json($cache_collection->collection(), 200, $cache_collection->headers()); } - public function simpleItemCollection(string $resource_type_id, string $resource_id, string $item_id): JsonResponse + private function simpleItemCollection(string $resource_type_id, string $resource_id, string $item_id): JsonResponse { return \App\Response\Responses::notSupported(); } @@ -209,16 +212,67 @@ public function optionsIndex(string $resource_type_id, string $resource_id, stri \App\Response\Responses::notFoundOrNotAccessible(trans('entities.item')); } - $response = new ItemCategoryCollection($this->permissions((int) $resource_type_id)); + $item_type = Entity::itemType((int) $resource_type_id); + + return match ($item_type) { + 'allocated-expense' => $this->optionsAllocatedExpenseCollection((int) $resource_type_id), + 'game' => $this->optionsGameCollection((int) $resource_type_id), + 'simple-expense' => $this->optionsSimpleExpenseCollection((int) $resource_type_id), + 'simple-item' => $this->optionsSimpleItemCollection((int) $resource_type_id), + default => throw new \OutOfRangeException('No item type definition for ' . $item_type, 500), + }; + } + + private function optionsAllocatedExpenseCollection(string $resource_type_id): JsonResponse + { + if ($this->viewAccessToResourceType((int) $resource_type_id) === false) { + \App\Response\Responses::notFoundOrNotAccessible(trans('entities.item')); + } + + $response = new AllocatedExpenseCollection($this->permissions((int) $resource_type_id)); return $response - ->setEntity(Entity::item($resource_type_id)) ->setDynamicAllowedFields( (new \App\AllowedValue\Category())->allowedValues($resource_type_id)) ->create() ->response(); } + private function optionsGameCollection(string $resource_type_id): JsonResponse + { + if ($this->viewAccessToResourceType((int) $resource_type_id) === false) { + \App\Response\Responses::notFoundOrNotAccessible(trans('entities.item')); + } + + $response = new GameCollection($this->permissions((int) $resource_type_id)); + + return $response + ->setDynamicAllowedFields( + (new \App\AllowedValue\Category())->allowedValues($resource_type_id)) + ->create() + ->response(); + } + + private function optionsSimpleExpenseCollection(string $resource_type_id): JsonResponse + { + if ($this->viewAccessToResourceType((int) $resource_type_id) === false) { + \App\Response\Responses::notFoundOrNotAccessible(trans('entities.item')); + } + + $response = new SimpleExpenseCollection($this->permissions((int) $resource_type_id)); + + return $response + ->setDynamicAllowedFields( + (new \App\AllowedValue\Category())->allowedValues($resource_type_id)) + ->create() + ->response(); + } + + private function optionsSimpleItemCollection(string $resource_type_id): JsonResponse + { + return Responses::notSupported(); + } + public function optionsShow( string $resource_type_id, string $resource_id, diff --git a/app/Option/ItemCategoryCollection.php b/app/Option/ItemCategoryCollection.php deleted file mode 100644 index 6242ac99..00000000 --- a/app/Option/ItemCategoryCollection.php +++ /dev/null @@ -1,28 +0,0 @@ -verbs['GET'] = $get->setAuthenticationStatus($this->permissions['view'])-> - setParameters(Config::get('api.item-category.parameters.collection'))-> - setDescription('route-descriptions.item_category_GET_index')-> - option(); - - $post = new \App\Method\PostRequest(); - $this->verbs['POST'] = $post->setFields(Config::get('api.item-category.fields'))-> - setDynamicFields($this->allowed_fields)-> - setAuthenticationRequirement(true)-> - setAuthenticationStatus($this->permissions['manage'])-> - setDescription('route-descriptions.item_category_POST_' . $this->entity->type())-> - option(); - - return $this; - } -} From 31b444ac6f8a3b344413761bd8db6137734849d1 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Fri, 21 Jan 2022 11:58:47 +0000 Subject: [PATCH 42/73] Refactoring - Updated the option requests for the item category collections --- .../AllocatedExpenseCollection.php | 29 +++++++++++++++++++ app/Option/ItemCategory/GameCollection.php | 29 +++++++++++++++++++ .../ItemCategory/SimpleExpenseCollection.php | 29 +++++++++++++++++++ resources/lang/en/route-descriptions.php | 2 -- 4 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 app/Option/ItemCategory/AllocatedExpenseCollection.php create mode 100644 app/Option/ItemCategory/GameCollection.php create mode 100644 app/Option/ItemCategory/SimpleExpenseCollection.php diff --git a/app/Option/ItemCategory/AllocatedExpenseCollection.php b/app/Option/ItemCategory/AllocatedExpenseCollection.php new file mode 100644 index 00000000..e774287b --- /dev/null +++ b/app/Option/ItemCategory/AllocatedExpenseCollection.php @@ -0,0 +1,29 @@ +verbs['GET'] = $get->setAuthenticationStatus($this->permissions['view'])-> + setParameters(Config::get('api.item-category.parameters.collection'))-> + setDescription('route-descriptions.item_category_GET_index')-> + option(); + + $post = new \App\Method\PostRequest(); + $this->verbs['POST'] = $post->setFields(Config::get('api.item-category.fields'))-> + setDynamicFields($this->allowed_fields)-> + setAuthenticationRequirement(true)-> + setAuthenticationStatus($this->permissions['manage'])-> + setDescription('route-descriptions.item_category_POST_allocated-expense')-> + option(); + + return $this; + } +} diff --git a/app/Option/ItemCategory/GameCollection.php b/app/Option/ItemCategory/GameCollection.php new file mode 100644 index 00000000..d3cb5394 --- /dev/null +++ b/app/Option/ItemCategory/GameCollection.php @@ -0,0 +1,29 @@ +verbs['GET'] = $get->setAuthenticationStatus($this->permissions['view'])-> + setParameters(Config::get('api.item-category.parameters.collection'))-> + setDescription('route-descriptions.item_category_GET_index')-> + option(); + + $post = new \App\Method\PostRequest(); + $this->verbs['POST'] = $post->setFields(Config::get('api.item-category.fields'))-> + setDynamicFields($this->allowed_fields)-> + setAuthenticationRequirement(true)-> + setAuthenticationStatus($this->permissions['manage'])-> + setDescription('route-descriptions.item_category_POST_game')-> + option(); + + return $this; + } +} diff --git a/app/Option/ItemCategory/SimpleExpenseCollection.php b/app/Option/ItemCategory/SimpleExpenseCollection.php new file mode 100644 index 00000000..ee4f49fd --- /dev/null +++ b/app/Option/ItemCategory/SimpleExpenseCollection.php @@ -0,0 +1,29 @@ +verbs['GET'] = $get->setAuthenticationStatus($this->permissions['view'])-> + setParameters(Config::get('api.item-category.parameters.collection'))-> + setDescription('route-descriptions.item_category_GET_index')-> + option(); + + $post = new \App\Method\PostRequest(); + $this->verbs['POST'] = $post->setFields(Config::get('api.item-category.fields'))-> + setDynamicFields($this->allowed_fields)-> + setAuthenticationRequirement(true)-> + setAuthenticationStatus($this->permissions['manage'])-> + setDescription('route-descriptions.item_category_POST_simple-expense')-> + option(); + + return $this; + } +} diff --git a/resources/lang/en/route-descriptions.php b/resources/lang/en/route-descriptions.php index d85393fc..12508f64 100644 --- a/resources/lang/en/route-descriptions.php +++ b/resources/lang/en/route-descriptions.php @@ -65,7 +65,6 @@ 'item_category_POST_allocated-expense' => 'Assign a maximum of one category to the selected allocated-expense', 'item_category_POST_simple-expense' => 'Assign a maximum of one category to the selected simple-expense', - 'item_category_POST_simple-item' => 'Category assignment not support for simple-item', 'item_category_POST_game' => 'Assign the categories (players) to the selected game', 'item_category_PATCH' => 'Update the category assigned to the selected item', @@ -76,7 +75,6 @@ 'item_sub_category_POST_allocated-expense' => 'Assign a maximum of one subcategory to the selected allocated-expense', 'item_sub_category_POST_simple-expense' => 'Assign a maximum of one subcategory to the selected simple-expense', - 'item_sub_category_POST_simple-item' => 'Subcategory assignment not support for simple-item', 'item_sub_category_PATCH' => 'Update the subcategory assigned to the selected item', 'item_sub_category_DELETE' => 'Delete the subcategory assigned to the selected item', From 96aadc483499424113a320c34ca15e5453a10790 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Fri, 21 Jan 2022 12:22:14 +0000 Subject: [PATCH 43/73] Refactoring - Update the options requests for the default show request --- app/Http/Controllers/ItemCategoryView.php | 106 +++++++++++++++--- app/Http/Controllers/ItemManage.php | 16 ++- app/Option/ItemCategory/AllocatedExpense.php | 27 +++++ .../Game.php} | 5 +- app/Option/ItemCategory/SimpleExpense.php | 27 +++++ 5 files changed, 163 insertions(+), 18 deletions(-) create mode 100644 app/Option/ItemCategory/AllocatedExpense.php rename app/Option/{ItemCategoryItem.php => ItemCategory/Game.php} (89%) create mode 100644 app/Option/ItemCategory/SimpleExpense.php diff --git a/app/Http/Controllers/ItemCategoryView.php b/app/Http/Controllers/ItemCategoryView.php index e7bbeeb5..60a24070 100644 --- a/app/Http/Controllers/ItemCategoryView.php +++ b/app/Http/Controllers/ItemCategoryView.php @@ -4,10 +4,12 @@ use App\ItemType\Entity; use App\Models\ItemCategory; +use App\Option\ItemCategory\AllocatedExpense; use App\Option\ItemCategory\AllocatedExpenseCollection; +use App\Option\ItemCategory\Game; use App\Option\ItemCategory\GameCollection; +use App\Option\ItemCategory\SimpleExpense; use App\Option\ItemCategory\SimpleExpenseCollection; -use App\Option\ItemCategoryItem; use App\Response\Header; use App\Response\Responses; use App\Transformers\ItemCategory as ItemCategoryTransformer; @@ -39,7 +41,7 @@ public function index(string $resource_type_id, string $resource_id, string $ite }; } - private function allocatedExpenseCollection(string $resource_type_id, string $resource_id, string $item_id): JsonResponse + private function allocatedExpenseCollection(int $resource_type_id, int $resource_id, int $item_id): JsonResponse { $cache_control = new \App\Cache\Control( $this->writeAccessToResourceType((int) $resource_type_id), @@ -81,7 +83,7 @@ static function ($category) { return response()->json($cache_collection->collection(), 200, $cache_collection->headers()); } - private function gameCollection(string $resource_type_id, string $resource_id, string $item_id): JsonResponse + private function gameCollection(int $resource_type_id, int $resource_id, int $item_id): JsonResponse { $cache_control = new \App\Cache\Control( $this->writeAccessToResourceType((int) $resource_type_id), @@ -123,10 +125,10 @@ static function ($category) { return response()->json($cache_collection->collection(), 200, $cache_collection->headers()); } - private function simpleExpenseCollection(string $resource_type_id, string $resource_id, string $item_id): JsonResponse + private function simpleExpenseCollection(int $resource_type_id, int $resource_id, int $item_id): JsonResponse { $cache_control = new \App\Cache\Control( - $this->writeAccessToResourceType((int) $resource_type_id), + $this->writeAccessToResourceType($resource_type_id), $this->user_id ); $cache_control->setTtlOneWeek(); @@ -165,7 +167,7 @@ static function ($category) { return response()->json($cache_collection->collection(), 200, $cache_collection->headers()); } - private function simpleItemCollection(string $resource_type_id, string $resource_id, string $item_id): JsonResponse + private function simpleItemCollection(int $resource_type_id, int $resource_id, int $item_id): JsonResponse { return \App\Response\Responses::notSupported(); } @@ -223,7 +225,7 @@ public function optionsIndex(string $resource_type_id, string $resource_id, stri }; } - private function optionsAllocatedExpenseCollection(string $resource_type_id): JsonResponse + private function optionsAllocatedExpenseCollection(int $resource_type_id): JsonResponse { if ($this->viewAccessToResourceType((int) $resource_type_id) === false) { \App\Response\Responses::notFoundOrNotAccessible(trans('entities.item')); @@ -238,13 +240,13 @@ private function optionsAllocatedExpenseCollection(string $resource_type_id): Js ->response(); } - private function optionsGameCollection(string $resource_type_id): JsonResponse + private function optionsGameCollection(int $resource_type_id): JsonResponse { - if ($this->viewAccessToResourceType((int) $resource_type_id) === false) { + if ($this->viewAccessToResourceType($resource_type_id) === false) { \App\Response\Responses::notFoundOrNotAccessible(trans('entities.item')); } - $response = new GameCollection($this->permissions((int) $resource_type_id)); + $response = new GameCollection($this->permissions($resource_type_id)); return $response ->setDynamicAllowedFields( @@ -253,13 +255,13 @@ private function optionsGameCollection(string $resource_type_id): JsonResponse ->response(); } - private function optionsSimpleExpenseCollection(string $resource_type_id): JsonResponse + private function optionsSimpleExpenseCollection(int $resource_type_id): JsonResponse { - if ($this->viewAccessToResourceType((int) $resource_type_id) === false) { + if ($this->viewAccessToResourceType($resource_type_id) === false) { \App\Response\Responses::notFoundOrNotAccessible(trans('entities.item')); } - $response = new SimpleExpenseCollection($this->permissions((int) $resource_type_id)); + $response = new SimpleExpenseCollection($this->permissions($resource_type_id)); return $response ->setDynamicAllowedFields( @@ -268,7 +270,7 @@ private function optionsSimpleExpenseCollection(string $resource_type_id): JsonR ->response(); } - private function optionsSimpleItemCollection(string $resource_type_id): JsonResponse + private function optionsSimpleItemCollection(int $resource_type_id): JsonResponse { return Responses::notSupported(); } @@ -288,6 +290,24 @@ public function optionsShow( return \App\Response\Responses::notFound(trans('entities.item-category')); } + $item_type = Entity::itemType((int) $resource_type_id); + + return match ($item_type) { + 'allocated-expense' => $this->optionsAllocatedExpenseShow((int) $resource_type_id, (int) $resource_id, (int) $item_id, (int) $item_category_id), + 'game' => $this->optionsGameShow((int) $resource_type_id, (int) $resource_id, (int) $item_id, (int) $item_category_id), + 'simple-expense' => $this->optionsSimpleExpenseShow((int) $resource_type_id, (int) $resource_id, (int) $item_id, (int) $item_category_id), + 'simple-item' => $this->optionsSimpleItemShow((int) $resource_type_id, (int) $resource_id, (int) $item_id, (int) $item_category_id), + default => throw new \OutOfRangeException('No item type definition for ' . $item_type, 500), + }; + } + + private function optionsAllocatedExpenseShow( + int $resource_type_id, + int $resource_id, + int $item_id, + int $item_category_id + ): JsonResponse + { $item_category = (new ItemCategory())->single( $resource_type_id, $resource_id, @@ -299,8 +319,64 @@ public function optionsShow( return \App\Response\Responses::notFound(trans('entities.item-category')); } - $response = new ItemCategoryItem($this->permissions((int) $resource_type_id)); + $response = new AllocatedExpense($this->permissions((int) $resource_type_id)); return $response->create()->response(); } + + private function optionsGameShow( + int $resource_type_id, + int $resource_id, + int $item_id, + int $item_category_id + ): JsonResponse + { + $item_category = (new ItemCategory())->single( + $resource_type_id, + $resource_id, + $item_id, + $item_category_id + ); + + if ($item_category === null) { + return \App\Response\Responses::notFound(trans('entities.item-category')); + } + + $response = new Game($this->permissions((int) $resource_type_id)); + + return $response->create()->response(); + } + + private function optionsSimpleExpenseShow( + int $resource_type_id, + int $resource_id, + int $item_id, + int $item_category_id + ): JsonResponse + { + $item_category = (new ItemCategory())->single( + $resource_type_id, + $resource_id, + $item_id, + $item_category_id + ); + + if ($item_category === null) { + return \App\Response\Responses::notFound(trans('entities.item-category')); + } + + $response = new SimpleExpense($this->permissions((int) $resource_type_id)); + + return $response->create()->response(); + } + + private function optionsSimpleItemShow( + int $resource_type_id, + int $resource_id, + int $item_id, + int $item_category_id + ): JsonResponse + { + return Responses::notSupported(); + } } diff --git a/app/Http/Controllers/ItemManage.php b/app/Http/Controllers/ItemManage.php index f4556689..3dd70ff3 100644 --- a/app/Http/Controllers/ItemManage.php +++ b/app/Http/Controllers/ItemManage.php @@ -391,13 +391,27 @@ private function updateGame(int $resource_type_id, int $resource_id, int $item_i return Responses::invalidFieldsInRequest($invalid_fields); } + $merge_array = []; + if (array_key_exists('winner_id', request()->all())) { + $decode = $this->hash->category()->decode(request()->input('winner_id')); + $winner_id = null; + if (count($decode) === 1) { + $winner_id = $decode[0]; + } + + $merge_array = ['winner_id' => $winner_id]; + } + $messages = []; foreach (LaravelConfig::get($config_base_path . '.validation.PATCH.messages', []) as $key => $custom_message) { $messages[$key] = trans($custom_message); } $validator = ValidatorFacade::make( - request()->all(), + array_merge( + request()->all(), + $merge_array + ), LaravelConfig::get($config_base_path . '.validation.PATCH.fields', []), $messages ); diff --git a/app/Option/ItemCategory/AllocatedExpense.php b/app/Option/ItemCategory/AllocatedExpense.php new file mode 100644 index 00000000..5de455c4 --- /dev/null +++ b/app/Option/ItemCategory/AllocatedExpense.php @@ -0,0 +1,27 @@ +verbs['GET'] = $get->setParameters(Config::get('api.item-category.parameters.item'))-> + setAuthenticationStatus($this->permissions['view'])-> + setDescription('route-descriptions.item_category_GET_show')-> + option(); + + $delete = new \App\Method\DeleteRequest(); + $this->verbs['DELETE'] = $delete->setDescription('route-descriptions.item_category_DELETE')-> + setAuthenticationStatus($this->permissions['manage'])-> + setAuthenticationRequirement(true)-> + option(); + + return $this; + } +} diff --git a/app/Option/ItemCategoryItem.php b/app/Option/ItemCategory/Game.php similarity index 89% rename from app/Option/ItemCategoryItem.php rename to app/Option/ItemCategory/Game.php index 29354260..db6db1a6 100644 --- a/app/Option/ItemCategoryItem.php +++ b/app/Option/ItemCategory/Game.php @@ -1,11 +1,12 @@ verbs['GET'] = $get->setParameters(Config::get('api.item-category.parameters.item'))-> + setAuthenticationStatus($this->permissions['view'])-> + setDescription('route-descriptions.item_category_GET_show')-> + option(); + + $delete = new \App\Method\DeleteRequest(); + $this->verbs['DELETE'] = $delete->setDescription('route-descriptions.item_category_DELETE')-> + setAuthenticationStatus($this->permissions['manage'])-> + setAuthenticationRequirement(true)-> + option(); + + return $this; + } +} From fa6ec1013bbaff71bbcb4ba9c2795e6016f600cc Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Fri, 21 Jan 2022 12:35:34 +0000 Subject: [PATCH 44/73] Refactoring - Rework the options request for an item category --- app/Http/Controllers/ItemCategoryView.php | 42 ++++++++++------------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/app/Http/Controllers/ItemCategoryView.php b/app/Http/Controllers/ItemCategoryView.php index 60a24070..8ebe007c 100644 --- a/app/Http/Controllers/ItemCategoryView.php +++ b/app/Http/Controllers/ItemCategoryView.php @@ -16,8 +16,6 @@ use Illuminate\Http\JsonResponse; /** - * Manage the category for an item row - * * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE @@ -36,7 +34,7 @@ public function index(string $resource_type_id, string $resource_id, string $ite 'allocated-expense' => $this->allocatedExpenseCollection((int) $resource_type_id, (int) $resource_id, (int) $item_id), 'game' => $this->gameCollection((int) $resource_type_id, (int) $resource_id, (int) $item_id), 'simple-expense' => $this->simpleExpenseCollection((int) $resource_type_id, (int) $resource_id, (int) $item_id), - 'simple-item' => $this->simpleItemCollection((int) $resource_type_id, (int) $resource_id, (int) $item_id), + 'simple-item' => \App\Response\Responses::notSupported(), default => throw new \OutOfRangeException('No item type definition for ' . $item_type, 500), }; } @@ -167,11 +165,6 @@ static function ($category) { return response()->json($cache_collection->collection(), 200, $cache_collection->headers()); } - private function simpleItemCollection(int $resource_type_id, int $resource_id, int $item_id): JsonResponse - { - return \App\Response\Responses::notSupported(); - } - public function show( string $resource_type_id, string $resource_id, @@ -187,6 +180,22 @@ public function show( return \App\Response\Responses::notFound(trans('entities.item-category')); } + $item_type = Entity::itemType((int) $resource_type_id); + + return match ($item_type) { + 'allocated-expense', 'game', 'simple-expense' => $this->itemCategory((int) $resource_type_id, (int) $resource_id, (int) $item_id, (int) $item_category_id), + 'simple-item' => Responses::notSupported(), + default => throw new \OutOfRangeException('No item type definition for ' . $item_type, 500), + }; + } + + private function itemCategory( + int $resource_type_id, + int $resource_id, + int $item_id, + int $item_category_id = null + ): JsonResponse + { $item_category = (new ItemCategory())->single( $resource_type_id, $resource_id, @@ -220,7 +229,7 @@ public function optionsIndex(string $resource_type_id, string $resource_id, stri 'allocated-expense' => $this->optionsAllocatedExpenseCollection((int) $resource_type_id), 'game' => $this->optionsGameCollection((int) $resource_type_id), 'simple-expense' => $this->optionsSimpleExpenseCollection((int) $resource_type_id), - 'simple-item' => $this->optionsSimpleItemCollection((int) $resource_type_id), + 'simple-item' => Responses::notSupported(), default => throw new \OutOfRangeException('No item type definition for ' . $item_type, 500), }; } @@ -270,11 +279,6 @@ private function optionsSimpleExpenseCollection(int $resource_type_id): JsonResp ->response(); } - private function optionsSimpleItemCollection(int $resource_type_id): JsonResponse - { - return Responses::notSupported(); - } - public function optionsShow( string $resource_type_id, string $resource_id, @@ -369,14 +373,4 @@ private function optionsSimpleExpenseShow( return $response->create()->response(); } - - private function optionsSimpleItemShow( - int $resource_type_id, - int $resource_id, - int $item_id, - int $item_category_id - ): JsonResponse - { - return Responses::notSupported(); - } } From 986a5f2b3e608585ddd4018a8cae94a084a07547 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Fri, 21 Jan 2022 14:07:01 +0000 Subject: [PATCH 45/73] DRY - Remove a little duplication --- app/Http/Controllers/ItemCategoryView.php | 90 +---------------------- 1 file changed, 2 insertions(+), 88 deletions(-) diff --git a/app/Http/Controllers/ItemCategoryView.php b/app/Http/Controllers/ItemCategoryView.php index 8ebe007c..46a5bd78 100644 --- a/app/Http/Controllers/ItemCategoryView.php +++ b/app/Http/Controllers/ItemCategoryView.php @@ -31,15 +31,13 @@ public function index(string $resource_type_id, string $resource_id, string $ite $item_type = Entity::itemType((int) $resource_type_id); return match ($item_type) { - 'allocated-expense' => $this->allocatedExpenseCollection((int) $resource_type_id, (int) $resource_id, (int) $item_id), - 'game' => $this->gameCollection((int) $resource_type_id, (int) $resource_id, (int) $item_id), - 'simple-expense' => $this->simpleExpenseCollection((int) $resource_type_id, (int) $resource_id, (int) $item_id), + 'allocated-expense', 'game', 'simple-expense' => $this->itemCategoryCollection((int) $resource_type_id, (int) $resource_id, (int) $item_id), 'simple-item' => \App\Response\Responses::notSupported(), default => throw new \OutOfRangeException('No item type definition for ' . $item_type, 500), }; } - private function allocatedExpenseCollection(int $resource_type_id, int $resource_id, int $item_id): JsonResponse + private function itemCategoryCollection(int $resource_type_id, int $resource_id, int $item_id): JsonResponse { $cache_control = new \App\Cache\Control( $this->writeAccessToResourceType((int) $resource_type_id), @@ -81,90 +79,6 @@ static function ($category) { return response()->json($cache_collection->collection(), 200, $cache_collection->headers()); } - private function gameCollection(int $resource_type_id, int $resource_id, int $item_id): JsonResponse - { - $cache_control = new \App\Cache\Control( - $this->writeAccessToResourceType((int) $resource_type_id), - $this->user_id - ); - $cache_control->setTtlOneWeek(); - - $cache_collection = new \App\Cache\Collection(); - $cache_collection->setFromCache($cache_control->getByKey(request()->getRequestUri())); - - if ($cache_control->isRequestCacheable() === false || $cache_collection->valid() === false) { - - $item_category = (new ItemCategory())->paginatedCollection( - $resource_type_id, - $resource_id, - $item_id - ); - - if ((count($item_category) === 0)) { - $collection = []; - } else { - $collection = array_map( - static function ($category) { - return (new ItemCategoryTransformer($category))->asArray(); - }, - $item_category - ); - } - - $headers = new Header(); - $headers->add('X-Total-Count', count($collection)); - $headers->add('X-Count', count($collection)); - $headers->addCacheControl($cache_control->visibility(), $cache_control->ttl()); - - $cache_collection->create(count($collection), $collection, [], $headers->headers()); - $cache_control->putByKey(request()->getRequestUri(), $cache_collection->content()); - } - - return response()->json($cache_collection->collection(), 200, $cache_collection->headers()); - } - - private function simpleExpenseCollection(int $resource_type_id, int $resource_id, int $item_id): JsonResponse - { - $cache_control = new \App\Cache\Control( - $this->writeAccessToResourceType($resource_type_id), - $this->user_id - ); - $cache_control->setTtlOneWeek(); - - $cache_collection = new \App\Cache\Collection(); - $cache_collection->setFromCache($cache_control->getByKey(request()->getRequestUri())); - - if ($cache_control->isRequestCacheable() === false || $cache_collection->valid() === false) { - - $item_category = (new ItemCategory())->paginatedCollection( - $resource_type_id, - $resource_id, - $item_id - ); - - if ((count($item_category) === 0)) { - $collection = []; - } else { - $collection = array_map( - static function ($category) { - return (new ItemCategoryTransformer($category))->asArray(); - }, - $item_category - ); - } - - $headers = new Header(); - $headers->add('X-Total-Count', count($collection)); - $headers->add('X-Count', count($collection)); - $headers->addCacheControl($cache_control->visibility(), $cache_control->ttl()); - - $cache_collection->create(count($collection), $collection, [], $headers->headers()); - $cache_control->putByKey(request()->getRequestUri(), $cache_collection->content()); - } - - return response()->json($cache_collection->collection(), 200, $cache_collection->headers()); - } - public function show( string $resource_type_id, string $resource_id, From c995388ab3df961de686ae7a698d1df19dc21b13 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Fri, 21 Jan 2022 14:58:22 +0000 Subject: [PATCH 46/73] Refactoring - Upgraded item subcategory view controller to not use the entity class and be closer to other item controllers. --- app/Http/Controllers/ItemCategoryView.php | 2 +- .../AllocatedExpenseCollection.php | 29 +++++++++++++++++++ .../SimpleExpenseCollection.php | 29 +++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 app/Option/ItemSubcategory/AllocatedExpenseCollection.php create mode 100644 app/Option/ItemSubcategory/SimpleExpenseCollection.php diff --git a/app/Http/Controllers/ItemCategoryView.php b/app/Http/Controllers/ItemCategoryView.php index 46a5bd78..7b2a2024 100644 --- a/app/Http/Controllers/ItemCategoryView.php +++ b/app/Http/Controllers/ItemCategoryView.php @@ -214,7 +214,7 @@ public function optionsShow( 'allocated-expense' => $this->optionsAllocatedExpenseShow((int) $resource_type_id, (int) $resource_id, (int) $item_id, (int) $item_category_id), 'game' => $this->optionsGameShow((int) $resource_type_id, (int) $resource_id, (int) $item_id, (int) $item_category_id), 'simple-expense' => $this->optionsSimpleExpenseShow((int) $resource_type_id, (int) $resource_id, (int) $item_id, (int) $item_category_id), - 'simple-item' => $this->optionsSimpleItemShow((int) $resource_type_id, (int) $resource_id, (int) $item_id, (int) $item_category_id), + 'simple-item' => \App\Response\Responses::notSupported(), default => throw new \OutOfRangeException('No item type definition for ' . $item_type, 500), }; } diff --git a/app/Option/ItemSubcategory/AllocatedExpenseCollection.php b/app/Option/ItemSubcategory/AllocatedExpenseCollection.php new file mode 100644 index 00000000..6bcde312 --- /dev/null +++ b/app/Option/ItemSubcategory/AllocatedExpenseCollection.php @@ -0,0 +1,29 @@ +verbs['GET'] = $get->setParameters(Config::get('api.item-subcategory.parameters.collection'))-> + setAuthenticationStatus($this->permissions['view'])-> + setDescription('route-descriptions.item_sub_category_GET_index')-> + option(); + + $post = new \App\Method\PostRequest(); + $this->verbs['POST'] = $post->setFields(Config::get('api.item-subcategory.fields'))-> + setDynamicFields($this->allowed_fields)-> + setDescription('route-descriptions.item_sub_category_POST_allocated-expense')-> + setAuthenticationStatus($this->permissions['manage'])-> + setAuthenticationRequirement(true)-> + option(); + + return $this; + } +} diff --git a/app/Option/ItemSubcategory/SimpleExpenseCollection.php b/app/Option/ItemSubcategory/SimpleExpenseCollection.php new file mode 100644 index 00000000..ea256d97 --- /dev/null +++ b/app/Option/ItemSubcategory/SimpleExpenseCollection.php @@ -0,0 +1,29 @@ +verbs['GET'] = $get->setParameters(Config::get('api.item-subcategory.parameters.collection'))-> + setAuthenticationStatus($this->permissions['view'])-> + setDescription('route-descriptions.item_sub_category_GET_index')-> + option(); + + $post = new \App\Method\PostRequest(); + $this->verbs['POST'] = $post->setFields(Config::get('api.item-subcategory.fields'))-> + setDynamicFields($this->allowed_fields)-> + setDescription('route-descriptions.item_sub_category_POST_simple-expense')-> + setAuthenticationStatus($this->permissions['manage'])-> + setAuthenticationRequirement(true)-> + option(); + + return $this; + } +} From 726f283b0c09ca5c99817f28cfd6d09bc431676d Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Fri, 21 Jan 2022 14:58:57 +0000 Subject: [PATCH 47/73] Refactoring - Missed including in preview commit --- app/Http/Controllers/ItemSubcategoryView.php | 117 +++++++++++++++---- 1 file changed, 96 insertions(+), 21 deletions(-) diff --git a/app/Http/Controllers/ItemSubcategoryView.php b/app/Http/Controllers/ItemSubcategoryView.php index 385f233d..2e4820d7 100644 --- a/app/Http/Controllers/ItemSubcategoryView.php +++ b/app/Http/Controllers/ItemSubcategoryView.php @@ -5,31 +5,20 @@ use App\ItemType\Entity; use App\Models\ItemCategory; use App\Models\ItemSubcategory; -use App\Option\ItemSubcategoryCollection; +use App\Option\ItemSubcategory\AllocatedExpenseCollection; +use App\Option\ItemSubcategory\SimpleExpenseCollection; use App\Option\ItemSubcategoryItem; use App\Response\Header; use App\Transformers\ItemSubcategory as ItemSubcategoryTransformer; use Illuminate\Http\JsonResponse; /** - * Manage the category for an item row - * * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ItemSubcategoryView extends Controller { - /** - * Return the sub category assigned to an item - * - * @param string $resource_type_id - * @param string $resource_id - * @param string $item_id - * @param string $item_category_id - * - * @return JsonResponse - */ public function index( string $resource_type_id, string $resource_id, @@ -41,6 +30,22 @@ public function index( \App\Response\Responses::notFoundOrNotAccessible(trans('entities.item-category')); } + $item_type = Entity::itemType((int) $resource_type_id); + + return match ($item_type) { + 'allocated-expense', 'simple-expense' => $this->itemSubcategoryCollection((int) $resource_type_id, (int) $resource_id, (int) $item_id, (int) $item_category_id), + 'game', 'simple-item' => \App\Response\Responses::notSupported(), + default => throw new \OutOfRangeException('No item type definition for ' . $item_type, 500), + }; + } + + private function itemSubcategoryCollection( + int $resource_type_id, + int $resource_id, + int $item_id, + int $item_category_id + ): JsonResponse + { $cache_control = new \App\Cache\Control( $this->writeAccessToResourceType((int) $resource_type_id), $this->user_id @@ -59,7 +64,7 @@ public function index( $item_category_id ); - if ($item_sub_category === null || (is_array($item_sub_category) && count($item_sub_category) === 0)) { + if (count($item_sub_category) === 0) { $collection = []; } else { $collection = array_map( @@ -98,6 +103,23 @@ public function show( return \App\Response\Responses::notFound(trans('entities.item-subcategory')); } + $item_type = Entity::itemType((int) $resource_type_id); + + return match ($item_type) { + 'allocated-expense', 'simple-expense' => $this->itemSubcategory((int) $resource_type_id, (int) $resource_id, (int) $item_id, (int) $item_category_id, (int) $item_subcategory_id), + 'game', 'simple-item' => \App\Response\Responses::notSupported(), + default => throw new \OutOfRangeException('No item type definition for ' . $item_type, 500), + }; + } + + private function itemSubcategory( + int $resource_type_id, + int $resource_id, + int $item_id, + int $item_category_id, + int $item_subcategory_id + ): JsonResponse + { $item_sub_category = (new ItemSubcategory())->single( $resource_type_id, $resource_id, @@ -135,18 +157,54 @@ public function optionsIndex( return \App\Response\Responses::notFound(trans('entities.item-subcategory')); } + $item_type = Entity::itemType((int) $resource_type_id); + + return match ($item_type) { + 'allocated-expense' => $this->optionsAllocatedExpenseCollection((int) $resource_type_id, (int) $item_category_id), + 'simple-expense' => $this->optionsSimpleExpenseCollection((int) $resource_type_id, (int) $item_category_id), + 'game', 'simple-item' => \App\Response\Responses::notSupported(), + default => throw new \OutOfRangeException('No item type definition for ' . $item_type, 500), + }; + } + + private function optionsAllocatedExpenseCollection( + int $resource_type_id, + int $item_category_id + ): JsonResponse + { + if ($this->viewAccessToResourceType((int) $resource_type_id) === false) { + \App\Response\Responses::notFoundOrNotAccessible(trans('entities.item-category')); + } + + $item_category = (new ItemCategory())->find($item_category_id); + if ($item_category === null) { + return \App\Response\Responses::notFound(trans('entities.item-category')); + } + + $response = new AllocatedExpenseCollection($this->permissions((int) $resource_type_id)); + + return $response->setDynamicAllowedFields((new \App\AllowedValue\Subcategory())->allowedValues($item_category->category_id)) + ->create() + ->response(); + } + + private function optionsSimpleExpenseCollection( + int $resource_type_id, + int $item_category_id + ): JsonResponse + { + if ($this->viewAccessToResourceType((int) $resource_type_id) === false) { + \App\Response\Responses::notFoundOrNotAccessible(trans('entities.item-category')); + } + $item_category = (new ItemCategory())->find($item_category_id); if ($item_category === null) { return \App\Response\Responses::notFound(trans('entities.item-category')); } - $response = new ItemSubcategoryCollection($this->permissions((int) $resource_type_id)); + $response = new SimpleExpenseCollection($this->permissions((int) $resource_type_id)); - return $response - ->setEntity(Entity::item($resource_type_id)) - ->setDynamicAllowedFields( - (new \App\AllowedValue\Subcategory())->allowedValues($item_category->category_id) - ) + return $response->setDynamicAllowedFields((new \App\AllowedValue\Subcategory())->allowedValues($item_category->category_id)) ->create() ->response(); } @@ -167,6 +225,23 @@ public function optionsShow( return \App\Response\Responses::notFound(trans('entities.item-subcategory')); } + $item_type = Entity::itemType((int) $resource_type_id); + + return match ($item_type) { + 'allocated-expense', 'simple-expense' => $this->optionsItemSubcategoryShow((int) $resource_type_id, (int) $resource_id, (int) $item_id, (int) $item_category_id, (int) $item_subcategory_id), + 'game', 'simple-item' => \App\Response\Responses::notSupported(), + default => throw new \OutOfRangeException('No item type definition for ' . $item_type, 500), + }; + } + + public function optionsItemSubcategoryShow( + int $resource_type_id, + int $resource_id, + int $item_id, + int $item_category_id, + int $item_subcategory_id + ): JsonResponse + { $item_sub_category = (new ItemSubcategory())->single( $resource_type_id, $resource_id, @@ -179,7 +254,7 @@ public function optionsShow( return \App\Response\Responses::notFound(trans('entities.item-subcategory')); } - $response = new ItemSubcategoryItem($this->permissions((int) $resource_type_id)); + $response = new ItemSubcategoryItem($this->permissions($resource_type_id)); return $response->create()->response(); } From bfea8e43d65b78767818ac892ca390a6632a2a9e Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Mon, 24 Jan 2022 11:50:49 +0000 Subject: [PATCH 48/73] Refactoring - Updated the create item category code, method per item type, don't use entity class --- app/Http/Controllers/ItemCategoryManage.php | 68 ++++++++++++--------- 1 file changed, 40 insertions(+), 28 deletions(-) diff --git a/app/Http/Controllers/ItemCategoryManage.php b/app/Http/Controllers/ItemCategoryManage.php index cad85cdd..55476ceb 100644 --- a/app/Http/Controllers/ItemCategoryManage.php +++ b/app/Http/Controllers/ItemCategoryManage.php @@ -5,30 +5,21 @@ use App\ItemType\Entity; use App\Jobs\ClearCache; use App\Models\ItemCategory; -use App\Request\Validate\ItemCategory as ItemCategoryValidator; +use App\Response\Responses; use App\Transformers\ItemCategory as ItemCategoryTransformer; use Exception; use Illuminate\Database\QueryException; use Illuminate\Http\JsonResponse; +use Illuminate\Support\Facades\Config; +use Illuminate\Support\Facades\Validator as ValidatorFacade; /** - * Manage the category for an item row - * * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ItemCategoryManage extends Controller { - /** - * Assign the category - * - * @param string $resource_type_id - * @param string $resource_id - * @param string $item_id - * - * @return JsonResponse - */ public function create( string $resource_type_id, string $resource_id, @@ -36,21 +27,52 @@ public function create( ): JsonResponse { if ($this->writeAccessToResourceType((int) $resource_type_id) === false) { - \App\Response\Responses::notFoundOrNotAccessible(trans('entities.item')); + Responses::notFoundOrNotAccessible(trans('entities.resource')); } - $entity = Entity::item($resource_type_id); + $item_type = Entity::itemType((int) $resource_type_id); + + return match ($item_type) { + 'allocated-expense', 'simple-expense' => $this->createItemCategory((int) $resource_type_id, (int) $resource_id, (int) $item_id, 1), + 'game' => $this->createItemCategory((int) $resource_type_id, (int) $resource_id, (int) $item_id, 5), + 'simple-item' => \App\Response\Responses::categoryAssignmentLimit(0), + default => throw new \OutOfRangeException('No item type definition for ' . $item_type, 500), + }; + } + + private function createItemCategory( + int $resource_type_id, + int $resource_id, + int $item_id, + int $assignment_limit = 1 + ): JsonResponse + { $assigned = (new ItemCategory())->numberAssigned( $resource_type_id, $resource_id, $item_id ); - if ($assigned >= $entity->categoryAssignmentLimit()) { - return \App\Response\Responses::categoryAssignmentLimit($entity->categoryAssignmentLimit()); + if ($assigned >= $assignment_limit) { + return \App\Response\Responses::categoryAssignmentLimit($assignment_limit); } - $validator = (new ItemCategoryValidator)->create(); + $decode = $this->hash->category()->decode(request()->input('category_id')); + $category_id = null; + if (count($decode) === 1) { + $category_id = $decode[0]; + } + + $messages = []; + foreach (Config::get('api.item-category.validation.POST.messages') as $key => $custom_message) { + $messages[$key] = trans($custom_message); + } + + $validator = ValidatorFacade::make( + ['category_id' => $category_id], + Config::get('api.item-category.validation.POST.fields'), + $messages + ); if ($validator->fails()) { return \App\Request\BodyValidation::returnValidationErrors( @@ -65,7 +87,7 @@ public function create( 'resource_type_id' => $resource_type_id, 'resource_id' => $resource_id ]) - ->setPermittedUser($this->writeAccessToResourceType((int) $resource_type_id)) + ->setPermittedUser($this->writeAccessToResourceType($resource_type_id)) ->setUserId($this->user_id); try { @@ -93,16 +115,6 @@ public function create( ); } - /** - * Delete the assigned category - * - * @param string $resource_type_id, - * @param string $resource_id, - * @param string $item_id, - * @param string $item_category_id - * - * @return JsonResponse - */ public function delete( string $resource_type_id, string $resource_id, From da53bcb224692c66f9ee07fd890dbb2761786d31 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Mon, 24 Jan 2022 12:29:00 +0000 Subject: [PATCH 49/73] Refactoring - Updated item category delete. --- app/Http/Controllers/ItemCategoryManage.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/ItemCategoryManage.php b/app/Http/Controllers/ItemCategoryManage.php index 55476ceb..92360447 100644 --- a/app/Http/Controllers/ItemCategoryManage.php +++ b/app/Http/Controllers/ItemCategoryManage.php @@ -123,9 +123,25 @@ public function delete( ): JsonResponse { if ($this->writeAccessToResourceType((int) $resource_type_id) === false) { - \App\Response\Responses::notFoundOrNotAccessible(trans('entities.item-category')); + Responses::notFoundOrNotAccessible(trans('entities.resource')); } + $item_type = Entity::itemType((int) $resource_type_id); + + return match ($item_type) { + 'allocated-expense', 'simple-expense', 'game' => $this->deleteItemCategory((int) $resource_type_id, (int) $resource_id, (int) $item_id, (int) $item_category_id), + 'simple-item' => \App\Response\Responses::notSupported(), + default => throw new \OutOfRangeException('No item type definition for ' . $item_type, 500), + }; + } + + private function deleteItemCategory( + int $resource_type_id, + int $resource_id, + int $item_id, + int $item_category_id + ): JsonResponse + { $item_category = (new ItemCategory())->instance( $resource_type_id, $resource_id, @@ -143,7 +159,7 @@ public function delete( 'resource_type_id' => $resource_type_id, 'resource_id' => $resource_id ]) - ->setPermittedUser($this->writeAccessToResourceType((int) $resource_type_id)) + ->setPermittedUser($this->writeAccessToResourceType($resource_type_id)) ->setUserId($this->user_id); try { From 1848a05bb41e7fd77895e5e667e1dc198ac7cd18 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Mon, 24 Jan 2022 13:11:13 +0000 Subject: [PATCH 50/73] Refactoring - Rework item subcategory controller - Remove the validation classes we aren't using anymore. --- .../Controllers/ItemSubcategoryManage.php | 89 +++++++++++++------ app/Request/Validate/ItemCategory.php | 45 ---------- app/Request/Validate/ItemSubcategory.php | 64 ------------- 3 files changed, 61 insertions(+), 137 deletions(-) delete mode 100644 app/Request/Validate/ItemCategory.php delete mode 100644 app/Request/Validate/ItemSubcategory.php diff --git a/app/Http/Controllers/ItemSubcategoryManage.php b/app/Http/Controllers/ItemSubcategoryManage.php index 773cfee5..7916ade1 100644 --- a/app/Http/Controllers/ItemSubcategoryManage.php +++ b/app/Http/Controllers/ItemSubcategoryManage.php @@ -6,31 +6,20 @@ use App\Jobs\ClearCache; use App\Models\ItemCategory; use App\Models\ItemSubcategory; -use App\Request\Validate\ItemSubcategory as ItemSubcategoryValidator; use App\Transformers\ItemSubcategory as ItemSubcategoryTransformer; use Exception; use Illuminate\Database\QueryException; use Illuminate\Http\JsonResponse; +use Illuminate\Support\Facades\Config; +use Illuminate\Support\Facades\Validator as ValidatorFacade; /** - * Manage the category for an item row - * * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ItemSubcategoryManage extends Controller { - /** - * Assign the sub category - * - * @param string $resource_type_id - * @param string $resource_id - * @param string $item_id - * @param string $item_category_id - * - * @return JsonResponse - */ public function create( string $resource_type_id, string $resource_id, @@ -46,7 +35,23 @@ public function create( return \App\Response\Responses::notFound(trans('entities.item-subcategory')); } - $entity = Entity::item($resource_type_id); + $item_type = Entity::itemType((int) $resource_type_id); + + return match ($item_type) { + 'allocated-expense', 'simple-expense' => $this->createItemSubcategory((int) $resource_type_id, (int) $resource_id, (int) $item_id, (int) $item_category_id, 1), + 'game', 'simple-item' => \App\Response\Responses::subcategoryAssignmentLimit(0), + default => throw new \OutOfRangeException('No item type definition for ' . $item_type, 500), + }; + } + + private function createItemSubcategory( + int $resource_type_id, + int $resource_id, + int $item_id, + int $item_category_id, + int $assignment_limit = 1 + ): JsonResponse + { $assigned = (new ItemSubcategory())->numberAssigned( $resource_type_id, $resource_id, @@ -54,15 +59,37 @@ public function create( $item_category_id ); - if ($assigned >= $entity->subcategoryAssignmentLimit()) { - return \App\Response\Responses::subcategoryAssignmentLimit($entity->subcategoryAssignmentLimit()); + if ($assigned >= $assignment_limit) { + return \App\Response\Responses::subcategoryAssignmentLimit($assignment_limit); } $item_category = (new ItemCategory()) ->where('item_id', '=', $item_id) ->find($item_category_id); - $validator = (new ItemSubcategoryValidator)->create(['category_id' => $item_category->category_id]); + $decode = $this->hash->subcategory()->decode(request()->input('subcategory_id')); + $subcategory_id = null; + if (count($decode) === 1) { + $subcategory_id = $decode[0]; + } + + $messages = []; + foreach (Config::get('api.item-subcategory.validation.POST.messages') as $key => $custom_message) { + $messages[$key] = trans($custom_message); + } + + $validator = ValidatorFacade::make( + ['subcategory_id' => $subcategory_id], + array_merge( + [ + 'subcategory_id' => [ + 'required' + ], + ], + Config::get('api.item-subcategory.validation.POST.fields') + ), + $messages + ); if ($validator->fails()) { return \App\Request\BodyValidation::returnValidationErrors( @@ -105,17 +132,6 @@ public function create( ); } - /** - * Delete the assigned sub category - * - * @param string $resource_type_id, - * @param string $resource_id, - * @param string $item_id, - * @param string $item_category_id, - * @param string $item_subcategory_id - * - * @return JsonResponse - */ public function delete( string $resource_type_id, string $resource_id, @@ -132,6 +148,23 @@ public function delete( return \App\Response\Responses::notFound(trans('entities.item-subcategory')); } + $item_type = Entity::itemType((int) $resource_type_id); + + return match ($item_type) { + 'allocated-expense', 'simple-expense' => $this->deleteItemSubcategory((int) $resource_type_id, (int) $resource_id, (int) $item_id, (int) $item_category_id, (int) $item_subcategory_id), + 'game', 'simple-item' => \App\Response\Responses::notSupported(), + default => throw new \OutOfRangeException('No item type definition for ' . $item_type, 500), + }; + } + + private function deleteItemSubcategory( + int $resource_type_id, + int $resource_id, + int $item_id, + int $item_category_id, + int $item_subcategory_id + ): JsonResponse + { $item_sub_category = (new ItemSubcategory())->instance( $resource_type_id, $resource_id, diff --git a/app/Request/Validate/ItemCategory.php b/app/Request/Validate/ItemCategory.php deleted file mode 100644 index e782546c..00000000 --- a/app/Request/Validate/ItemCategory.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @copyright Dean Blackborough 2018-2022 - * @license https://github.com/costs-to-expect/api/blob/master/LICENSE - */ -class ItemCategory extends BaseValidator -{ - /** - * Create the validation rules for the create (POST) request - * - * @param array $options - * - * @return \Illuminate\Contracts\Validation\Validator - */ - public function create(array $options = []): \Illuminate\Contracts\Validation\Validator - { - $decode = $this->hash->category()->decode(request()->input('category_id')); - $category_id = null; - if (count($decode) === 1) { - $category_id = $decode[0]; - } - - return ValidatorFacade::make( - ['category_id' => $category_id], - Config::get('api.item-category.validation.POST.fields'), - $this->translateMessages('api.item-category.validation.POST.messages') - ); - } - - public function update(array $options = []): ?\Illuminate\Contracts\Validation\Validator - { - return null; - } -} diff --git a/app/Request/Validate/ItemSubcategory.php b/app/Request/Validate/ItemSubcategory.php deleted file mode 100644 index 6a41f547..00000000 --- a/app/Request/Validate/ItemSubcategory.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @copyright Dean Blackborough 2018-2022 - * @license https://github.com/costs-to-expect/api/blob/master/LICENSE - */ -class ItemSubcategory extends BaseValidator -{ - /** - * Create the validation rules for the create (POST) request - * - * @return array - */ - private function createRules(): array - { - return array_merge( - [ - 'subcategory_id' => [ - 'required' - ], - ], - Config::get('api.item-subcategory.validation.POST.fields') - ); - } - - /** - * Return a valid validator object for a create (POST) request - * - * @param array $options - * - * @return \Illuminate\Contracts\Validation\Validator - */ - public function create(array $options = []): \Illuminate\Contracts\Validation\Validator - { - $this->requiredIndexes(['category_id'], $options); - - $decode = $this->hash->subcategory()->decode(request()->input('subcategory_id')); - $subcategory_id = null; - if (count($decode) === 1) { - $subcategory_id = $decode[0]; - } - - return ValidatorFacade::make( - ['subcategory_id' => $subcategory_id], - $this->createRules(), - $this->translateMessages('api.item-subcategory.validation.POST.messages') - ); - } - - public function update(array $options = []): ?\Illuminate\Contracts\Validation\Validator - { - return null; - } -} From ed55a62232d7f875c89074d980826de83e40ed0e Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Mon, 24 Jan 2022 14:28:36 +0000 Subject: [PATCH 51/73] Refactoring summaries - Updated the item summary controller, method per item type, will review later down the road as we add/change item types. --- app/Http/Controllers/Summary/ItemView.php | 58 ++++++++++++++++++++--- 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/Summary/ItemView.php b/app/Http/Controllers/Summary/ItemView.php index bee96101..315aa862 100644 --- a/app/Http/Controllers/Summary/ItemView.php +++ b/app/Http/Controllers/Summary/ItemView.php @@ -16,17 +16,63 @@ public function index(string $resource_type_id, string $resource_id): JsonRespon Responses::notFoundOrNotAccessible(trans('entities.resource')); } - $entity = Entity::item((int) $resource_type_id); + $item_type = Entity::itemType((int) $resource_type_id); - $summary_class = $entity->apiSummaryResponseClass(); - $summary = new $summary_class( - (int) $resource_type_id, - (int) $resource_id, + return match ($item_type) { + 'allocated-expense' => $this->allocatedExpenseSummary((int) $resource_type_id, (int) $resource_id), + 'simple-expense' => $this->simpleExpenseSummary((int) $resource_type_id, (int) $resource_id), + 'simple-item' => $this->simpleItemSummary((int) $resource_type_id, (int) $resource_id), + 'game' => $this->gameSummary((int) $resource_type_id, (int) $resource_id), + default => throw new \OutOfRangeException('No item type definition for ' . $item_type, 500), + }; + } + + private function allocatedExpenseSummary(int $resource_type_id, int $resource_id): JsonResponse + { + $response = new \App\ItemType\AllocatedExpense\ApiResponse\Summary( + $resource_type_id, + $resource_id, + $this->writeAccessToResourceType($resource_type_id), + $this->user_id + ); + + return $response->response(); + } + + private function gameSummary(int $resource_type_id, int $resource_id): JsonResponse + { + $response = new \App\ItemType\Game\ApiResponse\Summary( + $resource_type_id, + $resource_id, + $this->writeAccessToResourceType($resource_type_id), + $this->user_id + ); + + return $response->response(); + } + + private function simpleExpenseSummary(int $resource_type_id, int $resource_id): JsonResponse + { + $response = new \App\ItemType\SimpleExpense\ApiResponse\Summary( + $resource_type_id, + $resource_id, + $this->writeAccessToResourceType($resource_type_id), + $this->user_id + ); + + return $response->response(); + } + + private function simpleItemSummary(int $resource_type_id, int $resource_id): JsonResponse + { + $response = new \App\ItemType\SimpleItem\ApiResponse\Summary( + $resource_type_id, + $resource_id, $this->writeAccessToResourceType($resource_type_id), $this->user_id ); - return $summary->response(); + return $response->response(); } public function optionsIndex(string $resource_type_id, string $resource_id): JsonResponse From be4f527f3e7848f327811592df45fc391fc99da9 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Mon, 24 Jan 2022 14:52:24 +0000 Subject: [PATCH 52/73] Refactoring summary - Rework the summary, opt for method per item type, will be helpful later. --- app/Http/Controllers/ItemView.php | 8 -- app/Http/Controllers/Summary/ItemView.php | 78 ++++++++++++++++++-- app/Option/Item/Summary/AllocatedExpense.php | 27 +++++++ app/Option/Item/Summary/Game.php | 27 +++++++ app/Option/Item/Summary/SimpleExpense.php | 27 +++++++ app/Option/Item/Summary/SimpleItem.php | 27 +++++++ 6 files changed, 178 insertions(+), 16 deletions(-) create mode 100644 app/Option/Item/Summary/AllocatedExpense.php create mode 100644 app/Option/Item/Summary/Game.php create mode 100644 app/Option/Item/Summary/SimpleExpense.php create mode 100644 app/Option/Item/Summary/SimpleItem.php diff --git a/app/Http/Controllers/ItemView.php b/app/Http/Controllers/ItemView.php index 3e5030ac..fa275947 100644 --- a/app/Http/Controllers/ItemView.php +++ b/app/Http/Controllers/ItemView.php @@ -150,14 +150,6 @@ private function simpleItem(int $resource_type_id, int $resource_id, int $item_i return $response->showResponse($item_id); } - /** - * Generate the OPTIONS request for the item list - * - * @param string $resource_type_id - * @param string $resource_id - * - * @return JsonResponse - */ public function optionsIndex( string $resource_type_id, string $resource_id diff --git a/app/Http/Controllers/Summary/ItemView.php b/app/Http/Controllers/Summary/ItemView.php index 315aa862..f403e330 100644 --- a/app/Http/Controllers/Summary/ItemView.php +++ b/app/Http/Controllers/Summary/ItemView.php @@ -4,7 +4,10 @@ use App\Http\Controllers\Controller; use App\ItemType\Entity; -use App\Option\SummaryItemCollection; +use App\Option\Item\Summary\AllocatedExpense; +use App\Option\Item\Summary\Game; +use App\Option\Item\Summary\SimpleExpense; +use App\Option\Item\Summary\SimpleItem; use App\Response\Responses; use Illuminate\Http\JsonResponse; @@ -81,18 +84,77 @@ public function optionsIndex(string $resource_type_id, string $resource_id): Jso Responses::notFoundOrNotAccessible(trans('entities.resource')); } - $entity = Entity::item($resource_type_id); + $item_type = Entity::itemType((int) $resource_type_id); + + return match ($item_type) { + 'allocated-expense' => $this->optionsAllocatedExpense((int) $resource_type_id, (int) $resource_id), + 'simple-expense' => $this->optionsSimpleExpense((int) $resource_type_id, (int) $resource_id), + 'simple-item' => $this->optionsSimpleItem((int) $resource_type_id, (int) $resource_id), + 'game' => $this->optionsGame((int) $resource_type_id, (int) $resource_id), + default => throw new \OutOfRangeException('No item type definition for ' . $item_type, 500), + }; + } + + private function optionsAllocatedExpense(int $resource_type_id, int $resource_id): JsonResponse + { + $item = new \App\ItemType\AllocatedExpense\Item(); + $allowed_values = $item->allowedValuesForItemCollection( + $resource_type_id, + $resource_id, + $this->viewable_resource_types + ); + + $response = new AllocatedExpense($this->permissions($resource_type_id)); + + return $response->setDynamicAllowedParameters($allowed_values) + ->create() + ->response(); + } + + private function optionsGame(int $resource_type_id, int $resource_id): JsonResponse + { + $item = new \App\ItemType\Game\Item(); + $allowed_values = $item->allowedValuesForItemCollection( + $resource_type_id, + $resource_id, + $this->viewable_resource_types + ); + + $response = new Game($this->permissions($resource_type_id)); - $allowed_values = $entity->allowedValuesForItemCollection( - (int) $resource_type_id, - (int) $resource_id, + return $response->setDynamicAllowedParameters($allowed_values) + ->create() + ->response(); + } + + private function optionsSimpleExpense(int $resource_type_id, int $resource_id): JsonResponse + { + $item = new \App\ItemType\SimpleExpense\Item(); + $allowed_values = $item->allowedValuesForItemCollection( + $resource_type_id, + $resource_id, + $this->viewable_resource_types + ); + + $response = new SimpleExpense($this->permissions($resource_type_id)); + + return $response->setDynamicAllowedParameters($allowed_values) + ->create() + ->response(); + } + + private function optionsSimpleItem(int $resource_type_id, int $resource_id): JsonResponse + { + $item = new \App\ItemType\SimpleItem\Item(); + $allowed_values = $item->allowedValuesForItemCollection( + $resource_type_id, + $resource_id, $this->viewable_resource_types ); - $response = new SummaryItemCollection($this->permissions((int) $resource_type_id)); + $response = new SimpleItem($this->permissions($resource_type_id)); - return $response->setEntity($entity) - ->setDynamicAllowedParameters($allowed_values) + return $response->setDynamicAllowedParameters($allowed_values) ->create() ->response(); } diff --git a/app/Option/Item/Summary/AllocatedExpense.php b/app/Option/Item/Summary/AllocatedExpense.php new file mode 100644 index 00000000..d7560603 --- /dev/null +++ b/app/Option/Item/Summary/AllocatedExpense.php @@ -0,0 +1,27 @@ +verbs['GET'] = $get + ->setParameters(LaravelConfig::get($base_path . '.summary-parameters', [])) + ->setSearchableParameters(LaravelConfig::get($base_path . '.summary-searchable', [])) + ->setFilterableParameters(LaravelConfig::get($base_path . '.summary-filterable', [])) + ->setDynamicParameters($this->allowed_parameters) + ->setDescription('route-descriptions.summary_GET_resource-type_resource_items') + ->setAuthenticationStatus($this->permissions['view']) + ->option(); + + return $this; + } +} diff --git a/app/Option/Item/Summary/Game.php b/app/Option/Item/Summary/Game.php new file mode 100644 index 00000000..98744d92 --- /dev/null +++ b/app/Option/Item/Summary/Game.php @@ -0,0 +1,27 @@ +verbs['GET'] = $get + ->setParameters(LaravelConfig::get($base_path . '.summary-parameters', [])) + ->setSearchableParameters(LaravelConfig::get($base_path . '.summary-searchable', [])) + ->setFilterableParameters(LaravelConfig::get($base_path . '.summary-filterable', [])) + ->setDynamicParameters($this->allowed_parameters) + ->setDescription('route-descriptions.summary_GET_resource-type_resource_items') + ->setAuthenticationStatus($this->permissions['view']) + ->option(); + + return $this; + } +} diff --git a/app/Option/Item/Summary/SimpleExpense.php b/app/Option/Item/Summary/SimpleExpense.php new file mode 100644 index 00000000..13818335 --- /dev/null +++ b/app/Option/Item/Summary/SimpleExpense.php @@ -0,0 +1,27 @@ +verbs['GET'] = $get + ->setParameters(LaravelConfig::get($base_path . '.summary-parameters', [])) + ->setSearchableParameters(LaravelConfig::get($base_path . '.summary-searchable', [])) + ->setFilterableParameters(LaravelConfig::get($base_path . '.summary-filterable', [])) + ->setDynamicParameters($this->allowed_parameters) + ->setDescription('route-descriptions.summary_GET_resource-type_resource_items') + ->setAuthenticationStatus($this->permissions['view']) + ->option(); + + return $this; + } +} diff --git a/app/Option/Item/Summary/SimpleItem.php b/app/Option/Item/Summary/SimpleItem.php new file mode 100644 index 00000000..38875080 --- /dev/null +++ b/app/Option/Item/Summary/SimpleItem.php @@ -0,0 +1,27 @@ +verbs['GET'] = $get + ->setParameters(LaravelConfig::get($base_path . '.summary-parameters', [])) + ->setSearchableParameters(LaravelConfig::get($base_path . '.summary-searchable', [])) + ->setFilterableParameters(LaravelConfig::get($base_path . '.summary-filterable', [])) + ->setDynamicParameters($this->allowed_parameters) + ->setDescription('route-descriptions.summary_GET_resource-type_resource_items') + ->setAuthenticationStatus($this->permissions['view']) + ->option(); + + return $this; + } +} From 418449dd4367f4bde36f25a95bf8a539ecbdafe6 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Mon, 24 Jan 2022 22:53:25 +0000 Subject: [PATCH 53/73] Refactoring - Re work all the summaries --- .../Summary/ResourceTypeItemView.php | 130 ++++++++++++++++-- app/ItemType/ItemType.php | 3 +- .../Summary/AllocatedExpense.php | 26 ++++ app/Option/ResourceTypeItem/Summary/Game.php | 26 ++++ .../Summary/SimpleExpense.php | 26 ++++ .../ResourceTypeItem/Summary/SimpleItem.php | 26 ++++ app/Option/ResourceTypeItemCollection.php | 23 ---- app/Option/SummaryItemCollection.php | 22 --- .../SummaryResourceTypeItemCollection.php | 21 --- 9 files changed, 220 insertions(+), 83 deletions(-) create mode 100644 app/Option/ResourceTypeItem/Summary/AllocatedExpense.php create mode 100644 app/Option/ResourceTypeItem/Summary/Game.php create mode 100644 app/Option/ResourceTypeItem/Summary/SimpleExpense.php create mode 100644 app/Option/ResourceTypeItem/Summary/SimpleItem.php delete mode 100644 app/Option/ResourceTypeItemCollection.php delete mode 100644 app/Option/SummaryItemCollection.php delete mode 100644 app/Option/SummaryResourceTypeItemCollection.php diff --git a/app/Http/Controllers/Summary/ResourceTypeItemView.php b/app/Http/Controllers/Summary/ResourceTypeItemView.php index e455f21a..8fcb3a1b 100644 --- a/app/Http/Controllers/Summary/ResourceTypeItemView.php +++ b/app/Http/Controllers/Summary/ResourceTypeItemView.php @@ -4,13 +4,14 @@ use App\Http\Controllers\Controller; use App\ItemType\Entity; -use App\Option\SummaryResourceTypeItemCollection; +use App\Option\ResourceTypeItem\Summary\AllocatedExpense; +use App\Option\ResourceTypeItem\Summary\Game; +use App\Option\ResourceTypeItem\Summary\SimpleExpense; +use App\Option\ResourceTypeItem\Summary\SimpleItem; use App\Response\Responses; use Illuminate\Http\JsonResponse; /** - * Summary for resource type items route - * * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE @@ -23,35 +24,134 @@ public function index(string $resource_type_id): JsonResponse Responses::notFoundOrNotAccessible(trans('entities.resource')); } - $entity = Entity::item((int)$resource_type_id); + $item_type = Entity::itemType((int) $resource_type_id); - $summary_class = $entity->apiSummaryResourceTypeItemResponseClass(); - $summary = new $summary_class( - (int) $resource_type_id, + return match ($item_type) { + 'allocated-expense' => $this->allocatedExpenseSummary((int) $resource_type_id), + 'simple-expense' => $this->simpleExpenseSummary((int) $resource_type_id), + 'simple-item' => $this->simpleItemSummary((int) $resource_type_id), + 'game' => $this->gameSummary((int) $resource_type_id), + default => throw new \OutOfRangeException('No item type definition for ' . $item_type, 500), + }; + } + + private function allocatedExpenseSummary(int $resource_type_id): JsonResponse + { + $response = new \App\ItemType\AllocatedExpense\ApiResponse\SummaryResourceTypeItem( + $resource_type_id, + $this->writeAccessToResourceType($resource_type_id), + $this->user_id + ); + + return $response->response(); + } + + private function gameSummary(int $resource_type_id): JsonResponse + { + $response = new \App\ItemType\Game\ApiResponse\SummaryResourceTypeItem( + $resource_type_id, + $this->writeAccessToResourceType($resource_type_id), + $this->user_id + ); + + return $response->response(); + } + + private function simpleExpenseSummary(int $resource_type_id): JsonResponse + { + $response = new \App\ItemType\SimpleExpense\ApiResponse\SummaryResourceTypeItem( + $resource_type_id, + $this->writeAccessToResourceType($resource_type_id), + $this->user_id + ); + + return $response->response(); + } + + private function simpleItemSummary(int $resource_type_id): JsonResponse + { + $response = new \App\ItemType\SimpleItem\ApiResponse\SummaryResourceTypeItem( + $resource_type_id, $this->writeAccessToResourceType($resource_type_id), $this->user_id ); - return $summary->response(); + return $response->response(); } public function optionsIndex(string $resource_type_id): JsonResponse { if ($this->viewAccessToResourceType((int) $resource_type_id) === false) { - \App\Response\Responses::notFoundOrNotAccessible(trans('entities.resource-type')); + Responses::notFoundOrNotAccessible(trans('entities.resource')); } - $entity = Entity::item($resource_type_id); + $item_type = Entity::itemType((int) $resource_type_id); - $allowed_values = $entity->allowedValuesForResourceTypeItemCollection( - (int) $resource_type_id, + return match ($item_type) { + 'allocated-expense' => $this->optionsAllocatedExpense((int) $resource_type_id), + 'game' => $this->optionsGame((int) $resource_type_id), + 'simple-expense' => $this->optionsSimpleExpense((int) $resource_type_id), + 'simple-item' => $this->optionsSimpleItem((int) $resource_type_id), + default => throw new \OutOfRangeException('No item type definition for ' . $item_type, 500), + }; + } + + private function optionsAllocatedExpense(int $resource_type_id): JsonResponse + { + $item = new \App\ItemType\AllocatedExpense\Item(); + $allowed_values = $item->allowedValuesForResourceTypeItemCollection( + $resource_type_id, + $this->viewable_resource_types + ); + + $response = new AllocatedExpense($this->permissions($resource_type_id)); + + return $response->setDynamicAllowedParameters($allowed_values) + ->create() + ->response(); + } + + private function optionsGame(int $resource_type_id): JsonResponse + { + $item = new \App\ItemType\Game\Item(); + $allowed_values = $item->allowedValuesForResourceTypeItemCollection( + $resource_type_id, + $this->viewable_resource_types + ); + + $response = new Game($this->permissions($resource_type_id)); + + return $response->setDynamicAllowedParameters($allowed_values) + ->create() + ->response(); + } + + private function optionsSimpleExpense(int $resource_type_id): JsonResponse + { + $item = new \App\ItemType\SimpleExpense\Item(); + $allowed_values = $item->allowedValuesForResourceTypeItemCollection( + $resource_type_id, + $this->viewable_resource_types + ); + + $response = new SimpleExpense($this->permissions($resource_type_id)); + + return $response->setDynamicAllowedParameters($allowed_values) + ->create() + ->response(); + } + + private function optionsSimpleItem(int $resource_type_id): JsonResponse + { + $item = new \App\ItemType\SimpleItem\Item(); + $allowed_values = $item->allowedValuesForResourceTypeItemCollection( + $resource_type_id, $this->viewable_resource_types ); - $response = new SummaryResourceTypeItemCollection($this->permissions((int) $resource_type_id)); + $response = new SimpleItem($this->permissions($resource_type_id)); - return $response->setEntity($entity) - ->setDynamicAllowedParameters($allowed_values) + return $response->setDynamicAllowedParameters($allowed_values) ->create() ->response(); } diff --git a/app/ItemType/ItemType.php b/app/ItemType/ItemType.php index e9d79edb..b3e9b147 100644 --- a/app/ItemType/ItemType.php +++ b/app/ItemType/ItemType.php @@ -73,8 +73,7 @@ public function allowedValuesForResourceTypeItemCollection( $viewable_resource_types ); - return $allowed_values - ->setParameters( + return $allowed_values->setParameters( $available_parameters, $defined_parameters ) diff --git a/app/Option/ResourceTypeItem/Summary/AllocatedExpense.php b/app/Option/ResourceTypeItem/Summary/AllocatedExpense.php new file mode 100644 index 00000000..5f7898e0 --- /dev/null +++ b/app/Option/ResourceTypeItem/Summary/AllocatedExpense.php @@ -0,0 +1,26 @@ +verbs['GET'] = $get->setSearchableParameters(LaravelConfig::get($base_path . '.summary-searchable', [])) + ->setParameters(LaravelConfig::get($base_path . '.summary-parameters', [])) + ->setFilterableParameters(LaravelConfig::get($base_path . '.summary-filterable', [])) + ->setDynamicParameters($this->allowed_parameters) + ->setDescription('route-descriptions.summary-resource-type-item-GET-index') + ->setAuthenticationStatus($this->permissions['view']) + ->option(); + + return $this; + } +} diff --git a/app/Option/ResourceTypeItem/Summary/Game.php b/app/Option/ResourceTypeItem/Summary/Game.php new file mode 100644 index 00000000..dd6c94d7 --- /dev/null +++ b/app/Option/ResourceTypeItem/Summary/Game.php @@ -0,0 +1,26 @@ +verbs['GET'] = $get->setSearchableParameters(LaravelConfig::get($base_path . '.summary-searchable', [])) + ->setParameters(LaravelConfig::get($base_path . '.summary-parameters', [])) + ->setFilterableParameters(LaravelConfig::get($base_path . '.summary-filterable', [])) + ->setDynamicParameters($this->allowed_parameters) + ->setDescription('route-descriptions.summary-resource-type-item-GET-index') + ->setAuthenticationStatus($this->permissions['view']) + ->option(); + + return $this; + } +} diff --git a/app/Option/ResourceTypeItem/Summary/SimpleExpense.php b/app/Option/ResourceTypeItem/Summary/SimpleExpense.php new file mode 100644 index 00000000..a33ce8a4 --- /dev/null +++ b/app/Option/ResourceTypeItem/Summary/SimpleExpense.php @@ -0,0 +1,26 @@ +verbs['GET'] = $get->setSearchableParameters(LaravelConfig::get($base_path . '.summary-searchable', [])) + ->setParameters(LaravelConfig::get($base_path . '.summary-parameters', [])) + ->setFilterableParameters(LaravelConfig::get($base_path . '.summary-filterable', [])) + ->setDynamicParameters($this->allowed_parameters) + ->setDescription('route-descriptions.summary-resource-type-item-GET-index') + ->setAuthenticationStatus($this->permissions['view']) + ->option(); + + return $this; + } +} diff --git a/app/Option/ResourceTypeItem/Summary/SimpleItem.php b/app/Option/ResourceTypeItem/Summary/SimpleItem.php new file mode 100644 index 00000000..264ecb1a --- /dev/null +++ b/app/Option/ResourceTypeItem/Summary/SimpleItem.php @@ -0,0 +1,26 @@ +verbs['GET'] = $get->setSearchableParameters(LaravelConfig::get($base_path . '.summary-searchable', [])) + ->setParameters(LaravelConfig::get($base_path . '.summary-parameters', [])) + ->setFilterableParameters(LaravelConfig::get($base_path . '.summary-filterable', [])) + ->setDynamicParameters($this->allowed_parameters) + ->setDescription('route-descriptions.summary-resource-type-item-GET-index') + ->setAuthenticationStatus($this->permissions['view']) + ->option(); + + return $this; + } +} diff --git a/app/Option/ResourceTypeItemCollection.php b/app/Option/ResourceTypeItemCollection.php deleted file mode 100644 index dca1bc59..00000000 --- a/app/Option/ResourceTypeItemCollection.php +++ /dev/null @@ -1,23 +0,0 @@ -verbs['GET'] = $get->setSortableParameters($this->entity->resourceTypeSortParameters())-> - setSearchableParameters($this->entity->resourceTypeSearchParameters())-> - setFilterableParameters($this->entity->resourceTypeFilterParameters())-> - setPaginationStatus(true)-> - setParameters($this->entity->resourceTypeRequestParameters())-> - setDynamicParameters($this->allowed_parameters)-> - setDescription('route-descriptions.resource_type_item_GET_index')-> - setAuthenticationStatus($this->permissions['view'])-> - option(); - - return $this; - } -} diff --git a/app/Option/SummaryItemCollection.php b/app/Option/SummaryItemCollection.php deleted file mode 100644 index 13e0d130..00000000 --- a/app/Option/SummaryItemCollection.php +++ /dev/null @@ -1,22 +0,0 @@ -verbs['GET'] = $get - ->setParameters($this->entity->summaryRequestParameters()) - ->setSearchableParameters($this->entity->summarySearchParameters()) - ->setFilterableParameters($this->entity->summaryFilterParameters()) - ->setDynamicParameters($this->allowed_parameters) - ->setDescription('route-descriptions.summary_GET_resource-type_resource_items') - ->setAuthenticationStatus($this->permissions['view']) - ->option(); - - return $this; - } -} diff --git a/app/Option/SummaryResourceTypeItemCollection.php b/app/Option/SummaryResourceTypeItemCollection.php deleted file mode 100644 index 8d1b5d18..00000000 --- a/app/Option/SummaryResourceTypeItemCollection.php +++ /dev/null @@ -1,21 +0,0 @@ -verbs['GET'] = $get->setSearchableParameters($this->entity->summaryResourceTypeSearchParameters()) - ->setParameters($this->entity->summaryResourceTypeRequestParameters()) - ->setFilterableParameters($this->entity->summaryResourceTypeFilterParameters()) - ->setDynamicParameters($this->allowed_parameters) - ->setDescription('route-descriptions.summary-resource-type-item-GET-index') - ->setAuthenticationStatus($this->permissions['view']) - ->option(); - - return $this; - } -} From 8b5809f9e4e109fcfc8c66552e51ce766de5350c Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Mon, 24 Jan 2022 23:24:56 +0000 Subject: [PATCH 54/73] Refactoring - Removed unused methods --- app/ItemType/Game/Item.php | 10 ---------- app/ItemType/ItemType.php | 10 ---------- app/ItemType/SimpleItem/Item.php | 10 ---------- app/Option/Response.php | 10 ---------- 4 files changed, 40 deletions(-) diff --git a/app/ItemType/Game/Item.php b/app/ItemType/Game/Item.php index 7cbde84b..51f79baf 100644 --- a/app/ItemType/Game/Item.php +++ b/app/ItemType/Game/Item.php @@ -28,11 +28,6 @@ public function allowedValuesForItem(int $resource_type_id): array return (new Winner())->allowedValues($resource_type_id); } - public function categoryAssignmentLimit(): int - { - return 5; - } - public function create(int $id): Model { $item = new Models\Item([ @@ -60,11 +55,6 @@ public function model() return new Models\Item(); } - public function subcategoryAssignmentLimit(): int - { - return 0; - } - public function table(): string { return 'item_type_game'; diff --git a/app/ItemType/ItemType.php b/app/ItemType/ItemType.php index b3e9b147..f3334af8 100644 --- a/app/ItemType/ItemType.php +++ b/app/ItemType/ItemType.php @@ -86,11 +86,6 @@ public function allowPartialTransfers(): bool return false; } - public function categoryAssignmentLimit(): int - { - return 1; - } - abstract public function create(int $id): Model; public function dateRangeField(): ?string @@ -177,11 +172,6 @@ public function sortParameters(): array return LaravelConfig::get($this->base_path . '.sortable', []); } - public function subcategoryAssignmentLimit(): int - { - return 1; - } - abstract public function apiSummaryResponseClass(): string; abstract public function apiSummaryResourceTypeItemResponseClass(): string; abstract public function apiItemResponseClass(): string; diff --git a/app/ItemType/SimpleItem/Item.php b/app/ItemType/SimpleItem/Item.php index 91a4fa71..c18e2856 100644 --- a/app/ItemType/SimpleItem/Item.php +++ b/app/ItemType/SimpleItem/Item.php @@ -25,11 +25,6 @@ public function allowedValuesForItem(int $resource_type_id): array return []; } - public function categoryAssignmentLimit(): int - { - return 0; - } - public function create(int $id): Model { $item = new Models\Item([ @@ -56,11 +51,6 @@ public function model() return new Models\Item(); } - public function subcategoryAssignmentLimit(): int - { - return 0; - } - public function table(): string { return 'item_type_simple_item'; diff --git a/app/Option/Response.php b/app/Option/Response.php index 4c8d52fb..ca0ddc27 100644 --- a/app/Option/Response.php +++ b/app/Option/Response.php @@ -3,7 +3,6 @@ namespace App\Option; -use App\ItemType\ItemType; use Illuminate\Http\JsonResponse; abstract class Response @@ -16,8 +15,6 @@ abstract class Response protected array $allowed_parameters; - protected ItemType $entity; - public function __construct(array $permissions) { $this->verbs = []; @@ -65,11 +62,4 @@ public function setDynamicAllowedParameters(array $allowed_parameters): Response return $this; } - - public function setEntity(ItemType $entity): Response - { - $this->entity = $entity; - - return $this; - } } From c64a04c15cda42ed737520e2235e85e96a6c015d Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Mon, 24 Jan 2022 23:36:55 +0000 Subject: [PATCH 55/73] Refactoring - Removed dead methods --- app/ItemType/AllocatedExpense/Item.php | 6 ------ app/ItemType/Game/Item.php | 6 ------ app/ItemType/ItemType.php | 3 --- app/ItemType/SimpleExpense/Item.php | 6 ------ app/ItemType/SimpleItem/Item.php | 6 ------ 5 files changed, 27 deletions(-) diff --git a/app/ItemType/AllocatedExpense/Item.php b/app/ItemType/AllocatedExpense/Item.php index e85d4b72..eb9d9f09 100644 --- a/app/ItemType/AllocatedExpense/Item.php +++ b/app/ItemType/AllocatedExpense/Item.php @@ -7,7 +7,6 @@ use App\ItemType\ItemType; use App\Transformers\Transformer; use App\Request\Hash; -use App\Request\Validate\Validator; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Date; @@ -125,11 +124,6 @@ public function update(array $patch, Model $instance): bool return $instance->save(); } - public function validator(): Validator - { - return new \App\ItemType\AllocatedExpense\Validator(); - } - public function apiItemResponseClass(): string { return \App\ItemType\AllocatedExpense\ApiResponse\Item::class; diff --git a/app/ItemType/Game/Item.php b/app/ItemType/Game/Item.php index 51f79baf..1f7448cc 100644 --- a/app/ItemType/Game/Item.php +++ b/app/ItemType/Game/Item.php @@ -7,7 +7,6 @@ use App\ItemType\ItemType; use App\Transformers\Transformer; use App\Request\Hash; -use App\Request\Validate\Validator; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Config as LaravelConfig; use Illuminate\Support\Facades\Date; @@ -94,11 +93,6 @@ public function update(array $patch, Model $instance): bool return $instance->save(); } - public function validator(): Validator - { - return new \App\ItemType\Game\Validator(); - } - public function patchFields(): array { return LaravelConfig::get($this->base_path . '.fields-patch', []); diff --git a/app/ItemType/ItemType.php b/app/ItemType/ItemType.php index f3334af8..d40a4cad 100644 --- a/app/ItemType/ItemType.php +++ b/app/ItemType/ItemType.php @@ -5,7 +5,6 @@ use App\Transformers\Transformer; use App\Request\Parameter\Request; -use App\Request\Validate\Validator; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Config as LaravelConfig; @@ -215,8 +214,6 @@ abstract public function type(): string; abstract public function update(array $patch, Model $instance): bool; - abstract public function validator(): Validator; - abstract protected function allowedValuesItemCollectionClass(): string; abstract protected function allowedValuesResourceTypeItemCollectionClass(): string; } diff --git a/app/ItemType/SimpleExpense/Item.php b/app/ItemType/SimpleExpense/Item.php index 2792380e..e46f1c9a 100644 --- a/app/ItemType/SimpleExpense/Item.php +++ b/app/ItemType/SimpleExpense/Item.php @@ -7,7 +7,6 @@ use App\ItemType\ItemType; use App\Transformers\Transformer; use App\Request\Hash; -use App\Request\Validate\Validator; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Date; @@ -98,11 +97,6 @@ public function update(array $patch, Model $instance): bool return $instance->save(); } - public function validator(): Validator - { - return new \App\ItemType\SimpleExpense\Validator(); - } - public function apiItemResponseClass(): string { return ApiResponse\Item::class; diff --git a/app/ItemType/SimpleItem/Item.php b/app/ItemType/SimpleItem/Item.php index c18e2856..5b2e276a 100644 --- a/app/ItemType/SimpleItem/Item.php +++ b/app/ItemType/SimpleItem/Item.php @@ -5,7 +5,6 @@ use App\ItemType\ItemType; use App\Transformers\Transformer; -use App\Request\Validate\Validator; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Date; @@ -87,11 +86,6 @@ public function update(array $patch, Model $instance): bool return $instance->save(); } - public function validator(): Validator - { - return new \App\ItemType\SimpleItem\Validator(); - } - public function apiItemResponseClass(): string { return ApiResponse\Item::class; From 52cf6105cbb21a087aa2dcd5ef0a7b44208b2c39 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Mon, 24 Jan 2022 23:53:16 +0000 Subject: [PATCH 56/73] Refactoring - Call the config files directory, no need for the class methods --- app/Option/Item/AllocatedExpense.php | 8 ++++---- app/Option/Item/Game.php | 8 ++++---- app/Option/Item/SimpleExpense.php | 8 ++++---- app/Option/Item/SimpleItem.php | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/Option/Item/AllocatedExpense.php b/app/Option/Item/AllocatedExpense.php index f702339e..5fde5235 100644 --- a/app/Option/Item/AllocatedExpense.php +++ b/app/Option/Item/AllocatedExpense.php @@ -3,17 +3,17 @@ namespace App\Option\Item; -use App\ItemType\AllocatedExpense\Item; use App\Option\Response; +use Illuminate\Support\Facades\Config as LaravelConfig; class AllocatedExpense extends Response { public function create() { - $item = new Item(); + $base_path = 'api.item-type-allocated-expense'; $get = new \App\Method\GetRequest(); - $this->verbs['GET'] = $get->setParameters($item->itemRequestParameters()) + $this->verbs['GET'] = $get->setParameters(LaravelConfig::get($base_path . '.parameters.item', [])) ->setAuthenticationStatus($this->permissions['view']) ->setDescription('route-descriptions.item_GET_show') ->option(); @@ -25,7 +25,7 @@ public function create() ->option(); $patch = new \App\Method\PatchRequest(); - $this->verbs['PATCH'] = $patch->setFields($item->patchFields()) + $this->verbs['PATCH'] = $patch->setFields(LaravelConfig::get($base_path . '.fields', [])) ->setDescription('route-descriptions.item_PATCH') ->setAuthenticationStatus($this->permissions['manage']) ->setAuthenticationRequirement(true) diff --git a/app/Option/Item/Game.php b/app/Option/Item/Game.php index edb13da6..5680f940 100644 --- a/app/Option/Item/Game.php +++ b/app/Option/Item/Game.php @@ -3,17 +3,17 @@ namespace App\Option\Item; -use App\ItemType\Game\Item; use App\Option\Response; +use Illuminate\Support\Facades\Config as LaravelConfig; class Game extends Response { public function create() { - $item = new Item(); + $base_path = 'api.item-type-game'; $get = new \App\Method\GetRequest(); - $this->verbs['GET'] = $get->setParameters($item->itemRequestParameters()) + $this->verbs['GET'] = $get->setParameters(LaravelConfig::get($base_path . '.parameters.item', [])) ->setAuthenticationStatus($this->permissions['view']) ->setDescription('route-descriptions.item_GET_show') ->option(); @@ -25,7 +25,7 @@ public function create() ->option(); $patch = new \App\Method\PatchRequest(); - $this->verbs['PATCH'] = $patch->setFields($item->patchFields()) + $this->verbs['PATCH'] = $patch->setFields(LaravelConfig::get($base_path . '.fields-patch', [])) ->setDescription('route-descriptions.item_PATCH') ->setAuthenticationStatus($this->permissions['manage']) ->setAuthenticationRequirement(true) diff --git a/app/Option/Item/SimpleExpense.php b/app/Option/Item/SimpleExpense.php index 62e971bc..4272ffb8 100644 --- a/app/Option/Item/SimpleExpense.php +++ b/app/Option/Item/SimpleExpense.php @@ -3,17 +3,17 @@ namespace App\Option\Item; -use App\ItemType\SimpleExpense\Item; use App\Option\Response; +use Illuminate\Support\Facades\Config as LaravelConfig; class SimpleExpense extends Response { public function create() { - $item = new Item(); + $base_path = 'api.item-type-simple-expense'; $get = new \App\Method\GetRequest(); - $this->verbs['GET'] = $get->setParameters($item->itemRequestParameters()) + $this->verbs['GET'] = $get->setParameters(LaravelConfig::get($base_path . '.parameters.item', [])) ->setAuthenticationStatus($this->permissions['view']) ->setDescription('route-descriptions.item_GET_show') ->option(); @@ -25,7 +25,7 @@ public function create() ->option(); $patch = new \App\Method\PatchRequest(); - $this->verbs['PATCH'] = $patch->setFields($item->patchFields()) + $this->verbs['PATCH'] = $patch->setFields(LaravelConfig::get($base_path . '.fields', [])) ->setDescription('route-descriptions.item_PATCH') ->setAuthenticationStatus($this->permissions['manage']) ->setAuthenticationRequirement(true) diff --git a/app/Option/Item/SimpleItem.php b/app/Option/Item/SimpleItem.php index 3f517f89..a1dda187 100644 --- a/app/Option/Item/SimpleItem.php +++ b/app/Option/Item/SimpleItem.php @@ -3,17 +3,17 @@ namespace App\Option\Item; -use App\ItemType\SimpleItem\Item; use App\Option\Response; +use Illuminate\Support\Facades\Config as LaravelConfig; class SimpleItem extends Response { public function create() { - $item = new Item(); + $base_path = 'api.item-type-simple-item'; $get = new \App\Method\GetRequest(); - $this->verbs['GET'] = $get->setParameters($item->itemRequestParameters()) + $this->verbs['GET'] = $get->setParameters(LaravelConfig::get($base_path . '.parameters.item', [])) ->setAuthenticationStatus($this->permissions['view']) ->setDescription('route-descriptions.item_GET_show') ->option(); @@ -25,7 +25,7 @@ public function create() ->option(); $patch = new \App\Method\PatchRequest(); - $this->verbs['PATCH'] = $patch->setFields($item->patchFields()) + $this->verbs['PATCH'] = $patch->setFields(LaravelConfig::get($base_path . '.fields', [])) ->setDescription('route-descriptions.item_PATCH') ->setAuthenticationStatus($this->permissions['manage']) ->setAuthenticationRequirement(true) From d4de9006468bbd6959510263263316b00de12975 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Tue, 25 Jan 2022 14:49:43 +0000 Subject: [PATCH 57/73] Refactoring - Call the config file directly --- app/Option/Item/AllocatedExpenseCollection.php | 14 +++++++------- app/Option/Item/GameCollection.php | 14 +++++++------- app/Option/Item/SimpleExpenseCollection.php | 14 +++++++------- app/Option/Item/SimpleItemCollection.php | 14 +++++++------- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/app/Option/Item/AllocatedExpenseCollection.php b/app/Option/Item/AllocatedExpenseCollection.php index 4712db79..a3426cc2 100644 --- a/app/Option/Item/AllocatedExpenseCollection.php +++ b/app/Option/Item/AllocatedExpenseCollection.php @@ -3,20 +3,20 @@ namespace App\Option\Item; -use App\ItemType\AllocatedExpense\Item; use App\Option\Response; +use Illuminate\Support\Facades\Config as LaravelConfig; class AllocatedExpenseCollection extends Response { public function create() { - $item = new Item(); + $base_path = 'api.item-type-allocated-expense'; $get = new \App\Method\GetRequest(); - $this->verbs['GET'] = $get->setSortableParameters($item->sortParameters()) - ->setSearchableParameters($item->searchParameters()) - ->setFilterableParameters($item->filterParameters()) - ->setParameters($item->requestParameters()) + $this->verbs['GET'] = $get->setSortableParameters(LaravelConfig::get($base_path . '.sortable', [])) + ->setSearchableParameters(LaravelConfig::get($base_path . '.searchable', [])) + ->setFilterableParameters(LaravelConfig::get($base_path . '.filterable', [])) + ->setParameters(LaravelConfig::get($base_path . '.parameters.collection', [])) ->setDynamicParameters($this->allowed_parameters) ->setPaginationStatus(true) ->setAuthenticationStatus($this->permissions['view']) @@ -24,7 +24,7 @@ public function create() ->option(); $post = new \App\Method\PostRequest(); - $this->verbs['POST'] = $post->setFields($item->postFields()) + $this->verbs['POST'] = $post->setFields(LaravelConfig::get($base_path . '.fields', [])) ->setDescription( 'route-descriptions.item_POST') ->setAuthenticationRequirement(true) ->setAuthenticationStatus($this->permissions['manage']) diff --git a/app/Option/Item/GameCollection.php b/app/Option/Item/GameCollection.php index 2c84e07b..bf0de2a5 100644 --- a/app/Option/Item/GameCollection.php +++ b/app/Option/Item/GameCollection.php @@ -3,20 +3,20 @@ namespace App\Option\Item; -use App\ItemType\Game\Item; use App\Option\Response; +use Illuminate\Support\Facades\Config as LaravelConfig; class GameCollection extends Response { public function create() { - $item = new Item(); + $base_path = 'api.item-type-game'; $get = new \App\Method\GetRequest(); - $this->verbs['GET'] = $get->setSortableParameters($item->sortParameters()) - ->setSearchableParameters($item->searchParameters()) - ->setFilterableParameters($item->filterParameters()) - ->setParameters($item->requestParameters()) + $this->verbs['GET'] = $get->setSortableParameters(LaravelConfig::get($base_path . '.sortable', [])) + ->setSearchableParameters(LaravelConfig::get($base_path . '.searchable', [])) + ->setFilterableParameters(LaravelConfig::get($base_path . '.filterable', [])) + ->setParameters(LaravelConfig::get($base_path . '.parameters.collection', [])) ->setDynamicParameters($this->allowed_parameters) ->setPaginationStatus(true) ->setAuthenticationStatus($this->permissions['view']) @@ -24,7 +24,7 @@ public function create() ->option(); $post = new \App\Method\PostRequest(); - $this->verbs['POST'] = $post->setFields($item->postFields()) + $this->verbs['POST'] = $post->setFields(LaravelConfig::get($base_path . '.fields', [])) ->setDescription( 'route-descriptions.item_POST') ->setAuthenticationRequirement(true) ->setAuthenticationStatus($this->permissions['manage']) diff --git a/app/Option/Item/SimpleExpenseCollection.php b/app/Option/Item/SimpleExpenseCollection.php index 95b065bd..674b3925 100644 --- a/app/Option/Item/SimpleExpenseCollection.php +++ b/app/Option/Item/SimpleExpenseCollection.php @@ -3,20 +3,20 @@ namespace App\Option\Item; -use App\ItemType\SimpleExpense\Item; use App\Option\Response; +use Illuminate\Support\Facades\Config as LaravelConfig; class SimpleExpenseCollection extends Response { public function create() { - $item = new Item(); + $base_path = 'api.item-type-simple-expense'; $get = new \App\Method\GetRequest(); - $this->verbs['GET'] = $get->setSortableParameters($item->sortParameters()) - ->setSearchableParameters($item->searchParameters()) - ->setFilterableParameters($item->filterParameters()) - ->setParameters($item->requestParameters()) + $this->verbs['GET'] = $get->setSortableParameters(LaravelConfig::get($base_path . '.sortable', [])) + ->setSearchableParameters(LaravelConfig::get($base_path . '.searchable', [])) + ->setFilterableParameters(LaravelConfig::get($base_path . '.filterable', [])) + ->setParameters(LaravelConfig::get($base_path . '.parameters.collection', [])) ->setDynamicParameters($this->allowed_parameters) ->setPaginationStatus(true) ->setAuthenticationStatus($this->permissions['view']) @@ -24,7 +24,7 @@ public function create() ->option(); $post = new \App\Method\PostRequest(); - $this->verbs['POST'] = $post->setFields($item->postFields()) + $this->verbs['POST'] = $post->setFields(LaravelConfig::get($base_path . '.fields', [])) ->setDescription( 'route-descriptions.item_POST') ->setAuthenticationRequirement(true) ->setAuthenticationStatus($this->permissions['manage']) diff --git a/app/Option/Item/SimpleItemCollection.php b/app/Option/Item/SimpleItemCollection.php index 17b9e537..6b839f7e 100644 --- a/app/Option/Item/SimpleItemCollection.php +++ b/app/Option/Item/SimpleItemCollection.php @@ -3,20 +3,20 @@ namespace App\Option\Item; -use App\ItemType\SimpleItem\Item; use App\Option\Response; +use Illuminate\Support\Facades\Config as LaravelConfig; class SimpleItemCollection extends Response { public function create() { - $item = new Item(); + $base_path = 'api.item-type-simple-item'; $get = new \App\Method\GetRequest(); - $this->verbs['GET'] = $get->setSortableParameters($item->sortParameters()) - ->setSearchableParameters($item->searchParameters()) - ->setFilterableParameters($item->filterParameters()) - ->setParameters($item->requestParameters()) + $this->verbs['GET'] = $get->setSortableParameters(LaravelConfig::get($base_path . '.sortable', [])) + ->setSearchableParameters(LaravelConfig::get($base_path . '.searchable', [])) + ->setFilterableParameters(LaravelConfig::get($base_path . '.filterable', [])) + ->setParameters(LaravelConfig::get($base_path . '.parameters.collection', [])) ->setDynamicParameters($this->allowed_parameters) ->setPaginationStatus(true) ->setAuthenticationStatus($this->permissions['view']) @@ -24,7 +24,7 @@ public function create() ->option(); $post = new \App\Method\PostRequest(); - $this->verbs['POST'] = $post->setFields($item->postFields()) + $this->verbs['POST'] = $post->setFields(LaravelConfig::get($base_path . '.fields', [])) ->setDescription( 'route-descriptions.item_POST') ->setAuthenticationRequirement(true) ->setAuthenticationStatus($this->permissions['manage']) From 2bb040de15939467910863e67cd60fbb6ee78d6b Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Tue, 25 Jan 2022 15:12:41 +0000 Subject: [PATCH 58/73] Refactoring - Updated option classes to not call the pointless class --- .../ResourceTypeItem/AllocatedExpenseCollection.php | 12 ++++++------ app/Option/ResourceTypeItem/GameCollection.php | 12 ++++++------ .../ResourceTypeItem/SimpleExpenseCollection.php | 12 ++++++------ app/Option/ResourceTypeItem/SimpleItemCollection.php | 12 ++++++------ 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/app/Option/ResourceTypeItem/AllocatedExpenseCollection.php b/app/Option/ResourceTypeItem/AllocatedExpenseCollection.php index 235d05a4..e59faff5 100644 --- a/app/Option/ResourceTypeItem/AllocatedExpenseCollection.php +++ b/app/Option/ResourceTypeItem/AllocatedExpenseCollection.php @@ -3,21 +3,21 @@ namespace App\Option\ResourceTypeItem; -use App\ItemType\AllocatedExpense\Item; use App\Option\Response; +use Illuminate\Support\Facades\Config as LaravelConfig; class AllocatedExpenseCollection extends Response { public function create() { - $item = new Item(); + $base_path = 'api.resource-type-item-type-allocated-expense'; $get = new \App\Method\GetRequest(); - $this->verbs['GET'] = $get->setSortableParameters($item->resourceTypeSortParameters())-> - setSearchableParameters($item->resourceTypeSearchParameters())-> - setFilterableParameters($item->resourceTypeFilterParameters())-> + $this->verbs['GET'] = $get->setSortableParameters(LaravelConfig::get($base_path . '.sortable', []))-> + setSearchableParameters(LaravelConfig::get($base_path . '.searchable', []))-> + setFilterableParameters(LaravelConfig::get($base_path . '.filterable', []))-> setPaginationStatus(true)-> - setParameters($item->resourceTypeRequestParameters())-> + setParameters(LaravelConfig::get($base_path . '.parameters.collection', []))-> setDynamicParameters($this->allowed_parameters)-> setDescription('route-descriptions.resource_type_item_GET_index')-> setAuthenticationStatus($this->permissions['view'])-> diff --git a/app/Option/ResourceTypeItem/GameCollection.php b/app/Option/ResourceTypeItem/GameCollection.php index ce04fb40..03073799 100644 --- a/app/Option/ResourceTypeItem/GameCollection.php +++ b/app/Option/ResourceTypeItem/GameCollection.php @@ -3,21 +3,21 @@ namespace App\Option\ResourceTypeItem; -use App\ItemType\Game\Item; use App\Option\Response; +use Illuminate\Support\Facades\Config as LaravelConfig; class GameCollection extends Response { public function create() { - $item = new Item(); + $base_path = 'api.resource-type-item-type-game'; $get = new \App\Method\GetRequest(); - $this->verbs['GET'] = $get->setSortableParameters($item->resourceTypeSortParameters())-> - setSearchableParameters($item->resourceTypeSearchParameters())-> - setFilterableParameters($item->resourceTypeFilterParameters())-> + $this->verbs['GET'] = $get->setSortableParameters(LaravelConfig::get($base_path . '.sortable', []))-> + setSearchableParameters(LaravelConfig::get($base_path . '.searchable', []))-> + setFilterableParameters(LaravelConfig::get($base_path . '.filterable', []))-> setPaginationStatus(true)-> - setParameters($item->resourceTypeRequestParameters())-> + setParameters(LaravelConfig::get($base_path . '.parameters.collection', []))-> setDynamicParameters($this->allowed_parameters)-> setDescription('route-descriptions.resource_type_item_GET_index')-> setAuthenticationStatus($this->permissions['view'])-> diff --git a/app/Option/ResourceTypeItem/SimpleExpenseCollection.php b/app/Option/ResourceTypeItem/SimpleExpenseCollection.php index 93d3f46c..57378723 100644 --- a/app/Option/ResourceTypeItem/SimpleExpenseCollection.php +++ b/app/Option/ResourceTypeItem/SimpleExpenseCollection.php @@ -3,21 +3,21 @@ namespace App\Option\ResourceTypeItem; -use App\ItemType\SimpleExpense\Item; use App\Option\Response; +use Illuminate\Support\Facades\Config as LaravelConfig; class SimpleExpenseCollection extends Response { public function create() { - $item = new Item(); + $base_path = 'api.resource-type-item-type-simple-expense'; $get = new \App\Method\GetRequest(); - $this->verbs['GET'] = $get->setSortableParameters($item->resourceTypeSortParameters())-> - setSearchableParameters($item->resourceTypeSearchParameters())-> - setFilterableParameters($item->resourceTypeFilterParameters())-> + $this->verbs['GET'] = $get->setSortableParameters(LaravelConfig::get($base_path . '.sortable', []))-> + setSearchableParameters(LaravelConfig::get($base_path . '.searchable', []))-> + setFilterableParameters(LaravelConfig::get($base_path . '.filterable', []))-> setPaginationStatus(true)-> - setParameters($item->resourceTypeRequestParameters())-> + setParameters(LaravelConfig::get($base_path . '.parameters.collection', []))-> setDynamicParameters($this->allowed_parameters)-> setDescription('route-descriptions.resource_type_item_GET_index')-> setAuthenticationStatus($this->permissions['view'])-> diff --git a/app/Option/ResourceTypeItem/SimpleItemCollection.php b/app/Option/ResourceTypeItem/SimpleItemCollection.php index 08fc8ae7..48617f7a 100644 --- a/app/Option/ResourceTypeItem/SimpleItemCollection.php +++ b/app/Option/ResourceTypeItem/SimpleItemCollection.php @@ -3,21 +3,21 @@ namespace App\Option\ResourceTypeItem; -use App\ItemType\SimpleItem\Item; use App\Option\Response; +use Illuminate\Support\Facades\Config as LaravelConfig; class SimpleItemCollection extends Response { public function create() { - $item = new Item(); + $base_path = 'api.resource-type-item-type-simple-item'; $get = new \App\Method\GetRequest(); - $this->verbs['GET'] = $get->setSortableParameters($item->resourceTypeSortParameters())-> - setSearchableParameters($item->resourceTypeSearchParameters())-> - setFilterableParameters($item->resourceTypeFilterParameters())-> + $this->verbs['GET'] = $get->setSortableParameters(LaravelConfig::get($base_path . '.sortable', []))-> + setSearchableParameters(LaravelConfig::get($base_path . '.searchable', []))-> + setFilterableParameters(LaravelConfig::get($base_path . '.filterable', []))-> setPaginationStatus(true)-> - setParameters($item->resourceTypeRequestParameters())-> + setParameters(LaravelConfig::get($base_path . '.parameters.collection', []))-> setDynamicParameters($this->allowed_parameters)-> setDescription('route-descriptions.resource_type_item_GET_index')-> setAuthenticationStatus($this->permissions['view'])-> From 26b5f2102dafccf2b53820924603de660b58b686 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Tue, 25 Jan 2022 15:24:40 +0000 Subject: [PATCH 59/73] Refactoring - Removed dead methods --- app/ItemType/ItemType.php | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/app/ItemType/ItemType.php b/app/ItemType/ItemType.php index d40a4cad..e9d5d179 100644 --- a/app/ItemType/ItemType.php +++ b/app/ItemType/ItemType.php @@ -99,18 +99,8 @@ public function filterParameters(): array abstract public function instance(int $id): Model; - public function itemRequestParameters(): array - { - return LaravelConfig::get($this->base_path . '.parameters.item', []); // We need to split this - } - abstract public function model(); - public function patchFields(): array // We need post fields and patch fields - { - return $this->postFields(); - } - public function patchValidation(): array // We need to split validation config files { return LaravelConfig::get($this->base_path . '.validation.PATCH.fields', []); @@ -121,11 +111,6 @@ public function patchValidationMessages(): array // We need to split validation return LaravelConfig::get($this->base_path . '.validation.PATCH.messages', []); } - public function postFields(): array // We need post fields and patch fields - { - return LaravelConfig::get($this->base_path . '.fields', []); - } - public function postValidation(): array // We need to split validation config files { return LaravelConfig::get($this->base_path . '.validation.POST.fields', []); From 2c8a256b8af05e1584a8d13d05557429b04f0724 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Tue, 25 Jan 2022 15:46:00 +0000 Subject: [PATCH 60/73] Refactoring - Response classes don't use entity class --- .../AllocatedExpense/ApiResponse/Item.php | 37 +++++++++++++++---- app/ItemType/Game/ApiResponse/Item.php | 37 +++++++++++++++---- .../SimpleExpense/ApiResponse/Item.php | 37 +++++++++++++++---- app/ItemType/SimpleItem/ApiResponse/Item.php | 37 +++++++++++++++---- 4 files changed, 120 insertions(+), 28 deletions(-) diff --git a/app/ItemType/AllocatedExpense/ApiResponse/Item.php b/app/ItemType/AllocatedExpense/ApiResponse/Item.php index 55b9f968..85006dfd 100644 --- a/app/ItemType/AllocatedExpense/ApiResponse/Item.php +++ b/app/ItemType/AllocatedExpense/ApiResponse/Item.php @@ -4,8 +4,13 @@ namespace App\ItemType\AllocatedExpense\ApiResponse; use App\ItemType\ApiItemResponse; +use App\Request\Parameter\Filter; +use App\Request\Parameter\Request; +use App\Request\Parameter\Search; +use App\Request\Parameter\Sort; use App\Response\Responses; use Illuminate\Http\JsonResponse; +use Illuminate\Support\Facades\Config as LaravelConfig; use function request; use function response; use function trans; @@ -14,6 +19,8 @@ class Item extends ApiItemResponse { public function collectionResponse(): JsonResponse { + $this->requestParameters(); + if ($this->cache_control->visibility() === 'public') { $this->cache_control->setTtlOneWeek(); } else { @@ -29,10 +36,6 @@ public function collectionResponse(): JsonResponse ) { $model = new \App\ItemType\AllocatedExpense\Models\Item(); - $this->fetchAllRequestParameters( - new \App\ItemType\AllocatedExpense\Item() - ); - $total = $model->totalCount( $this->resource_type_id, $this->resource_id, @@ -86,9 +89,7 @@ static function ($item) { public function showResponse(int $item_id): JsonResponse { - $this->fetchAllRequestParameters( - new \App\ItemType\AllocatedExpense\Item() - ); + $this->requestParameters(); $item = (new \App\ItemType\AllocatedExpense\Models\Item())->single( $this->resource_type_id, @@ -107,4 +108,26 @@ public function showResponse(int $item_id): JsonResponse $this->showHeaders() ); } + + protected function requestParameters(): void + { + $base_path = 'api.item-type-allocated-expense'; + + $this->request_parameters = Request::fetch( + array_keys(LaravelConfig::get($base_path . '.parameters.collection', [])), + $this->resource_type_id + ); + + $this->search_parameters = Search::fetch( + LaravelConfig::get($base_path . '.searchable', []) + ); + + $this->filter_parameters = Filter::fetch( + LaravelConfig::get($base_path . '.filterable', []) + ); + + $this->sort_fields = Sort::fetch( + LaravelConfig::get($base_path . '.sortable', []) + ); + } } diff --git a/app/ItemType/Game/ApiResponse/Item.php b/app/ItemType/Game/ApiResponse/Item.php index 75ce20bb..7ab9ee30 100644 --- a/app/ItemType/Game/ApiResponse/Item.php +++ b/app/ItemType/Game/ApiResponse/Item.php @@ -4,8 +4,13 @@ namespace App\ItemType\Game\ApiResponse; use App\ItemType\ApiItemResponse; +use App\Request\Parameter\Filter; +use App\Request\Parameter\Request; +use App\Request\Parameter\Search; +use App\Request\Parameter\Sort; use App\Response\Responses; use Illuminate\Http\JsonResponse; +use Illuminate\Support\Facades\Config as LaravelConfig; use function request; use function response; use function trans; @@ -14,6 +19,8 @@ class Item extends ApiItemResponse { public function collectionResponse(): JsonResponse { + $this->requestParameters(); + $this->cache_control->setTtlOneWeek(); $cache_collection = new \App\Cache\Collection(); @@ -25,10 +32,6 @@ public function collectionResponse(): JsonResponse ) { $model = new \App\ItemType\Game\Models\Item(); - $this->fetchAllRequestParameters( - new \App\ItemType\Game\Item() - ); - $total = $model->totalCount( $this->resource_type_id, $this->resource_id, @@ -82,9 +85,7 @@ static function ($item) { public function showResponse(int $item_id): JsonResponse { - $this->fetchAllRequestParameters( - new \App\ItemType\Game\Item() - ); + $this->requestParameters(); $item = (new \App\ItemType\Game\Models\Item())->single( $this->resource_type_id, @@ -103,4 +104,26 @@ public function showResponse(int $item_id): JsonResponse $this->showHeaders() ); } + + protected function requestParameters(): void + { + $base_path = 'api.item-type-game'; + + $this->request_parameters = Request::fetch( + array_keys(LaravelConfig::get($base_path . '.parameters.collection', [])), + $this->resource_type_id + ); + + $this->search_parameters = Search::fetch( + LaravelConfig::get($base_path . '.searchable', []) + ); + + $this->filter_parameters = Filter::fetch( + LaravelConfig::get($base_path . '.filterable', []) + ); + + $this->sort_fields = Sort::fetch( + LaravelConfig::get($base_path . '.sortable', []) + ); + } } diff --git a/app/ItemType/SimpleExpense/ApiResponse/Item.php b/app/ItemType/SimpleExpense/ApiResponse/Item.php index a9b3e600..0015e376 100644 --- a/app/ItemType/SimpleExpense/ApiResponse/Item.php +++ b/app/ItemType/SimpleExpense/ApiResponse/Item.php @@ -4,8 +4,13 @@ namespace App\ItemType\SimpleExpense\ApiResponse; use App\ItemType\ApiItemResponse; +use App\Request\Parameter\Filter; +use App\Request\Parameter\Request; +use App\Request\Parameter\Search; +use App\Request\Parameter\Sort; use App\Response\Responses; use Illuminate\Http\JsonResponse; +use Illuminate\Support\Facades\Config as LaravelConfig; use function request; use function response; use function trans; @@ -14,6 +19,8 @@ class Item extends ApiItemResponse { public function collectionResponse(): JsonResponse { + $this->requestParameters(); + $this->cache_control->setTtlOneMonth(); $cache_collection = new \App\Cache\Collection(); @@ -25,10 +32,6 @@ public function collectionResponse(): JsonResponse ) { $model = new \App\ItemType\SimpleExpense\Models\Item(); - $this->fetchAllRequestParameters( - new \App\ItemType\SimpleExpense\Item() - ); - $total = $model->totalCount( $this->resource_type_id, $this->resource_id, @@ -82,9 +85,7 @@ static function ($item) { public function showResponse(int $item_id): JsonResponse { - $this->fetchAllRequestParameters( - new \App\ItemType\SimpleExpense\Item() - ); + $this->requestParameters(); $item = (new \App\ItemType\SimpleExpense\Models\Item())->single( $this->resource_type_id, @@ -103,4 +104,26 @@ public function showResponse(int $item_id): JsonResponse $this->showHeaders() ); } + + protected function requestParameters(): void + { + $base_path = 'api.item-type-simple-expense'; + + $this->request_parameters = Request::fetch( + array_keys(LaravelConfig::get($base_path . '.parameters.collection', [])), + $this->resource_type_id + ); + + $this->search_parameters = Search::fetch( + LaravelConfig::get($base_path . '.searchable', []) + ); + + $this->filter_parameters = Filter::fetch( + LaravelConfig::get($base_path . '.filterable', []) + ); + + $this->sort_fields = Sort::fetch( + LaravelConfig::get($base_path . '.sortable', []) + ); + } } diff --git a/app/ItemType/SimpleItem/ApiResponse/Item.php b/app/ItemType/SimpleItem/ApiResponse/Item.php index 4dadeaef..7f9e4f8b 100644 --- a/app/ItemType/SimpleItem/ApiResponse/Item.php +++ b/app/ItemType/SimpleItem/ApiResponse/Item.php @@ -4,8 +4,13 @@ namespace App\ItemType\SimpleItem\ApiResponse; use App\ItemType\ApiItemResponse; +use App\Request\Parameter\Filter; +use App\Request\Parameter\Request; +use App\Request\Parameter\Search; +use App\Request\Parameter\Sort; use App\Response\Responses; use Illuminate\Http\JsonResponse; +use Illuminate\Support\Facades\Config as LaravelConfig; use function request; use function response; use function trans; @@ -14,6 +19,8 @@ class Item extends ApiItemResponse { public function collectionResponse(): JsonResponse { + $this->requestParameters(); + $this->cache_control->setTtlOneMonth(); $cache_collection = new \App\Cache\Collection(); @@ -25,10 +32,6 @@ public function collectionResponse(): JsonResponse ) { $model = new \App\ItemType\SimpleItem\Models\Item(); - $this->fetchAllRequestParameters( - new \App\ItemType\SimpleItem\Item() - ); - $total = $model->totalCount( $this->resource_type_id, $this->resource_id, @@ -81,9 +84,7 @@ static function ($item) { public function showResponse(int $item_id): JsonResponse { - $this->fetchAllRequestParameters( - new \App\ItemType\SimpleItem\Item() - ); + $this->requestParameters(); $item = (new \App\ItemType\SimpleItem\Models\Item())->single( $this->resource_type_id, @@ -102,4 +103,26 @@ public function showResponse(int $item_id): JsonResponse $this->showHeaders() ); } + + protected function requestParameters(): void + { + $base_path = 'api.item-type-simple-item'; + + $this->request_parameters = Request::fetch( + array_keys(LaravelConfig::get($base_path . '.parameters.collection', [])), + $this->resource_type_id + ); + + $this->search_parameters = Search::fetch( + LaravelConfig::get($base_path . '.searchable', []) + ); + + $this->filter_parameters = Filter::fetch( + LaravelConfig::get($base_path . '.filterable', []) + ); + + $this->sort_fields = Sort::fetch( + LaravelConfig::get($base_path . '.sortable', []) + ); + } } From 806227872174dfab07a82b58ba7b15008042fb94 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Tue, 25 Jan 2022 16:00:17 +0000 Subject: [PATCH 61/73] Refactoring - Remove need for entity class --- .../ApiResponse/ResourceTypeItem.php | 34 ++++++++++++++++--- .../Game/ApiResponse/ResourceTypeItem.php | 34 ++++++++++++++++--- .../ApiResponse/ResourceTypeItem.php | 34 ++++++++++++++++--- .../ApiResponse/ResourceTypeItem.php | 34 ++++++++++++++++--- 4 files changed, 116 insertions(+), 20 deletions(-) diff --git a/app/ItemType/AllocatedExpense/ApiResponse/ResourceTypeItem.php b/app/ItemType/AllocatedExpense/ApiResponse/ResourceTypeItem.php index c90bcf08..7f52a926 100644 --- a/app/ItemType/AllocatedExpense/ApiResponse/ResourceTypeItem.php +++ b/app/ItemType/AllocatedExpense/ApiResponse/ResourceTypeItem.php @@ -3,9 +3,13 @@ namespace App\ItemType\AllocatedExpense\ApiResponse; -use App\ItemType\AllocatedExpense\Item; use App\ItemType\ApiResourceTypeItemResponse; +use App\Request\Parameter\Filter; +use App\Request\Parameter\Request; +use App\Request\Parameter\Search; +use App\Request\Parameter\Sort; use Illuminate\Http\JsonResponse; +use Illuminate\Support\Facades\Config as LaravelConfig; use function request; use function response; @@ -13,6 +17,8 @@ class ResourceTypeItem extends ApiResourceTypeItemResponse { public function response(): JsonResponse { + $this->requestParameters(); + if ($this->cache_control->visibility() === 'public') { $this->cache_control->setTtlOneWeek(); } else { @@ -28,10 +34,6 @@ public function response(): JsonResponse ) { $model = new \App\ItemType\AllocatedExpense\Models\ResourceTypeItem(); - $this->fetchAllRequestParameters( - new Item() - ); - $total = $model->totalCount( $this->resource_type_id, $this->request_parameters, @@ -80,4 +82,26 @@ static function ($item) { return response()->json($cache_collection->collection(), 200, $cache_collection->headers()); } + + private function requestParameters(): void + { + $base_path = 'api.resource-type-item-type-allocated-expense'; + + $this->request_parameters = Request::fetch( + array_keys(LaravelConfig::get($base_path . '.parameters.collection', [])), + $this->resource_type_id + ); + + $this->search_parameters = Search::fetch( + LaravelConfig::get($base_path . '.searchable', []) + ); + + $this->filter_parameters = Filter::fetch( + LaravelConfig::get($base_path . '.filterable', []) + ); + + $this->sort_fields = Sort::fetch( + LaravelConfig::get($base_path . '.sortable', []) + ); + } } diff --git a/app/ItemType/Game/ApiResponse/ResourceTypeItem.php b/app/ItemType/Game/ApiResponse/ResourceTypeItem.php index e2937988..69b11b8d 100644 --- a/app/ItemType/Game/ApiResponse/ResourceTypeItem.php +++ b/app/ItemType/Game/ApiResponse/ResourceTypeItem.php @@ -3,9 +3,13 @@ namespace App\ItemType\Game\ApiResponse; -use App\ItemType\Game\Item; use App\ItemType\ApiResourceTypeItemResponse; +use App\Request\Parameter\Filter; +use App\Request\Parameter\Request; +use App\Request\Parameter\Search; +use App\Request\Parameter\Sort; use Illuminate\Http\JsonResponse; +use Illuminate\Support\Facades\Config as LaravelConfig; use function request; use function response; @@ -13,6 +17,8 @@ class ResourceTypeItem extends ApiResourceTypeItemResponse { public function response(): JsonResponse { + $this->requestParameters(); + $this->cache_control->setTtlOneWeek(); $cache_collection = new \App\Cache\Collection(); @@ -24,10 +30,6 @@ public function response(): JsonResponse ) { $model = new \App\ItemType\Game\Models\ResourceTypeItem(); - $this->fetchAllRequestParameters( - new Item() - ); - $total = $model->totalCount( $this->resource_type_id, $this->request_parameters, @@ -76,4 +78,26 @@ static function ($item) { return response()->json($cache_collection->collection(), 200, $cache_collection->headers()); } + + private function requestParameters(): void + { + $base_path = 'api.resource-type-item-type-game'; + + $this->request_parameters = Request::fetch( + array_keys(LaravelConfig::get($base_path . '.parameters.collection', [])), + $this->resource_type_id + ); + + $this->search_parameters = Search::fetch( + LaravelConfig::get($base_path . '.searchable', []) + ); + + $this->filter_parameters = Filter::fetch( + LaravelConfig::get($base_path . '.filterable', []) + ); + + $this->sort_fields = Sort::fetch( + LaravelConfig::get($base_path . '.sortable', []) + ); + } } diff --git a/app/ItemType/SimpleExpense/ApiResponse/ResourceTypeItem.php b/app/ItemType/SimpleExpense/ApiResponse/ResourceTypeItem.php index 72c288f8..5b5376b2 100644 --- a/app/ItemType/SimpleExpense/ApiResponse/ResourceTypeItem.php +++ b/app/ItemType/SimpleExpense/ApiResponse/ResourceTypeItem.php @@ -4,8 +4,12 @@ namespace App\ItemType\SimpleExpense\ApiResponse; use App\ItemType\ApiResourceTypeItemResponse; -use App\ItemType\SimpleExpense\Item; +use App\Request\Parameter\Filter; +use App\Request\Parameter\Request; +use App\Request\Parameter\Search; +use App\Request\Parameter\Sort; use Illuminate\Http\JsonResponse; +use Illuminate\Support\Facades\Config as LaravelConfig; use function request; use function response; @@ -13,6 +17,8 @@ class ResourceTypeItem extends ApiResourceTypeItemResponse { public function response(): JsonResponse { + $this->requestParameters(); + $this->cache_control->setTtlOneMonth(); $cache_collection = new \App\Cache\Collection(); @@ -24,10 +30,6 @@ public function response(): JsonResponse ) { $model = new \App\ItemType\SimpleExpense\Models\ResourceTypeItem(); - $this->fetchAllRequestParameters( - new Item() - ); - $total = $model->totalCount( $this->resource_type_id, $this->request_parameters, @@ -76,4 +78,26 @@ static function ($item) { return response()->json($cache_collection->collection(), 200, $cache_collection->headers()); } + + private function requestParameters(): void + { + $base_path = 'api.resource-type-item-type-simple-expense'; + + $this->request_parameters = Request::fetch( + array_keys(LaravelConfig::get($base_path . '.parameters.collection', [])), + $this->resource_type_id + ); + + $this->search_parameters = Search::fetch( + LaravelConfig::get($base_path . '.searchable', []) + ); + + $this->filter_parameters = Filter::fetch( + LaravelConfig::get($base_path . '.filterable', []) + ); + + $this->sort_fields = Sort::fetch( + LaravelConfig::get($base_path . '.sortable', []) + ); + } } diff --git a/app/ItemType/SimpleItem/ApiResponse/ResourceTypeItem.php b/app/ItemType/SimpleItem/ApiResponse/ResourceTypeItem.php index 5b381157..09109d7d 100644 --- a/app/ItemType/SimpleItem/ApiResponse/ResourceTypeItem.php +++ b/app/ItemType/SimpleItem/ApiResponse/ResourceTypeItem.php @@ -4,8 +4,12 @@ namespace App\ItemType\SimpleItem\ApiResponse; use App\ItemType\ApiResourceTypeItemResponse; -use App\ItemType\SimpleItem\Item; +use App\Request\Parameter\Filter; +use App\Request\Parameter\Request; +use App\Request\Parameter\Search; +use App\Request\Parameter\Sort; use Illuminate\Http\JsonResponse; +use Illuminate\Support\Facades\Config as LaravelConfig; use function request; use function response; @@ -13,6 +17,8 @@ class ResourceTypeItem extends ApiResourceTypeItemResponse { public function response(): JsonResponse { + $this->requestParameters(); + $this->cache_control->setTtlOneMonth(); $cache_collection = new \App\Cache\Collection(); @@ -24,10 +30,6 @@ public function response(): JsonResponse ) { $model = new \App\ItemType\SimpleItem\Models\ResourceTypeItem(); - $this->fetchAllRequestParameters( - new Item() - ); - $total = $model->totalCount( $this->resource_type_id, $this->search_parameters, @@ -74,4 +76,26 @@ static function ($item) { return response()->json($cache_collection->collection(), 200, $cache_collection->headers()); } + + private function requestParameters(): void + { + $base_path = 'api.resource-type-item-type-simple-item'; + + $this->request_parameters = Request::fetch( + array_keys(LaravelConfig::get($base_path . '.parameters.collection', [])), + $this->resource_type_id + ); + + $this->search_parameters = Search::fetch( + LaravelConfig::get($base_path . '.searchable', []) + ); + + $this->filter_parameters = Filter::fetch( + LaravelConfig::get($base_path . '.filterable', []) + ); + + $this->sort_fields = Sort::fetch( + LaravelConfig::get($base_path . '.sortable', []) + ); + } } From 8b81ade1ea7ccb0bcea92a6bc935d8d82e336aed Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Tue, 25 Jan 2022 16:17:37 +0000 Subject: [PATCH 62/73] Refactoring - Updated response class to not need to use entity class. --- .../AllocatedExpense/ApiResponse/Summary.php | 24 +++++++++++++++++-- app/ItemType/Game/ApiResponse/Summary.php | 24 +++++++++++++++++-- .../SimpleExpense/ApiResponse/Summary.php | 24 +++++++++++++++++-- .../SimpleItem/ApiResponse/Summary.php | 24 +++++++++++++++++-- 4 files changed, 88 insertions(+), 8 deletions(-) diff --git a/app/ItemType/AllocatedExpense/ApiResponse/Summary.php b/app/ItemType/AllocatedExpense/ApiResponse/Summary.php index c9bb20e2..4759ec0b 100644 --- a/app/ItemType/AllocatedExpense/ApiResponse/Summary.php +++ b/app/ItemType/AllocatedExpense/ApiResponse/Summary.php @@ -2,10 +2,11 @@ namespace App\ItemType\AllocatedExpense\ApiResponse; -use App\ItemType\AllocatedExpense\Item; use App\ItemType\ApiSummaryResponse; +use App\Request\Parameter; use App\Request\Validate\Boolean; use Illuminate\Http\JsonResponse; +use Illuminate\Support\Facades\Config as LaravelConfig; use function request; use function response; @@ -31,7 +32,7 @@ public function __construct( $this->shortCircuit(); // Skip working out which for obvious routes - $this->fetchAllRequestParameters(new Item()); + $this->requestParameters(); $this->removeDecisionParameters(); } @@ -463,4 +464,23 @@ protected function setUpCache(): void $this->cache_summary = new \App\Cache\Summary(); $this->cache_summary->setFromCache($this->cache_control->getByKey(request()->getRequestUri())); } + + private function requestParameters(): void + { + $base_path = 'api.item-type-allocated-expense'; + + $this->parameters = Parameter\Request::fetch( + array_keys(LaravelConfig::get($base_path . '.summary-parameters', [])), + $this->resource_type_id, + $this->resource_id + ); + + $this->search_parameters = Parameter\Search::fetch( + LaravelConfig::get($base_path . '.summary-searchable', []) + ); + + $this->filter_parameters = Parameter\Filter::fetch( + LaravelConfig::get($base_path . '.summary-filterable', []) + ); + } } diff --git a/app/ItemType/Game/ApiResponse/Summary.php b/app/ItemType/Game/ApiResponse/Summary.php index 9e52474d..3010cd58 100644 --- a/app/ItemType/Game/ApiResponse/Summary.php +++ b/app/ItemType/Game/ApiResponse/Summary.php @@ -3,8 +3,9 @@ namespace App\ItemType\Game\ApiResponse; use App\ItemType\ApiSummaryResponse; -use App\ItemType\Game\Item; +use App\Request\Parameter; use Illuminate\Http\JsonResponse; +use Illuminate\Support\Facades\Config as LaravelConfig; use function response; class Summary extends ApiSummaryResponse @@ -27,7 +28,7 @@ public function __construct( $this->model = new \App\ItemType\Game\Models\Summary(); - $this->fetchAllRequestParameters(new Item()); + $this->requestParameters(); $this->removeDecisionParameters(); } @@ -102,4 +103,23 @@ protected function summary(): JsonResponse return response()->json($this->cache_summary->collection(), 200, $this->cache_summary->headers()); } + + private function requestParameters(): void + { + $base_path = 'api.item-type-game'; + + $this->parameters = Parameter\Request::fetch( + array_keys(LaravelConfig::get($base_path . '.summary-parameters', [])), + $this->resource_type_id, + $this->resource_id + ); + + $this->search_parameters = Parameter\Search::fetch( + LaravelConfig::get($base_path . '.summary-searchable', []) + ); + + $this->filter_parameters = Parameter\Filter::fetch( + LaravelConfig::get($base_path . '.summary-filterable', []) + ); + } } diff --git a/app/ItemType/SimpleExpense/ApiResponse/Summary.php b/app/ItemType/SimpleExpense/ApiResponse/Summary.php index 8389573a..dabdb18e 100644 --- a/app/ItemType/SimpleExpense/ApiResponse/Summary.php +++ b/app/ItemType/SimpleExpense/ApiResponse/Summary.php @@ -3,9 +3,10 @@ namespace App\ItemType\SimpleExpense\ApiResponse; use App\ItemType\ApiSummaryResponse; -use App\ItemType\SimpleExpense\Item; +use App\Request\Parameter; use App\Request\Validate\Boolean; use Illuminate\Http\JsonResponse; +use Illuminate\Support\Facades\Config as LaravelConfig; use function response; class Summary extends ApiSummaryResponse @@ -28,7 +29,7 @@ public function __construct( $this->model = new \App\ItemType\SimpleExpense\Models\Summary(); - $this->fetchAllRequestParameters(new Item()); + $this->requestParameters(); $this->removeDecisionParameters(); } @@ -263,4 +264,23 @@ protected function summary(): JsonResponse return response()->json($this->cache_summary->collection(), 200, $this->cache_summary->headers()); } + + private function requestParameters(): void + { + $base_path = 'api.item-type-simple-expense'; + + $this->parameters = Parameter\Request::fetch( + array_keys(LaravelConfig::get($base_path . '.summary-parameters', [])), + $this->resource_type_id, + $this->resource_id + ); + + $this->search_parameters = Parameter\Search::fetch( + LaravelConfig::get($base_path . '.summary-searchable', []) + ); + + $this->filter_parameters = Parameter\Filter::fetch( + LaravelConfig::get($base_path . '.summary-filterable', []) + ); + } } diff --git a/app/ItemType/SimpleItem/ApiResponse/Summary.php b/app/ItemType/SimpleItem/ApiResponse/Summary.php index 6e734c8e..86e9206c 100644 --- a/app/ItemType/SimpleItem/ApiResponse/Summary.php +++ b/app/ItemType/SimpleItem/ApiResponse/Summary.php @@ -3,8 +3,9 @@ namespace App\ItemType\SimpleItem\ApiResponse; use App\ItemType\ApiSummaryResponse; -use App\ItemType\SimpleItem\Item; +use App\Request\Parameter; use Illuminate\Http\JsonResponse; +use Illuminate\Support\Facades\Config as LaravelConfig; use function response; class Summary extends ApiSummaryResponse @@ -27,7 +28,7 @@ public function __construct( $this->model = new \App\ItemType\SimpleItem\Models\Summary(); - $this->fetchAllRequestParameters(new Item()); + $this->requestParameters(); $this->removeDecisionParameters(); } @@ -102,4 +103,23 @@ protected function summary(): JsonResponse return response()->json($this->cache_summary->collection(), 200, $this->cache_summary->headers()); } + + private function requestParameters(): void + { + $base_path = 'api.item-type-simple-item'; + + $this->parameters = Parameter\Request::fetch( + array_keys(LaravelConfig::get($base_path . '.summary-parameters', [])), + $this->resource_type_id, + $this->resource_id + ); + + $this->search_parameters = Parameter\Search::fetch( + LaravelConfig::get($base_path . '.summary-searchable', []) + ); + + $this->filter_parameters = Parameter\Filter::fetch( + LaravelConfig::get($base_path . '.summary-filterable', []) + ); + } } From 09e54f699b52a3ad84cb40999d6f5d3e5bf1283b Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Tue, 25 Jan 2022 22:34:03 +0000 Subject: [PATCH 63/73] Refactoring - Response classes should not call the entity class --- .../ApiResponse/SummaryResourceTypeItem.php | 23 +++++++++++++++++-- .../ApiResponse/SummaryResourceTypeItem.php | 23 +++++++++++++++++-- .../ApiResponse/SummaryResourceTypeItem.php | 23 +++++++++++++++++-- .../ApiResponse/SummaryResourceTypeItem.php | 23 +++++++++++++++++-- 4 files changed, 84 insertions(+), 8 deletions(-) diff --git a/app/ItemType/AllocatedExpense/ApiResponse/SummaryResourceTypeItem.php b/app/ItemType/AllocatedExpense/ApiResponse/SummaryResourceTypeItem.php index 4f9b93c9..13acfb30 100644 --- a/app/ItemType/AllocatedExpense/ApiResponse/SummaryResourceTypeItem.php +++ b/app/ItemType/AllocatedExpense/ApiResponse/SummaryResourceTypeItem.php @@ -2,10 +2,11 @@ namespace App\ItemType\AllocatedExpense\ApiResponse; -use App\ItemType\AllocatedExpense\Item; use App\ItemType\ApiSummaryResourceTypeItemResponse; +use App\Request\Parameter; use App\Request\Validate\Boolean; use Illuminate\Http\JsonResponse; +use Illuminate\Support\Facades\Config as LaravelConfig; use function request; use function response; @@ -29,7 +30,7 @@ public function __construct( $this->shortCircuit(); // Skip working out which for obvious routes - $this->fetchAllRequestParameters(new Item()); + $this->requestParameters(); $this->removeDecisionParameters(); } @@ -484,4 +485,22 @@ protected function setUpCache(): void $this->cache_summary = new \App\Cache\Summary(); $this->cache_summary->setFromCache($this->cache_control->getByKey(request()->getRequestUri())); } + + private function requestParameters(): void + { + $base_path = 'api.resource-type-item-type-allocated-expense'; + + $this->parameters = Parameter\Request::fetch( + array_keys(LaravelConfig::get($base_path . '.summary-parameters', [])), + $this->resource_type_id + ); + + $this->search_parameters = Parameter\Search::fetch( + LaravelConfig::get($base_path . '.summary-searchable', []) + ); + + $this->filter_parameters = Parameter\Filter::fetch( + LaravelConfig::get($base_path . '.summary-filterable', []) + ); + } } diff --git a/app/ItemType/Game/ApiResponse/SummaryResourceTypeItem.php b/app/ItemType/Game/ApiResponse/SummaryResourceTypeItem.php index 6afcd34f..b6ebd84f 100644 --- a/app/ItemType/Game/ApiResponse/SummaryResourceTypeItem.php +++ b/app/ItemType/Game/ApiResponse/SummaryResourceTypeItem.php @@ -2,10 +2,11 @@ namespace App\ItemType\Game\ApiResponse; -use App\ItemType\Game\Item; use App\ItemType\ApiSummaryResourceTypeItemResponse; +use App\Request\Parameter; use App\Request\Validate\Boolean; use Illuminate\Http\JsonResponse; +use Illuminate\Support\Facades\Config as LaravelConfig; use function response; class SummaryResourceTypeItem extends ApiSummaryResourceTypeItemResponse @@ -26,7 +27,7 @@ public function __construct( $this->model = new \App\ItemType\Game\Models\SummaryResourceTypeItem(); - $this->fetchAllRequestParameters(new Item()); + $this->requestParameters(); $this->removeDecisionParameters(); } @@ -133,4 +134,22 @@ protected function summary(): JsonResponse return response()->json($this->cache_summary->collection(), 200, $this->cache_summary->headers()); } + + private function requestParameters(): void + { + $base_path = 'api.resource-type-item-type-game'; + + $this->parameters = Parameter\Request::fetch( + array_keys(LaravelConfig::get($base_path . '.summary-parameters', [])), + $this->resource_type_id + ); + + $this->search_parameters = Parameter\Search::fetch( + LaravelConfig::get($base_path . '.summary-searchable', []) + ); + + $this->filter_parameters = Parameter\Filter::fetch( + LaravelConfig::get($base_path . '.summary-filterable', []) + ); + } } diff --git a/app/ItemType/SimpleExpense/ApiResponse/SummaryResourceTypeItem.php b/app/ItemType/SimpleExpense/ApiResponse/SummaryResourceTypeItem.php index 240a5031..30b41c57 100644 --- a/app/ItemType/SimpleExpense/ApiResponse/SummaryResourceTypeItem.php +++ b/app/ItemType/SimpleExpense/ApiResponse/SummaryResourceTypeItem.php @@ -2,10 +2,11 @@ namespace App\ItemType\SimpleExpense\ApiResponse; -use App\ItemType\SimpleExpense\Item; use App\ItemType\ApiSummaryResourceTypeItemResponse; +use App\Request\Parameter; use App\Request\Validate\Boolean; use Illuminate\Http\JsonResponse; +use Illuminate\Support\Facades\Config as LaravelConfig; use function response; class SummaryResourceTypeItem extends ApiSummaryResourceTypeItemResponse @@ -26,7 +27,7 @@ public function __construct( $this->model = new \App\ItemType\SimpleExpense\Models\SummaryResourceTypeItem(); - $this->fetchAllRequestParameters(new Item()); + $this->requestParameters(); $this->removeDecisionParameters(); } @@ -286,4 +287,22 @@ protected function summary(): JsonResponse return response()->json($this->cache_summary->collection(), 200, $this->cache_summary->headers()); } + + private function requestParameters(): void + { + $base_path = 'api.resource-type-item-type-simple-expense'; + + $this->parameters = Parameter\Request::fetch( + array_keys(LaravelConfig::get($base_path . '.summary-parameters', [])), + $this->resource_type_id + ); + + $this->search_parameters = Parameter\Search::fetch( + LaravelConfig::get($base_path . '.summary-searchable', []) + ); + + $this->filter_parameters = Parameter\Filter::fetch( + LaravelConfig::get($base_path . '.summary-filterable', []) + ); + } } diff --git a/app/ItemType/SimpleItem/ApiResponse/SummaryResourceTypeItem.php b/app/ItemType/SimpleItem/ApiResponse/SummaryResourceTypeItem.php index 3c5f44ee..8e0aea44 100644 --- a/app/ItemType/SimpleItem/ApiResponse/SummaryResourceTypeItem.php +++ b/app/ItemType/SimpleItem/ApiResponse/SummaryResourceTypeItem.php @@ -2,10 +2,11 @@ namespace App\ItemType\SimpleItem\ApiResponse; -use App\ItemType\SimpleItem\Item; use App\ItemType\ApiSummaryResourceTypeItemResponse; +use App\Request\Parameter; use App\Request\Validate\Boolean; use Illuminate\Http\JsonResponse; +use Illuminate\Support\Facades\Config as LaravelConfig; use function response; class SummaryResourceTypeItem extends ApiSummaryResourceTypeItemResponse @@ -26,7 +27,7 @@ public function __construct( $this->model = new \App\ItemType\SimpleItem\Models\SummaryResourceTypeItem(); - $this->fetchAllRequestParameters(new Item()); + $this->requestParameters(); $this->removeDecisionParameters(); } @@ -133,4 +134,22 @@ protected function summary(): JsonResponse return response()->json($this->cache_summary->collection(), 200, $this->cache_summary->headers()); } + + private function requestParameters(): void + { + $base_path = 'api.resource-type-item-type-simple-item'; + + $this->parameters = Parameter\Request::fetch( + array_keys(LaravelConfig::get($base_path . '.summary-parameters', [])), + $this->resource_type_id + ); + + $this->search_parameters = Parameter\Search::fetch( + LaravelConfig::get($base_path . '.summary-searchable', []) + ); + + $this->filter_parameters = Parameter\Filter::fetch( + LaravelConfig::get($base_path . '.summary-filterable', []) + ); + } } From 86845eea9a28fa8aa4d61af539d26cb010f5784c Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Tue, 25 Jan 2022 22:44:28 +0000 Subject: [PATCH 64/73] Refactoring - Removed the validator class and redundant methods --- app/ItemType/AllocatedExpense/Validator.php | 46 -------- app/ItemType/Game/Validator.php | 58 ---------- app/ItemType/SimpleExpense/Validator.php | 46 -------- app/ItemType/SimpleItem/Validator.php | 46 -------- app/Request/Validate/Validator.php | 111 -------------------- 5 files changed, 307 deletions(-) delete mode 100644 app/ItemType/AllocatedExpense/Validator.php delete mode 100644 app/ItemType/Game/Validator.php delete mode 100644 app/ItemType/SimpleExpense/Validator.php delete mode 100644 app/ItemType/SimpleItem/Validator.php diff --git a/app/ItemType/AllocatedExpense/Validator.php b/app/ItemType/AllocatedExpense/Validator.php deleted file mode 100644 index 0b2e12f8..00000000 --- a/app/ItemType/AllocatedExpense/Validator.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @copyright Dean Blackborough 2018-2022 - * @license https://github.com/costs-to-expect/api/blob/master/LICENSE - */ -class Validator extends BaseValidator -{ - public function __construct() - { - $this->entity = Entity::byType('allocated-expense'); - - parent::__construct(); - } - - /** - * Return the validator object for the create request - * - * @param array $options - * - * @return \Illuminate\Contracts\Validation\Validator - */ - public function create(array $options = []): \Illuminate\Contracts\Validation\Validator - { - return $this->createExpenseItemValidator(); - } - - /** - * Return a valid validator object for a update (PATCH) request - * - * @param array $options - * - * @return \Illuminate\Contracts\Validation\Validator|null - */ - public function update(array $options = []): ?\Illuminate\Contracts\Validation\Validator - { - return $this->updateExpenseItemValidator(); - } -} diff --git a/app/ItemType/Game/Validator.php b/app/ItemType/Game/Validator.php deleted file mode 100644 index ea11a14d..00000000 --- a/app/ItemType/Game/Validator.php +++ /dev/null @@ -1,58 +0,0 @@ - - * @copyright Dean Blackborough 2018-2022 - * @license https://github.com/costs-to-expect/api/blob/master/LICENSE - */ -class Validator extends BaseValidator -{ - public function __construct() - { - $this->entity = Entity::byType('game'); - - parent::__construct(); - } - - public function create(array $options = []): \Illuminate\Contracts\Validation\Validator - { - return $this->createItemValidator(); - } - - public function update(array $options = []): ?\Illuminate\Contracts\Validation\Validator - { - $merge_array = []; - if (array_key_exists('winner_id', request()->all())) { - $decode = $this->hash->category()->decode(request()->input('winner_id')); - $winner_id = null; - if (count($decode) === 1) { - $winner_id = $decode[0]; - } - - $merge_array = ['winner_id' => $winner_id]; - } - - $messages = []; - foreach ($this->entity->patchValidationMessages() as $key => $custom_message) { - $messages[$key] = trans($custom_message); - } - - return ValidatorFacade::make( - array_merge( - request()->all(), - $merge_array - ), - $this->entity->patchValidation(), - $messages - ); - } - - -} diff --git a/app/ItemType/SimpleExpense/Validator.php b/app/ItemType/SimpleExpense/Validator.php deleted file mode 100644 index aca8a89d..00000000 --- a/app/ItemType/SimpleExpense/Validator.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @copyright Dean Blackborough 2018-2022 - * @license https://github.com/costs-to-expect/api/blob/master/LICENSE - */ -class Validator extends BaseValidator -{ - public function __construct() - { - $this->entity = Entity::byType('simple-expense'); - - parent::__construct(); - } - - /** - * Return the validator object for the create request - * - * @param array $options - * - * @return \Illuminate\Contracts\Validation\Validator - */ - public function create(array $options = []): \Illuminate\Contracts\Validation\Validator - { - return $this->createExpenseItemValidator(); - } - - /** - * Return a valid validator object for a update (PATCH) request - * - * @param array $options - * - * @return \Illuminate\Contracts\Validation\Validator|null - */ - public function update(array $options = []): ?\Illuminate\Contracts\Validation\Validator - { - return $this->updateExpenseItemValidator(); - } -} diff --git a/app/ItemType/SimpleItem/Validator.php b/app/ItemType/SimpleItem/Validator.php deleted file mode 100644 index 20bfc3a4..00000000 --- a/app/ItemType/SimpleItem/Validator.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @copyright Dean Blackborough 2018-2022 - * @license https://github.com/costs-to-expect/api/blob/master/LICENSE - */ -class Validator extends BaseValidator -{ - public function __construct() - { - $this->entity = Entity::byType('simple-item'); - - parent::__construct(); - } - - /** - * Return the validator object for the create request - * - * @param array $options - * - * @return \Illuminate\Contracts\Validation\Validator - */ - public function create(array $options = []): \Illuminate\Contracts\Validation\Validator - { - return $this->createItemValidator(); - } - - /** - * Return a valid validator object for a update (PATCH) request - * - * @param array $options - * - * @return \Illuminate\Contracts\Validation\Validator|null - */ - public function update(array $options = []): ?\Illuminate\Contracts\Validation\Validator - { - return $this->updateItemValidator(); - } -} diff --git a/app/Request/Validate/Validator.php b/app/Request/Validate/Validator.php index 872ee989..e61e7aa8 100644 --- a/app/Request/Validate/Validator.php +++ b/app/Request/Validate/Validator.php @@ -6,11 +6,8 @@ use App\ItemType\ItemType; use App\Request\Hash; use Illuminate\Support\Facades\Config; -use Illuminate\Support\Facades\Validator as ValidatorFacade; /** - * Base validator class, sets up the interface and includes helper methods - * * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE @@ -26,14 +23,6 @@ public function __construct() $this->hash = new Hash(); } - /** - * Fetch the validation error messages from the requested configuration - * file and translate the message strings - * - * @param string $config_key - * - * @return array - */ protected function translateMessages(string $config_key): array { $messages = []; @@ -45,13 +34,6 @@ protected function translateMessages(string $config_key): array return $messages; } - /** - * Check to ensure we have all the required indexes, check the required - * keys against the provided keys - * - * @param array $required - * @param array $provided - */ protected function requiredIndexes( array $required = [], array $provided = [] @@ -64,100 +46,7 @@ protected function requiredIndexes( } } - /** - * Return a valid validator object for a create (POST) request - * - * @param array $options - * - * @return \Illuminate\Contracts\Validation\Validator - */ abstract public function create(array $options = []): \Illuminate\Contracts\Validation\Validator; - /** - * Return a valid validator object for a update (PATCH) request - * - * @param array $options - * - * @return \Illuminate\Contracts\Validation\Validator|null - */ abstract public function update(array $options = []): ?\Illuminate\Contracts\Validation\Validator; - - protected function createExpenseItemValidator(): \Illuminate\Contracts\Validation\Validator - { - $decode = $this->hash->currency()->decode(request()->input('currency_id')); - $currency_id = null; - if (count($decode) === 1) { - $currency_id = $decode[0]; - } - - $messages = []; - foreach ($this->entity->postValidationMessages() as $key => $custom_message) { - $messages[$key] = trans($custom_message); - } - - return ValidatorFacade::make( - array_merge( - request()->all(), - ['currency_id' => $currency_id] - ), - $this->entity->postValidation(), - $messages - ); - } - - protected function createItemValidator(): \Illuminate\Contracts\Validation\Validator - { - $messages = []; - foreach ($this->entity->postValidationMessages() as $key => $custom_message) { - $messages[$key] = trans($custom_message); - } - - return ValidatorFacade::make( - request()->all(), - $this->entity->postValidation(), - $messages - ); - } - - protected function updateExpenseItemValidator(): ?\Illuminate\Contracts\Validation\Validator - { - $merge_array = []; - if (array_key_exists('currency_id', request()->all())) { - $decode = $this->hash->currency()->decode(request()->input('currency_id')); - $currency_id = null; - if (count($decode) === 1) { - $currency_id = $decode[0]; - } - - $merge_array = ['currency_id' => $currency_id]; - } - - $messages = []; - foreach ($this->entity->patchValidationMessages() as $key => $custom_message) { - $messages[$key] = trans($custom_message); - } - - return ValidatorFacade::make( - array_merge( - request()->all(), - $merge_array - ), - $this->entity->patchValidation(), - $messages - ); - } - - protected function updateItemValidator(): ?\Illuminate\Contracts\Validation\Validator - { - $messages = []; - foreach ($this->entity->patchValidationMessages() as $key => $custom_message) { - $messages[$key] = trans($custom_message); - } - - return ValidatorFacade::make( - request()->all(), - $this->entity->patchValidation(), - $messages - ); - } } From 118488e9bb5dd5437814e7414a63b9cc816689dc Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Tue, 25 Jan 2022 22:54:38 +0000 Subject: [PATCH 65/73] Refactoring - Removed dead methods --- app/ItemType/ApiItemResponse.php | 22 ------------------ app/ItemType/ItemType.php | 40 -------------------------------- 2 files changed, 62 deletions(-) diff --git a/app/ItemType/ApiItemResponse.php b/app/ItemType/ApiItemResponse.php index f5614265..bec4d75e 100644 --- a/app/ItemType/ApiItemResponse.php +++ b/app/ItemType/ApiItemResponse.php @@ -82,28 +82,6 @@ protected function showHeaders(): array return $headers->headers(); } - protected function fetchAllRequestParameters( - ItemType $entity - ): void - { - $this->request_parameters = Request::fetch( - array_keys($entity->requestParameters()), - $this->resource_type_id - ); - - $this->search_parameters = Search::fetch( - $entity->searchParameters() - ); - - $this->filter_parameters = Filter::fetch( - $entity->filterParameters() - ); - - $this->sort_fields = Sort::fetch( - $entity->sortParameters() - ); - } - protected function pagination_parameters(int $total): array { $pagination = new UtilityPagination(request()->path(), $total); diff --git a/app/ItemType/ItemType.php b/app/ItemType/ItemType.php index e9d5d179..eeb557d9 100644 --- a/app/ItemType/ItemType.php +++ b/app/ItemType/ItemType.php @@ -8,11 +8,6 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Config as LaravelConfig; -/** - @todo We will need a console command to create the config files for a new type - * Add the ticket to Pivotal when/if happy with this. - */ - abstract class ItemType { protected string $base_path; @@ -101,26 +96,6 @@ abstract public function instance(int $id): Model; abstract public function model(); - public function patchValidation(): array // We need to split validation config files - { - return LaravelConfig::get($this->base_path . '.validation.PATCH.fields', []); - } - - public function patchValidationMessages(): array // We need to split validation config files - { - return LaravelConfig::get($this->base_path . '.validation.PATCH.messages', []); - } - - public function postValidation(): array // We need to split validation config files - { - return LaravelConfig::get($this->base_path . '.validation.POST.fields', []); - } - - public function postValidationMessages(): array // We need to split validation config files - { - return LaravelConfig::get($this->base_path . '.validation.POST.messages', []); - } - public function requestParameters(): array { return LaravelConfig::get($this->base_path . '.parameters.collection', []); // We need to split this @@ -146,21 +121,6 @@ public function resourceTypeSortParameters(): array return LaravelConfig::get($this->resource_type_base_path . '.sortable', []); } - public function searchParameters(): array - { - return LaravelConfig::get($this->base_path . '.searchable', []); - } - - public function sortParameters(): array - { - return LaravelConfig::get($this->base_path . '.sortable', []); - } - - abstract public function apiSummaryResponseClass(): string; - abstract public function apiSummaryResourceTypeItemResponseClass(): string; - abstract public function apiItemResponseClass(): string; - abstract public function apiResourceTypeItemResponseClass(): string; - public function summaryFilterParameters(): array { return LaravelConfig::get($this->base_path . '.summary-filterable', []); From 3b4a89efe735837b79d45c1fca5db6afbbe13f12 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Tue, 25 Jan 2022 23:07:35 +0000 Subject: [PATCH 66/73] Refactoring - Removed more dead methods. --- app/ItemType/AllocatedExpense/Item.php | 20 -------------------- app/ItemType/Game/Item.php | 20 -------------------- app/ItemType/ItemType.php | 7 ------- app/ItemType/SimpleExpense/Item.php | 20 -------------------- app/ItemType/SimpleItem/Item.php | 20 -------------------- 5 files changed, 87 deletions(-) diff --git a/app/ItemType/AllocatedExpense/Item.php b/app/ItemType/AllocatedExpense/Item.php index eb9d9f09..78e4b096 100644 --- a/app/ItemType/AllocatedExpense/Item.php +++ b/app/ItemType/AllocatedExpense/Item.php @@ -84,16 +84,6 @@ public function model() return new Models\Item(); } - public function apiSummaryResponseClass(): string - { - return ApiResponse\Summary::class; - } - - public function apiSummaryResourceTypeItemResponseClass(): string - { - return ApiResponse\SummaryResourceTypeItem::class; - } - public function transformer(array $data_to_transform): Transformer { return new Transformers\Item($data_to_transform); @@ -124,16 +114,6 @@ public function update(array $patch, Model $instance): bool return $instance->save(); } - public function apiItemResponseClass(): string - { - return \App\ItemType\AllocatedExpense\ApiResponse\Item::class; - } - - public function apiResourceTypeItemResponseClass(): string - { - return ApiResponse\ResourceTypeItem::class; - } - protected function allowedValuesItemCollectionClass(): string { return AllowedValue\Item::class; diff --git a/app/ItemType/Game/Item.php b/app/ItemType/Game/Item.php index 1f7448cc..d1f267b6 100644 --- a/app/ItemType/Game/Item.php +++ b/app/ItemType/Game/Item.php @@ -98,26 +98,6 @@ public function patchFields(): array return LaravelConfig::get($this->base_path . '.fields-patch', []); } - public function apiSummaryResponseClass(): string - { - return ApiResponse\Summary::class; - } - - public function apiItemResponseClass(): string - { - return ApiResponse\Item::class; - } - - public function apiSummaryResourceTypeItemResponseClass(): string - { - return ApiResponse\SummaryResourceTypeItem::class; - } - - public function apiResourceTypeItemResponseClass(): string - { - return ApiResponse\ResourceTypeItem::class; - } - protected function allowedValuesItemCollectionClass(): string { return AllowedValue\Item::class; diff --git a/app/ItemType/ItemType.php b/app/ItemType/ItemType.php index eeb557d9..ca981af4 100644 --- a/app/ItemType/ItemType.php +++ b/app/ItemType/ItemType.php @@ -87,15 +87,8 @@ public function dateRangeField(): ?string return null; } - public function filterParameters(): array - { - return LaravelConfig::get($this->base_path . '.filterable', []); - } - abstract public function instance(int $id): Model; - abstract public function model(); - public function requestParameters(): array { return LaravelConfig::get($this->base_path . '.parameters.collection', []); // We need to split this diff --git a/app/ItemType/SimpleExpense/Item.php b/app/ItemType/SimpleExpense/Item.php index e46f1c9a..bde80aa9 100644 --- a/app/ItemType/SimpleExpense/Item.php +++ b/app/ItemType/SimpleExpense/Item.php @@ -66,16 +66,6 @@ public function type(): string return 'simple-expense'; } - public function apiSummaryResponseClass(): string - { - return ApiResponse\Summary::class; - } - - public function apiSummaryResourceTypeItemResponseClass(): string - { - return ApiResponse\SummaryResourceTypeItem::class; - } - public function transformer(array $data_to_transform): Transformer { return new Transformers\Item($data_to_transform); @@ -97,16 +87,6 @@ public function update(array $patch, Model $instance): bool return $instance->save(); } - public function apiItemResponseClass(): string - { - return ApiResponse\Item::class; - } - - public function apiResourceTypeItemResponseClass(): string - { - return ApiResponse\ResourceTypeItem::class; - } - protected function allowedValuesItemCollectionClass(): string { return AllowedValue\Item::class; diff --git a/app/ItemType/SimpleItem/Item.php b/app/ItemType/SimpleItem/Item.php index 5b2e276a..96d40453 100644 --- a/app/ItemType/SimpleItem/Item.php +++ b/app/ItemType/SimpleItem/Item.php @@ -60,16 +60,6 @@ public function type(): string return 'simple-item'; } - public function apiSummaryResponseClass(): string - { - return ApiResponse\Summary::class; - } - - public function apiSummaryResourceTypeItemResponseClass(): string - { - return ApiResponse\SummaryResourceTypeItem::class; - } - public function transformer(array $data_to_transform): Transformer { return new Transformers\Item($data_to_transform); @@ -86,16 +76,6 @@ public function update(array $patch, Model $instance): bool return $instance->save(); } - public function apiItemResponseClass(): string - { - return ApiResponse\Item::class; - } - - public function apiResourceTypeItemResponseClass(): string - { - return ApiResponse\ResourceTypeItem::class; - } - protected function allowedValuesItemCollectionClass(): string { return AllowedValue\Item::class; From d923b21597ff1c451c6202a946c6e28fca1e9563 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Tue, 25 Jan 2022 23:57:45 +0000 Subject: [PATCH 67/73] Refactoring - Update partial transfers to not need the entity class, as per other item controllers --- .../Controllers/ItemPartialTransferView.php | 127 ++++++++++-------- .../AllocatedExpense.php} | 6 +- .../AllocatedExpenseCollection.php} | 5 +- .../AllocatedExpenseTransfer.php} | 5 +- 4 files changed, 78 insertions(+), 65 deletions(-) rename app/Option/{ItemPartialTransferItem.php => ItemPartialTransfer/AllocatedExpense.php} (85%) rename app/Option/{ItemPartialTransferCollection.php => ItemPartialTransfer/AllocatedExpenseCollection.php} (81%) rename app/Option/{ItemPartialTransferTransfer.php => ItemPartialTransfer/AllocatedExpenseTransfer.php} (82%) diff --git a/app/Http/Controllers/ItemPartialTransferView.php b/app/Http/Controllers/ItemPartialTransferView.php index 9539e72d..52e613ff 100644 --- a/app/Http/Controllers/ItemPartialTransferView.php +++ b/app/Http/Controllers/ItemPartialTransferView.php @@ -4,49 +4,47 @@ use App\ItemType\Entity; use App\Models\ItemPartialTransfer; -use App\Option\ItemPartialTransferCollection; -use App\Option\ItemPartialTransferItem; -use App\Option\ItemPartialTransferTransfer; +use App\Option\ItemPartialTransfer\AllocatedExpense; +use App\Option\ItemPartialTransfer\AllocatedExpenseCollection; +use App\Option\ItemPartialTransfer\AllocatedExpenseTransfer; use App\Request\Parameter; use App\Response\Header; use App\Response\Pagination as UtilityPagination; +use App\Response\Responses; use App\Transformers\ItemPartialTransfer as ItemPartialTransferTransformer; use Illuminate\Http\JsonResponse; use Illuminate\Support\Facades\Config; /** - * Partial transfer of items - * * @author Dean Blackborough * @copyright Dean Blackborough 2018-2022 * @license https://github.com/costs-to-expect/api/blob/master/LICENSE */ class ItemPartialTransferView extends Controller { - /** - * Return the partial transfer collection - * - * @param string $resource_type_id - * - * @return JsonResponse - */ public function index($resource_type_id): JsonResponse { if ($this->viewAccessToResourceType((int) $resource_type_id) === false) { \App\Response\Responses::notFoundOrNotAccessible(trans('entities.resource-type')); } + $item_type = Entity::itemType((int) $resource_type_id); + + return match ($item_type) { + 'allocated-expense' => $this->allocatedExpenseCollection((int) $resource_type_id), + 'game', 'simple-expense', 'simple-item' => Responses::notSupported(), + default => throw new \OutOfRangeException('No item type definition for ' . $item_type, 500), + }; + } + + private function allocatedExpenseCollection(int $resource_type_id): JsonResponse + { $cache_control = new \App\Cache\Control( $this->writeAccessToResourceType((int) $resource_type_id), $this->user_id ); $cache_control->setTtlOneWeek(); - $entity = Entity::item($resource_type_id); - if ($entity->allowPartialTransfers() === false) { - return \App\Response\Responses::notSupported(); - } - $cache_collection = new \App\Cache\Collection(); $cache_collection->setFromCache($cache_control->getByKey(request()->getRequestUri())); @@ -57,18 +55,18 @@ public function index($resource_type_id): JsonResponse ); $total = (new ItemPartialTransfer())->total( - (int) $resource_type_id, + $resource_type_id, $this->viewable_resource_types, $parameters ); $pagination = new UtilityPagination(request()->path(), $total); $pagination_parameters = $pagination->allowPaginationOverride($this->allow_entire_collection)-> - setParameters($parameters)-> - parameters(); + setParameters($parameters)-> + parameters(); $transfers = (new ItemPartialTransfer())->paginatedCollection( - (int)$resource_type_id, + $resource_type_id, $this->viewable_resource_types, $pagination_parameters['offset'], $pagination_parameters['limit'], @@ -83,9 +81,9 @@ static function ($transfer) { ); $headers = new Header(); - $headers->collection($pagination_parameters, count($transfers), $total)-> - addCacheControl($cache_control->visibility(), $cache_control->ttl())-> - addETag($collection); + $headers->collection($pagination_parameters, count($transfers), $total) + ->addCacheControl($cache_control->visibility(), $cache_control->ttl()) + ->addETag($collection); $cache_collection->create($total, $collection, $pagination_parameters, $headers->headers()); $cache_control->putByKey(request()->getRequestUri(), $cache_collection->content()); @@ -94,14 +92,6 @@ static function ($transfer) { return response()->json($cache_collection->collection(), 200, $cache_collection->headers()); } - /** - * Return a single item partial transfer - * - * @param $resource_type_id - * @param $item_partial_transfer_id - * - * @return JsonResponse - */ public function show( $resource_type_id, $item_partial_transfer_id @@ -111,11 +101,17 @@ public function show( \App\Response\Responses::notFoundOrNotAccessible(trans('entities.resource-type')); } - $entity = Entity::item($resource_type_id); - if ($entity->allowPartialTransfers() === false) { - return \App\Response\Responses::notSupported(); - } + $item_type = Entity::itemType((int) $resource_type_id); + + return match ($item_type) { + 'allocated-expense' => $this->allocatedExpense((int) $resource_type_id, (int) $item_partial_transfer_id), + 'game', 'simple-expense', 'simple-item' => Responses::notSupported(), + default => throw new \OutOfRangeException('No item type definition for ' . $item_type, 500), + }; + } + private function allocatedExpense($resource_type_id, $item_partial_transfer_id): JsonResponse + { $item_partial_transfer = (new ItemPartialTransfer())->single( (int) $resource_type_id, (int) $item_partial_transfer_id @@ -141,36 +137,40 @@ public function optionsIndex($resource_type_id): JsonResponse \App\Response\Responses::notFoundOrNotAccessible(trans('entities.item')); } - $entity = Entity::item($resource_type_id); - if ($entity->allowPartialTransfers() === false) { - return \App\Response\Responses::notSupported(); - } + $item_type = Entity::itemType((int) $resource_type_id); - $response = new ItemPartialTransferCollection($this->permissions((int) $resource_type_id)); + return match ($item_type) { + 'allocated-expense' => $this->optionsAllocatedExpenseCollection((int) $resource_type_id), + 'game', 'simple-expense', 'simple-item' => Responses::notSupported(), + default => throw new \OutOfRangeException('No item type definition for ' . $item_type, 500), + }; + } + + private function optionsAllocatedExpenseCollection(int $resource_type_id): JsonResponse + { + $response = new AllocatedExpenseCollection($this->permissions($resource_type_id)); return $response->create()->response(); } - /** - * Generate the OPTIONS request for a specific item partial transfer - * - * @param $resource_type_id - * @param $item_partial_transfer_id - * - * @return JsonResponse - */ public function optionsShow($resource_type_id, $item_partial_transfer_id): JsonResponse { if ($this->viewAccessToResourceType((int) $resource_type_id) === false) { \App\Response\Responses::notFoundOrNotAccessible(trans('entities.item-partial-transfer')); } - $entity = Entity::item($resource_type_id); - if ($entity->allowPartialTransfers() === false) { - return \App\Response\Responses::notSupported(); - } + $item_type = Entity::itemType((int) $resource_type_id); - $response = new ItemPartialTransferItem($this->permissions((int) $resource_type_id)); + return match ($item_type) { + 'allocated-expense' => $this->optionsAllocatedExpenseShow((int) $resource_type_id), + 'game', 'simple-expense', 'simple-item' => Responses::notSupported(), + default => throw new \OutOfRangeException('No item type definition for ' . $item_type, 500), + }; + } + + private function optionsAllocatedExpenseShow(int $resource_type_id): JsonResponse + { + $response = new AllocatedExpense($this->permissions((int) $resource_type_id)); return $response->create()->response(); } @@ -185,12 +185,21 @@ public function optionsTransfer( \App\Response\Responses::notFoundOrNotAccessible(trans('entities.item')); } - $entity = Entity::item($resource_type_id); - if ($entity->allowPartialTransfers() === false) { - return \App\Response\Responses::notSupported(); - } + $item_type = Entity::itemType((int) $resource_type_id); + + return match ($item_type) { + 'allocated-expense' => $this->optionsAllocatedExpenseTransfer((int) $resource_type_id, (int) $resource_id), + 'game', 'simple-expense', 'simple-item' => Responses::notSupported(), + default => throw new \OutOfRangeException('No item type definition for ' . $item_type, 500), + }; + } - $response = new ItemPartialTransferTransfer($this->permissions((int) $resource_type_id)); + private function optionsAllocatedExpenseTransfer( + int $resource_type_id, + int $resource_id + ): JsonResponse + { + $response = new AllocatedExpenseTransfer($this->permissions($resource_type_id)); return $response->setDynamicAllowedFields( (new \App\AllowedValue\Resource())->allowedValues( diff --git a/app/Option/ItemPartialTransferItem.php b/app/Option/ItemPartialTransfer/AllocatedExpense.php similarity index 85% rename from app/Option/ItemPartialTransferItem.php rename to app/Option/ItemPartialTransfer/AllocatedExpense.php index f9ac17e1..2d4c1444 100644 --- a/app/Option/ItemPartialTransferItem.php +++ b/app/Option/ItemPartialTransfer/AllocatedExpense.php @@ -1,9 +1,11 @@ Date: Wed, 26 Jan 2022 00:02:20 +0000 Subject: [PATCH 68/73] Refactoring - Remove allow partial transfers --- app/ItemType/AllocatedExpense/Item.php | 5 ----- app/ItemType/ItemType.php | 5 ----- 2 files changed, 10 deletions(-) diff --git a/app/ItemType/AllocatedExpense/Item.php b/app/ItemType/AllocatedExpense/Item.php index 78e4b096..7d5307af 100644 --- a/app/ItemType/AllocatedExpense/Item.php +++ b/app/ItemType/AllocatedExpense/Item.php @@ -26,11 +26,6 @@ public function allowedValuesForItem(int $resource_type_id): array return (new Currency())->allowedValues(); } - public function allowPartialTransfers(): bool - { - return true; - } - public function create($id): Model { $hash = new Hash(); diff --git a/app/ItemType/ItemType.php b/app/ItemType/ItemType.php index ca981af4..0ec51136 100644 --- a/app/ItemType/ItemType.php +++ b/app/ItemType/ItemType.php @@ -75,11 +75,6 @@ public function allowedValuesForResourceTypeItemCollection( ->allowedValues(); } - public function allowPartialTransfers(): bool - { - return false; - } - abstract public function create(int $id): Model; public function dateRangeField(): ?string From 8a50fb721ded1a7cbbfa224c99b5d228184e9402 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Wed, 26 Jan 2022 00:35:33 +0000 Subject: [PATCH 69/73] Refactoring - Simplify code, remove calls to the entity class for values, additional updates to use match and switch statements where possible --- app/ItemType/Entity.php | 26 ------------------- app/Request/Parameter/Request.php | 42 ++++++++++++++----------------- 2 files changed, 19 insertions(+), 49 deletions(-) diff --git a/app/ItemType/Entity.php b/app/ItemType/Entity.php index b1ca9587..43403468 100644 --- a/app/ItemType/Entity.php +++ b/app/ItemType/Entity.php @@ -2,10 +2,6 @@ namespace App\ItemType; -use App\ItemType\AllocatedExpense\Item as AllocatedExpenseItem; -use App\ItemType\Game\Item as GameItem; -use App\ItemType\SimpleExpense\Item as SimpleExpenseItem; -use App\ItemType\SimpleItem\Item as SimpleItemItem; use App\Models\ResourceTypeItemType; class Entity @@ -20,26 +16,4 @@ public static function itemType(int $resource_type_id): string throw new \RuntimeException('No entity definition for ' . $type, 500); } - - public static function item(int $resource_type_id): ItemType - { - $type = (new ResourceTypeItemType())->itemType($resource_type_id); - - if ($type !== null) { - return self::byType($type); - } - - throw new \RuntimeException('No entity definition for ' . $type, 500); - } - - public static function byType(string $item_type): ItemType - { - return match ($item_type) { - 'allocated-expense' => new AllocatedExpenseItem(), - 'simple-expense' => new SimpleExpenseItem(), - 'simple-item' => new SimpleItemItem(), - 'game' => new GameItem(), - default => throw new \OutOfRangeException('No entity definition for ' . $item_type, 500), - }; - } } diff --git a/app/Request/Parameter/Request.php b/app/Request/Parameter/Request.php index c00f823b..b3bc03d0 100644 --- a/app/Request/Parameter/Request.php +++ b/app/Request/Parameter/Request.php @@ -146,34 +146,30 @@ private static function validate(?int $resource_type_id, ?int $resource_id): voi $max_year_limit = (int) Date('Y'); $entity_model = new EntityLimits(); - $entity = Entity::item($resource_type_id); + $item_type = Entity::itemType($resource_type_id); if ($resource_type_id !== null && $resource_id === null) { - $min_year_limit = $entity_model->minimumYearByResourceType( - $resource_type_id, - $entity->table(), - $entity->dateRangeField() - ); - $max_year_limit = $entity_model->maximumYearByResourceType( - $resource_type_id, - $entity->table(), - $entity->dateRangeField() - ); + switch ($item_type) { // Switch because there will be additional types + case 'allocated-expense': + $min_year_limit = $entity_model->minimumYearByResourceType($resource_type_id, 'item_type_allocated_expense', 'effective_date'); + $max_year_limit = $entity_model->maximumYearByResourceType($resource_type_id, 'item_type_allocated_expense', 'effective_date'); + break; + default: + // Do nothing + break; + } } if ($resource_type_id !== null && $resource_id !== null) { - $min_year_limit = $entity_model->minimumYearByResourceTypeAndResource( - $resource_type_id, - $resource_id, - $entity->table(), - $entity->dateRangeField() - ); - $max_year_limit = $entity_model->maximumYearByResourceTypeAndResource( - $resource_type_id, - $resource_id, - $entity->table(), - $entity->dateRangeField() - ); + switch ($item_type) { // Switch because there will be additional types + case 'allocated-expense': + $min_year_limit = $entity_model->minimumYearByResourceTypeAndResource($resource_type_id, $resource_id, 'item_type_allocated_expense', 'effective_date'); + $max_year_limit = $entity_model->maximumYearByResourceTypeAndResource($resource_type_id, $resource_id, 'item_type_allocated_expense', 'effective_date'); + break; + default: + // Do nothing + break; + } } if (self::$parameters[$key] < $min_year_limit || From de122789341487a883433bd8970058528b81a3d3 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Wed, 26 Jan 2022 11:04:40 +0000 Subject: [PATCH 70/73] Refactoring - Remove calls to the entity class for the date field --- app/AllowedValue/ResourceItem.php | 57 +++++++++++++---------- app/AllowedValue/ResourceTypeItem.php | 50 ++++++++++++-------- app/ItemType/AllocatedExpense/Item.php | 5 -- app/ItemType/AllowedValue.php | 55 +++++++++++++--------- app/ItemType/ItemType.php | 5 -- app/ItemType/ResourceTypeAllowedValue.php | 50 ++++++++++++-------- 6 files changed, 129 insertions(+), 93 deletions(-) diff --git a/app/AllowedValue/ResourceItem.php b/app/AllowedValue/ResourceItem.php index caf20814..95fecb70 100644 --- a/app/AllowedValue/ResourceItem.php +++ b/app/AllowedValue/ResourceItem.php @@ -193,9 +193,6 @@ function($subcategory) use (&$parameters) { return $parameters; } - /** - * @return array - */ protected function allowedValuesForYear( int $resource_type_id, int $resource_id @@ -203,27 +200,39 @@ protected function allowedValuesForYear( { $parameters = ['year' => ['allowed_values' => []]]; - for ( - $i = $this->model->minimumYearByResourceTypeAndResource( - $resource_type_id, - $resource_id, - $this->entity->table(), - $this->entity->dateRangeField() - ); - $i <= $this->model->maximumYearByResourceTypeAndResource( - $resource_type_id, - $resource_id, - $this->entity->table(), - $this->entity->dateRangeField() - ); - $i++ - ) { - $parameters['year']['allowed_values'][$i] = [ - 'value' => $i, - 'name' => $i, - 'description' => trans('item-type-' . $this->entity->type() . - '/allowed-values.description-prefix-year') . $i - ]; + $min_year = null; + $max_year = null; + + $item_type = \App\ItemType\Entity::itemType($resource_type_id); + switch($item_type) { + case 'allocated-expense': + $min_year = $this->model->minimumYearByResourceTypeAndResource( + $resource_type_id, + $resource_id, + 'item_type_allocated_expense', + 'effective_date' + ); + $max_year = $this->model->maximumYearByResourceTypeAndResource( + $resource_type_id, + $resource_id, + 'item_type_allocated_expense', + 'effective_date' + ); + break; + default: + // Do nothing + break; + } + + if ($min_year !== null && $max_year !== null) { + for ($i = $min_year; $i <= $max_year; $i++) { + $parameters['year']['allowed_values'][$i] = [ + 'value' => $i, + 'name' => $i, + 'description' => trans('item-type-' . $this->entity->type() . + '/allowed-values.description-prefix-year') . $i + ]; + } } return $parameters; diff --git a/app/AllowedValue/ResourceTypeItem.php b/app/AllowedValue/ResourceTypeItem.php index 67aede59..75b3d261 100644 --- a/app/AllowedValue/ResourceTypeItem.php +++ b/app/AllowedValue/ResourceTypeItem.php @@ -30,25 +30,37 @@ protected function allowedValuesForYear(int $resource_type_id): array { $parameters = ['year' => ['allowed_values' => []]]; - for ( - $i = $this->model->minimumYearByResourceType( - $resource_type_id, - $this->entity->table(), - $this->entity->dateRangeField() - ); - $i <= $this->model->maximumYearByResourceType( - $resource_type_id, - $this->entity->table(), - $this->entity->dateRangeField() - ); - $i++ - ) { - $parameters['year']['allowed_values'][$i] = [ - 'value' => $i, - 'name' => $i, - 'description' => trans('resource-type-item-type-' . $this->entity->type() . - '/allowed-values.description-prefix-year') . $i - ]; + $min_year = null; + $max_year = null; + + $item_type = \App\ItemType\Entity::itemType($resource_type_id); + switch ($item_type) { + case 'allocated-expense': + $min_year = $this->model->minimumYearByResourceType( + $resource_type_id, + 'item_type_allocated_expense', + 'effective_date' + ); + $max_year = $this->model->maximumYearByResourceType( + $resource_type_id, + 'item_type_allocated_expense', + 'effective_date' + ); + break; + default: + // No nothing + break; + } + + if ($min_year !== null && $max_year !== null) { + for ($i = $min_year; $i <= $max_year; $i++) { + $parameters['year']['allowed_values'][$i] = [ + 'value' => $i, + 'name' => $i, + 'description' => trans('resource-type-item-type-' . $this->entity->type() . + '/allowed-values.description-prefix-year') . $i + ]; + } } return $parameters; diff --git a/app/ItemType/AllocatedExpense/Item.php b/app/ItemType/AllocatedExpense/Item.php index 7d5307af..1ea1f3c7 100644 --- a/app/ItemType/AllocatedExpense/Item.php +++ b/app/ItemType/AllocatedExpense/Item.php @@ -54,11 +54,6 @@ public function create($id): Model return $item; } - public function dateRangeField(): ?string - { - return 'effective_date'; - } - public function instance(int $id): Model { return (new Models\Item())->instance($id); diff --git a/app/ItemType/AllowedValue.php b/app/ItemType/AllowedValue.php index 05bcc52e..ce553893 100644 --- a/app/ItemType/AllowedValue.php +++ b/app/ItemType/AllowedValue.php @@ -179,32 +179,45 @@ protected function fetchValuesForYear(): void { if (array_key_exists('year', $this->available_parameters) === true) { + $min_year = null; + $max_year = null; + + $item_type = Entity::itemType($this->resource_type_id); + switch ($item_type) { + case 'allocated-expense': + $min_year = $this->range_limits->minimumYearByResourceTypeAndResource( + $this->resource_type_id, + $this->resource_id, + 'item_type_allocated_expense', + 'effective_date' + ); + $max_year = $this->range_limits->maximumYearByResourceTypeAndResource( + $this->resource_type_id, + $this->resource_id, + 'item_type_allocated_expense', + 'effective_date' + ); + break; + default: + // Do nothing + break; + } + $allowed_values = []; - for ( - $i = $this->range_limits->minimumYearByResourceTypeAndResource( - $this->resource_type_id, - $this->resource_id, - $this->entity->table(), - $this->entity->dateRangeField() - ); - $i <= $this->range_limits->maximumYearByResourceTypeAndResource( - $this->resource_type_id, - $this->resource_id, - $this->entity->table(), - $this->entity->dateRangeField() - ); - $i++ - ) { - $allowed_values[$i] = [ - 'value' => $i, - 'name' => $i, - 'description' => trans('item-type-' . $this->entity->type() . - '/allowed-values.description-prefix-year') . $i - ]; + if ($min_year !== null && $max_year !== null) { + for ($i = $min_year; $i <= $max_year; $i++) { + $allowed_values[$i] = [ + 'value' => $i, + 'name' => $i, + 'description' => trans('item-type-' . $this->entity->type() . + '/allowed-values.description-prefix-year') . $i + ]; + } } $this->values['year'] = ['allowed_values' => $allowed_values]; + } } } diff --git a/app/ItemType/ItemType.php b/app/ItemType/ItemType.php index 0ec51136..21fd0dc5 100644 --- a/app/ItemType/ItemType.php +++ b/app/ItemType/ItemType.php @@ -77,11 +77,6 @@ public function allowedValuesForResourceTypeItemCollection( abstract public function create(int $id): Model; - public function dateRangeField(): ?string - { - return null; - } - abstract public function instance(int $id): Model; public function requestParameters(): array diff --git a/app/ItemType/ResourceTypeAllowedValue.php b/app/ItemType/ResourceTypeAllowedValue.php index 731fef57..24309286 100644 --- a/app/ItemType/ResourceTypeAllowedValue.php +++ b/app/ItemType/ResourceTypeAllowedValue.php @@ -179,25 +179,37 @@ protected function fetchValuesForYear(): void $allowed_values = []; - for ( - $i = $this->range_limits->minimumYearByResourceType( - $this->resource_type_id, - $this->entity->table(), - $this->entity->dateRangeField() - ); - $i <= $this->range_limits->maximumYearByResourceType( - $this->resource_type_id, - $this->entity->table(), - $this->entity->dateRangeField() - ); - $i++ - ) { - $allowed_values[$i] = [ - 'value' => $i, - 'name' => $i, - 'description' => trans('resource-type-item-type-' . $this->entity->type() . - '/allowed-values.description-prefix-year') . $i - ]; + $min_year = null; + $max_year = null; + + $item_type = \App\ItemType\Entity::itemType($this->resource_type_id); + switch ($item_type) { + case 'allocated-expense': + $min_year = $this->range_limits->minimumYearByResourceType( + $this->resource_type_id, + 'item_type_allocated_expense', + 'effective_date' + ); + $max_year = $this->range_limits->maximumYearByResourceType( + $this->resource_type_id, + 'item_type_allocated_expense', + 'effective_date' + ); + break; + default: + // Do nothing + break; + } + + if ($min_year !== null && $max_year !== null) { + for ($i = $min_year; $i <= $max_year; $i++) { + $allowed_values[$i] = [ + 'value' => $i, + 'name' => $i, + 'description' => trans('resource-type-item-type-' . $this->entity->type() . + '/allowed-values.description-prefix-year') . $i + ]; + } } $this->values['year'] = ['allowed_values' => $allowed_values]; From 65e985e7ec49947d21968a71fa77bd41f11b6027 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Wed, 26 Jan 2022 11:20:33 +0000 Subject: [PATCH 71/73] Refactoring - Auth controller no longer extends the app controller --- app/Http/Controllers/Authentication.php | 24 +++++++++++++++++++----- app/Http/Controllers/Controller.php | 2 +- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/Authentication.php b/app/Http/Controllers/Authentication.php index b1ce3034..613673b3 100644 --- a/app/Http/Controllers/Authentication.php +++ b/app/Http/Controllers/Authentication.php @@ -4,6 +4,7 @@ use App\Notifications\ForgotPassword; use App\Notifications\Registered; +use App\Option\Auth\Check; use App\Option\Auth\CreateNewPassword; use App\Option\Auth\CreatePassword; use App\Option\Auth\Login; @@ -22,8 +23,15 @@ use Illuminate\Support\Facades\Validator; use Illuminate\Support\Str; -class Authentication extends Controller +class Authentication extends \Illuminate\Routing\Controller { + protected \App\Request\Hash $hash; + + public function __construct() + { + $this->hash = new \App\Request\Hash(); + } + public function check(): Http\JsonResponse { return response()->json(['auth' => Auth::guard('api')->check()]); @@ -31,7 +39,7 @@ public function check(): Http\JsonResponse public function optionsCheck(): Http\JsonResponse { - $response = new \App\Option\Auth\Check([]); + $response = new Check([]); return $response->create()->response(); } @@ -412,14 +420,18 @@ public function updatePassword(Request $request): Http\JsonResponse public function optionsUpdateProfile(): Http\JsonResponse { - $response = new UpdateProfile(['view'=> $this->user_id !== null, 'manage'=> $this->user_id !== null]); + $user = auth()->guard('api')->user(); + + $response = new UpdateProfile(['view'=> $user !== null && $user->id !== null, 'manage'=> $user !== null && $user->id !== null]); return $response->create()->response(); } public function optionsUpdatePassword(): Http\JsonResponse { - $response = new UpdatePassword(['view'=> $this->user_id !== null, 'manage'=> $this->user_id !== null]); + $user = auth()->guard('api')->user(); + + $response = new UpdatePassword(['view'=> $user !== null && $user->id !== null, 'manage'=> $user !== null && $user->id !== null]); return $response->create()->response(); } @@ -500,7 +512,9 @@ public function user(): Http\JsonResponse public function optionsUser(): Http\JsonResponse { - $response = new \App\Option\Auth\User(['view'=> $this->user_id !== null]); + $user = auth()->guard('api')->user(); + + $response = new \App\Option\Auth\User(['view'=> $user !== null && $user->id !== null]); return $response->create()->response(); } diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index a26a0bc7..7236024b 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -26,7 +26,7 @@ class Controller extends BaseController protected ?int $user_id = null; /** - * @var bool Allow the entire collection to be returned ignoring pagination + * @var bool Allow the entire collection to be returned, ignoring pagination parameters */ protected bool $allow_entire_collection = false; From 9cd2a61c75f1a39103bd5718977e170550adf6bf Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Wed, 26 Jan 2022 11:35:58 +0000 Subject: [PATCH 72/73] Release - Updated the changelog and set the version and release date --- CHANGELOG.md | 39 ++++++++++++++++++++++++++++++++++++++ config/api/app/version.php | 4 ++-- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb95f637..b86eebde 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,45 @@ The complete changelog for the Costs to Expect REST API, our changelog follows the format defined at https://keepachangelog.com/en/1.0.0/ +## [v2.22.0] - 2022-01-26 +After being away from the code for a while I've made some changes. I've reduced the complexity around different items types because things had started to get a little complex and I know what is coming next so want to clear out as much unnecessary code as possible. This is just a first pass, I'm sure there will be more but I have many other planned tickets to get on with. + +### Added +- We have added additional tests for the `ResourceManage` controller. +- We have added tests for the `ResourceTypeView` controller. +- We have added a logout route. +- We have added an OPTIONS request for `/auth/create-new-password`. +- We have added an OPTIONS request for `/auth/create-password`. +- We have added an OPTIONS request for `/auth/forgot-password`. +- We have added an OPTIONS request for `/auth/login`. +- We have added an OPTIONS request for `/auth/register`. +- We have added an OPTIONS request for `/auth/update-password`. +- We have added an OPTIONS request for `/auth/update-profile`. +- We have added an OPTIONS request for `/auth/user`. +- We have added an OPTIONS request for `/auth/check`. + +### Changed +- We have made a couple of minor changes to the Docker setup. +- We have updated the README because of minor Docker changes and corrected the table layouts in the README file. +- We have updated all front-end and back-end dependencies. +- We have updated the copyright, we are now in 2022. +- We have added additional feature tests and removed some duplication in the tests, the README details the current test status. +- General refactoring, switched to method injection and logging exception messages. +- We are switching to named routes and have updated some route files, more will be updated as additional tests are created. +- We have done a quick review of each of the model classes and fixed a few tiny issues. +- We have reviewed all the `ItemType` classes, improved organisation with additional namespaces, renamed classes and methods, all with the goal being to try and make everything clearer. +- We have reviewed all item based controllers and switched to methods per item type rather than hiding all the logic in larger item classes. There is slightly more duplication but this will allow us to more easily customise each item type as new ones are added, I'm looking at you forecasting. +- We have updated the item/categories routes and will return a 405 when a category is not supported for the item type. +- We have updated the item/subcategories routes and will return a 405 when a subcategory is not supported for the item type. +- The Authentication controller no longer extends from the base app controller, it was doing some unnecessary work. + +### Fixed +- We have fixed the `delete_resource_type_success` test, wrong route. +- The `notFoundOrNotAccessible` response will optionally return a 403 if not accessible and not a 404. + +### Removed +- We have removed a few files not used by the API. + ## [v2.21.0] - 2021-04-29 ### Changed - We have updated our password requirements; the minimum length must now be 12 characters. diff --git a/config/api/app/version.php b/config/api/app/version.php index b3fe967e..f7f2486f 100644 --- a/config/api/app/version.php +++ b/config/api/app/version.php @@ -3,9 +3,9 @@ declare(strict_types=1); return [ - 'version'=> 'v2.21.0', + 'version'=> 'v2.22.0', 'prefix' => 'v2', - 'release_date' => '2021-04-29', + 'release_date' => '2022-01-26', 'changelog' => [ 'api' => '/v2/changelog', 'markdown' => 'https://github.com/costs-to-expect/api/blob/master/CHANGELOG.md' From f4f09d3b9eb3d3ec7318462399d650b578a7a65c Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Wed, 26 Jan 2022 11:42:22 +0000 Subject: [PATCH 73/73] Release - Updated the changelog on the landing page --- resources/views/welcome.blade.php | 50 +++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/resources/views/welcome.blade.php b/resources/views/welcome.blade.php index 556d3e0c..d250825f 100644 --- a/resources/views/welcome.blade.php +++ b/resources/views/welcome.blade.php @@ -222,12 +222,56 @@ function gtag(){dataLayer.push(arguments);}

The changelog below shows all the fixes and improvements we have made, to view the entire changelog please check here.

+

+ +

+ +

Added

+ +
    +
  • We have added additional tests for the `ResourceManage` controller
  • +
  • We have added tests for the `ResourceTypeView` controller
  • +
  • We have added a logout route
  • +
  • We have added an OPTIONS request for `/auth/create-new-password`
  • +
  • We have added an OPTIONS request for `/auth/create-password`
  • +
  • We have added an OPTIONS request for `/auth/forgot-password`
  • +
  • We have added an OPTIONS request for `/auth/login`
  • +
  • We have added an OPTIONS request for `/auth/register`
  • +
  • We have added an OPTIONS request for `/auth/update-password`
  • +
  • We have added an OPTIONS request for `/auth/update-profile`
  • +
  • We have added an OPTIONS request for `/auth/user`
  • +
  • We have added an OPTIONS request for `/auth/check`
  • +
+

Changed

    -
  • We have updated our password requirements; the minimum length must now be 12 characters.
  • -
  • We have updated our back-end dependencies.
  • -
  • Cache clear jobs are dispatched immediately; we no longer delay items in the queue.
  • +
  • We have made a couple of minor changes to the Docker setup
  • +
  • We have updated the README because of minor Docker changes and corrected the table layouts in the README file
  • +
  • We have updated all front-end and back-end dependencies
  • +
  • We have updated the copyright, we are now in 2022
  • +
  • We have added additional feature tests and removed some duplication in the tests, the README details the current test status
  • +
  • General refactoring, switched to method injection and logging exception messages
  • +
  • We are switching to named routes and have updated some of the route files, more will be updated as additional tests are created
  • +
  • We have done a quick review of each of the model classes and fixed a few tiny issues
  • +
  • We have reviewed all the `ItemType` classes, improved organisation with additional namespaces, renamed classes and methods, all with the goal being to try and make everything clearer
  • +
  • We have reviewed all item based controllers and switched to methods per item type rather than hiding all the logic in larger item classes. There is slightly more duplication but this will allow us to more easily customise each item type as new ones are added, I'm looking at you forecasting
  • +
  • We have updated the item/categories routes and will return a 405 when a category is not supported for the item type
  • +
  • We have updated the item/subcategories routes and will return a 405 when a subcategory is not supported for the item type
  • +
  • The Authentication controller no longer extends from the base app controller, it was doing some unnecessary work
  • +
+ +

Fixed

+ +
    +
  • We have fixed the `delete_resource_type_success` test, wrong route
  • +
  • The `notFoundOrNotAccessible` response will optionally return a 403 if not accessible and not a 404
  • +
+ +

Removed

+ +
    +
  • We have removed a few files not used by the API