public function create(Request $request)
{
$this->validate($request, [
- 'image' => 'required|string',
- 'uploaded_to' => 'required|integer',
+ 'image' => ['required', 'string'],
+ 'uploaded_to' => ['required', 'integer'],
]);
$this->checkPermission('image-create-all');
*/
public function getAsBase64($id)
{
- $image = $this->imageRepo->getById($id);
- if (is_null($image) || $image->type !== 'drawio' || !userCan('page-view', $image->getPage())) {
- return $this->jsonError('Image data could not be found');
+ try {
+ $image = $this->imageRepo->getById($id);
+ } catch (Exception $exception) {
+ return $this->jsonError(trans('errors.drawing_data_not_found'), 404);
+ }
+
+ if ($image->type !== 'drawio' || !userCan('page-view', $image->getPage())) {
+ return $this->jsonError(trans('errors.drawing_data_not_found'), 404);
}
$imageData = $this->imageRepo->getImageData($image);
if (is_null($imageData)) {
- return $this->jsonError('Image data could not be found');
+ return $this->jsonError(trans('errors.drawing_data_not_found'), 404);
}
return response()->json([