diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 65a13edb2e..1878025217 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -10,7 +10,7 @@ use ArieTimmerman\Laravel\SCIMServer\Exceptions\SCIMException; use Log; use Throwable; use JsonException; - +use Carbon\Exceptions\InvalidFormatException; class Handler extends ExceptionHandler { @@ -69,16 +69,25 @@ class Handler extends ExceptionHandler // Invalid JSON exception // TODO: don't understand why we have to do this when we have the invalidJson() method, below, but, well, whatever if ($e instanceof JsonException) { - return response()->json(Helper::formatStandardApiResponse('error', null, 'invalid JSON'), 422); + return response()->json(Helper::formatStandardApiResponse('error', null, 'Invalid JSON'), 422); } if ($e instanceof SCIMException) { - return response()->json(Helper::formatStandardApiResponse('error', null, 'invalid SCIM Request'), 400); + return response()->json(Helper::formatStandardApiResponse('error', null, 'Invalid SCIM Request'), 400); + } + + if ($e instanceof InvalidFormatException) { + return redirect()->back()->with('error', trans('validation.date', ['attribute' => 'date'])); } // Handle Ajax requests that fail because the model doesn't exist if ($request->ajax() || $request->wantsJson()) { + if ($e instanceof InvalidFormatException) { + return response()->json(Helper::formatStandardApiResponse('error', null, trans('validation.date')), 200); + } + + if ($e instanceof \Illuminate\Database\Eloquent\ModelNotFoundException) { $className = last(explode('\\', $e->getModel())); return response()->json(Helper::formatStandardApiResponse('error', null, $className . ' not found'), 200); @@ -103,6 +112,8 @@ class Handler extends ExceptionHandler } + + if ($this->isHttpException($e) && (isset($statusCode)) && ($statusCode == '404' )) { return response()->view('layouts/basic', [ 'content' => view('errors/404') diff --git a/app/Models/License.php b/app/Models/License.php index 94263ee0d8..41a3d7a52a 100755 --- a/app/Models/License.php +++ b/app/Models/License.php @@ -33,9 +33,9 @@ class License extends Depreciable protected $table = 'licenses'; protected $casts = [ - 'purchase_date' => 'datetime', - 'expiration_date' => 'datetime', - 'termination_date' => 'datetime', + 'purchase_date' => 'date', + 'expiration_date' => 'date', + 'termination_date' => 'date', 'category_id' => 'integer', 'company_id' => 'integer', ]; diff --git a/resources/views/licenses/edit.blade.php b/resources/views/licenses/edit.blade.php index efc10cec51..f45e69ce96 100755 --- a/resources/views/licenses/edit.blade.php +++ b/resources/views/licenses/edit.blade.php @@ -77,7 +77,7 @@
-
+
@@ -91,7 +91,7 @@
-
+