mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 05:34:06 -08:00
Check for Carbon exception
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
79a8effa25
commit
afd01869a5
|
@ -10,7 +10,7 @@ use ArieTimmerman\Laravel\SCIMServer\Exceptions\SCIMException;
|
||||||
use Log;
|
use Log;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
use JsonException;
|
use JsonException;
|
||||||
|
use Carbon\Exceptions\InvalidFormatException;
|
||||||
|
|
||||||
class Handler extends ExceptionHandler
|
class Handler extends ExceptionHandler
|
||||||
{
|
{
|
||||||
|
@ -69,16 +69,25 @@ class Handler extends ExceptionHandler
|
||||||
// Invalid JSON exception
|
// Invalid JSON exception
|
||||||
// TODO: don't understand why we have to do this when we have the invalidJson() method, below, but, well, whatever
|
// TODO: don't understand why we have to do this when we have the invalidJson() method, below, but, well, whatever
|
||||||
if ($e instanceof JsonException) {
|
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) {
|
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
|
// Handle Ajax requests that fail because the model doesn't exist
|
||||||
if ($request->ajax() || $request->wantsJson()) {
|
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) {
|
if ($e instanceof \Illuminate\Database\Eloquent\ModelNotFoundException) {
|
||||||
$className = last(explode('\\', $e->getModel()));
|
$className = last(explode('\\', $e->getModel()));
|
||||||
return response()->json(Helper::formatStandardApiResponse('error', null, $className . ' not found'), 200);
|
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' )) {
|
if ($this->isHttpException($e) && (isset($statusCode)) && ($statusCode == '404' )) {
|
||||||
return response()->view('layouts/basic', [
|
return response()->view('layouts/basic', [
|
||||||
'content' => view('errors/404')
|
'content' => view('errors/404')
|
||||||
|
|
|
@ -33,9 +33,9 @@ class License extends Depreciable
|
||||||
protected $table = 'licenses';
|
protected $table = 'licenses';
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'purchase_date' => 'datetime',
|
'purchase_date' => 'date',
|
||||||
'expiration_date' => 'datetime',
|
'expiration_date' => 'date',
|
||||||
'termination_date' => 'datetime',
|
'termination_date' => 'date',
|
||||||
'category_id' => 'integer',
|
'category_id' => 'integer',
|
||||||
'company_id' => 'integer',
|
'company_id' => 'integer',
|
||||||
];
|
];
|
||||||
|
|
|
@ -77,7 +77,7 @@
|
||||||
<div class="form-group {{ $errors->has('expiration_date') ? ' has-error' : '' }}">
|
<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>
|
<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">
|
<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) }}">
|
<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>
|
<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' : '' }}">
|
<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>
|
<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">
|
<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) }}">
|
<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>
|
<span class="input-group-addon"><i class="fas fa-calendar" aria-hidden="true"></i></span>
|
||||||
|
|
Loading…
Reference in a new issue