diff --git a/helpers/helpers.php b/helpers/helpers.php index 546e23b..77a506a 100644 --- a/helpers/helpers.php +++ b/helpers/helpers.php @@ -15,7 +15,7 @@ function APIUser() * * @deprecated Use Helpers.php * - * @param $array + * @param $array * @param int|null $levels How many levels of an array keys to transform - by default recurse infinitely (null) * @return array $array */ @@ -31,7 +31,7 @@ function camel_case_array_keys($array, $levels = null) * * @deprecated Use Helpers.php * - * @param $array + * @param $array * @param int|null $levels How many levels of an array keys to transform - by default recurse infinitely (null) * @return array $array */ diff --git a/src/APIHelpers.php b/src/APIHelpers.php index 8b49b9d..52c0519 100644 --- a/src/APIHelpers.php +++ b/src/APIHelpers.php @@ -9,7 +9,7 @@ class APIHelpers /** * Recursively camel-case an array's keys * - * @param $array + * @param $array * @param int|null $levels How many levels of an array keys to transform - by default recurse infinitely (null) * @return array $array */ @@ -42,7 +42,7 @@ public static function camelCaseArrayKeys($array, $levels = null) /** * Recursively snake-case an array's keys * - * @param $array + * @param $array * @param int|null $levels How many levels of an array keys to transform - by default recurse infinitely (null) * @return array $array */ diff --git a/src/Http/Controllers/Features/RestfulControllerTrait.php b/src/Http/Controllers/Features/RestfulControllerTrait.php index 38b953d..6b84fe4 100644 --- a/src/Http/Controllers/Features/RestfulControllerTrait.php +++ b/src/Http/Controllers/Features/RestfulControllerTrait.php @@ -107,7 +107,7 @@ protected function shouldTransform() * Useful for adding error info to internal request responses before returning them * * @param \Dingo\Api\Http\Response $response - * @param $message + * @param $message * @return \Dingo\Api\Http\Response */ protected function prependResponseMessage($response, $message) @@ -122,8 +122,8 @@ protected function prependResponseMessage($response, $message) /** * Try to find the relation name of the child model in the parent model * - * @param $parent Object Parent model instance - * @param $child string Child model name + * @param $parent Object Parent model instance + * @param $child string Child model name * @return null|string */ protected function getChildRelationNameForParent($parent, $child) diff --git a/src/Http/Controllers/RestfulChildController.php b/src/Http/Controllers/RestfulChildController.php index 9a0ac9b..5622f2d 100644 --- a/src/Http/Controllers/RestfulChildController.php +++ b/src/Http/Controllers/RestfulChildController.php @@ -30,11 +30,11 @@ class RestfulChildController extends BaseRestfulController * @var array */ public $parentAbilitiesRequired = [ - 'create' => 'update', - 'view' => 'view', - 'viewAll' => 'view', - 'update' => 'own', - 'delete' => 'own', + 'create' => 'update', + 'view' => 'view', + 'viewAll' => 'view', + 'update' => 'own', + 'delete' => 'own', ]; /** diff --git a/src/Services/RestfulService.php b/src/Services/RestfulService.php index e6a26a1..25ff098 100644 --- a/src/Services/RestfulService.php +++ b/src/Services/RestfulService.php @@ -7,6 +7,7 @@ use Illuminate\Http\Request; use Illuminate\Support\Str; use Illuminate\Database\QueryException; +use Illuminate\Support\Facades\Log; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException; use Symfony\Component\HttpKernel\Exception\ConflictHttpException; @@ -51,8 +52,8 @@ public function setModel($model) /** * Deletes resources of the given model and uuid(s) * - * @param $model string Model class name - * @param $uuid string|array The UUID(s) of the models to remove + * @param $model string Model class name + * @param $uuid string|array The UUID(s) of the models to remove * @return mixed */ public function delete($model, $uuid) @@ -82,6 +83,9 @@ public function patch($model, array $data) try { $resource = $model->update($data); } catch (\Exception $e) { + // Log this as an unexpected exception, useful if API debug is off + Log::error('Error updating resource ' . get_class($model) . ': ' . $e->getMessage()); + // Check for QueryException - if so, we may want to display a more meaningful message, or help with // development debugging if ($e instanceof QueryException) { @@ -108,8 +112,8 @@ public function patch($model, array $data) /** * Create model in the database * - * @param $model - * @param $data + * @param $model + * @param $data * @return mixed */ public function persistResource(RestfulModel $resource) @@ -117,6 +121,9 @@ public function persistResource(RestfulModel $resource) try { $resource->save(); } catch (\Exception $e) { + // Log this as an unexpected exception, useful if API debug is off + Log::error('Error persisting resource ' . get_class($resource) . ': ' . $e->getMessage()); + // Check for QueryException - if so, we may want to display a more meaningful message, or help with // development debugging if ($e instanceof QueryException) {