Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…o-expect-api into v2.03.0
  • Loading branch information
deanblackborough committed Nov 10, 2019
2 parents a769773 + f78b402 commit ef1b0d9
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 21 deletions.
10 changes: 5 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ The complete changelog for the Costs to Expect REST API, follows the format defi

## [v2.04.0] - 2019-11-xx
### Added
- We have added a GitHub callout to the top right corner of the website, courtesy of https://github.com/tholman/github-corners.
- We have added a GitHub callout to the top right corner of the API landing page, courtesy of https://github.com/tholman/github-corners.

### Changed
- We have updated the code to ensure the data arrays in the config files get used whenever possible; minor data arrays for parameters defined in two locations.
- We have added additional summary models.
- We have moved the item and resource type item models, now organised by namespace, not filename.
- We have moved the item and resource type item transformers, now organised by namespace, not the filename.
- We have moved all the `existsToUser` methods out of the `item` models and into the `PermittedUser` model.
- We have updated the `item` and `resource type item `summary routes; they respect the chosen resource type (Allocated expenses and Simple expenses) and provide the relevant summary.
- We have moved the item and resource type item models, now organised by namespace, not the class filename.
- We have moved the item and resource type item transformers, now organised by namespace, not the class filename.
- We have moved all the `existsToUser` methods out of the `item` models and into a `PermittedUser` model.
- We have updated the `item` and `resource type item` summary routes; they respect the chosen resource type (Allocated expenses and Simple expenses) and provide the relevant summary.

### Fixed
- We have corrected several more class names, incorrect capitalisation.
Expand Down
1 change: 0 additions & 1 deletion app/Models/ResourceTypeItemType/Summary/SimpleExpense.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

namespace App\Models\ResourceTypeItemType\Summary;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Query\Builder as QueryBuilder;
use Illuminate\Support\Facades\DB;
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Summary/ItemType/SimpleExpense.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function filteredSummary(
{
$collection = $this->
selectRaw("SUM({$this->sub_table}.total) AS total")->
join($this->sub_table, 'item.id', 'item_type_allocated_expense.item_id')->
join($this->sub_table, 'item.id', "{$this->sub_table}.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")->
Expand Down
56 changes: 42 additions & 14 deletions app/Utilities/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ static public function notFound(?string $type = null, ?Exception $e = null): Jso
trans('responses.not-found')
];

$response = self::addException($response, $e);
if ($e instanceOf Exception) {
$response = self::addException($response, $e);
}

response()->json(
$response,
Expand All @@ -76,7 +78,9 @@ static public function notFoundOrNotAccessible(?string $type = null, ?Exception
trans('responses.not-found')
];

$response = self::addException($response, $e);
if ($e instanceOf Exception) {
$response = self::addException($response, $e);
}

response()->json(
$response,
Expand All @@ -99,7 +103,9 @@ static public function foreignKeyConstraintError($message = '', ?Exception $e =
'message' => (strlen($message) > 0) ? $message : trans('responses.constraint')
];

$response = self::addException($response, $e);
if ($e instanceOf Exception) {
$response = self::addException($response, $e);
}

response()->json(
$response,
Expand All @@ -124,7 +130,9 @@ static public function failedToSelectModelForUpdate(?Exception $e = null): JsonR
'message' => trans('responses.model-select-failure'),
];

$response = self::addException($response, $e);
if ($e instanceOf Exception) {
$response = self::addException($response, $e);
}

response()->json(
$response,
Expand All @@ -149,7 +157,9 @@ static public function failedToSaveModelForUpdate(?Exception $e = null): JsonRes
'message' => trans('responses.model-save-failure-update'),
];

$response = self::addException($response, $e);
if ($e instanceOf Exception) {
$response = self::addException($response, $e);
}

response()->json(
$response,
Expand All @@ -171,7 +181,9 @@ static public function authenticationRequired(?Exception $e = null): JsonRespons
'message' => trans('responses.authentication-required')
];

$response = self::addException($response, $e);
if ($e instanceOf Exception) {
$response = self::addException($response, $e);
}

response()->json(
$response,
Expand All @@ -196,7 +208,9 @@ static public function failedToSaveModelForCreate(?Exception $e = null): JsonRes
'message' => trans('responses.model-save-failure-create'),
];

$response = self::addException($response, $e);
if ($e instanceOf Exception) {
$response = self::addException($response, $e);
}

response()->json(
$response,
Expand All @@ -219,7 +233,9 @@ static public function unableToDecode(?Exception $e = null): JsonResponse
'message' => trans('responses.decode-error')
];

$response = self::addException($response, $e);
if ($e instanceOf Exception) {
$response = self::addException($response, $e);
}

response()->json(
$response,
Expand All @@ -239,7 +255,9 @@ static public function successNoContent(?Exception $e = null): JsonResponse
{
$response = [];

$response = self::addException($response, $e);
if ($e instanceOf Exception) {
$response = self::addException($response, $e);
}

response()->json($response,204)->send();
exit;
Expand All @@ -257,7 +275,9 @@ static public function successEmptyContent(bool $array = false, ?Exception $e =
{
$response = ($array === true ? [] : null);

$response = self::addException($response, $e);
if ($e instanceOf Exception) {
$response = self::addException($response, $e);
}

response()->json($response,200)->send();
exit;
Expand All @@ -276,7 +296,9 @@ static public function nothingToPatch(?Exception $e = null)
'message' => trans('responses.patch-empty')
];

$response = self::addException($response, $e);
if ($e instanceOf Exception) {
$response = self::addException($response, $e);
}

response()->json(
$response,
Expand All @@ -300,7 +322,9 @@ static public function invalidFieldsInRequest(array $invalid_fields, ?Exception
'fields' => $invalid_fields
];

$response = self::addException($response, $e);
if ($e instanceOf Exception) {
$response = self::addException($response, $e);
}

response()->json(
$response,
Expand All @@ -322,7 +346,9 @@ static public function maintenance(?Exception $e = null): JsonResponse
'message' => trans('responses.maintenance')
];

$response = self::addException($response, $e);
if ($e instanceOf Exception) {
$response = self::addException($response, $e);
}

response()->json(
$response,
Expand All @@ -346,7 +372,9 @@ static public function validationErrors(array $validation_errors, ?Exception $e
'fields' => $validation_errors
];

$response = self::addException($response, $e);
if ($e instanceOf Exception) {
$response = self::addException($response, $e);
}

response()->json(
$response,
Expand Down

0 comments on commit ef1b0d9

Please sign in to comment.