A free open source IT asset/license management system
Check for Carbon exception
snipeafd01869a52f
diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.phpindex 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, whateverif ($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 existif ($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.phpindex 94263ee0d8..41a3d7a52a 100755--- a/app/Models/License.php+++ b/app/Models/License.php@@ -33,9 +33,9 @@ class License extends Depreciableprotected $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.phpindex efc10cec51..f45e69ce96 100755--- a/resources/views/licenses/edit.blade.php+++ b/resources/views/licenses/edit.blade.php@@ -77,7 +77,7 @@<div class="form-group {{ $errors->has('expiration_date') ? ' has-error' : '' }}"><label for="expiration_date" class="col-md-3 control-label">{{ trans('admin/licenses/form.expiration') }}</label>- <div class="input-group col-md-3">+ <div class="input-group col-md-4"><div class="input-group date" data-provide="datepicker" data-date-format="yyyy-mm-dd" data-autoclose="true" data-date-clear-btn="true"><input type="text" class="form-control" placeholder="{{ trans('general.select_date') }}" name="expiration_date" id="expiration_date" value="{{ old('expiration_date', $item->expiration_date) }}"><span class="input-group-addon"><i class="fas fa-calendar" aria-hidden="true"></i></span>@@ -91,7 +91,7 @@<div class="form-group {{ $errors->has('termination_date') ? ' has-error' : '' }}"><label for="termination_date" class="col-md-3 control-label">{{ trans('admin/licenses/form.termination_date') }}</label>- <div class="input-group col-md-3">+ <div class="input-group col-md-4"><div class="input-group date" data-provide="datepicker" data-date-format="yyyy-mm-dd" data-autoclose="true" data-date-clear-btn="true"><input type="text" class="form-control" placeholder="{{ trans('general.select_date') }}" name="termination_date" id="termination_date" value="{{ old('termination_date', $item->termination_date) }}"><span class="input-group-addon"><i class="fas fa-calendar" aria-hidden="true"></i></span>