Skip to content

Commit

Permalink
#100. Change exception on deleteBulk to Json::error
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurkushman committed Aug 18, 2018
1 parent 8b05e2a commit 7a82f45
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/blocks/EntitiesTrait.php
Expand Up @@ -6,7 +6,6 @@
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\DB;
use League\Fractal\Resource\ResourceAbstract;
use rjapi\exceptions\AttributesException;
use rjapi\extension\ApiController;
use rjapi\extension\BaseFormRequest;
use rjapi\extension\BaseModel;
Expand Down Expand Up @@ -162,7 +161,6 @@ protected function mutateBulk(array $jsonApiAttributes) : ResourceAbstract

/**
* @param array $jsonApiAttributes
* @throws AttributesException
*/
public function removeBulk(array $jsonApiAttributes) : void
{
Expand All @@ -174,7 +172,14 @@ public function removeBulk(array $jsonApiAttributes) : void

if ($model === null) {
DB::rollBack();
throw new AttributesException('There is no such id: ' . $jsonObject[JSONApiInterface::CONTENT_ID] . ' or model was already deleted - transaction has been rolled back.');
Json::outputErrors(
[
[
JSONApiInterface::ERROR_TITLE => 'There is no such id: ' . $jsonObject[JSONApiInterface::CONTENT_ID],
JSONApiInterface::ERROR_DETAIL => 'There is no such id: ' . $jsonObject[JSONApiInterface::CONTENT_ID] . ' or model was already deleted - transaction has been rolled back.'
],
]
);
}

$model->delete();
Expand Down
1 change: 0 additions & 1 deletion src/extension/BaseController.php
Expand Up @@ -60,7 +60,6 @@ public function updateBulk(Request $request)
*
* @param Request $request
* @throws \LogicException
* @throws \rjapi\exceptions\AttributesException
*/
public function deleteBulk(Request $request)
{
Expand Down

0 comments on commit 7a82f45

Please sign in to comment.