Skip to content

Commit 72d380a

Browse files
Merge pull request #229 from jitendra-webkul/master
Issue #217 fixed
2 parents ae0c316 + da112c4 commit 72d380a

File tree

2 files changed

+28
-16
lines changed

2 files changed

+28
-16
lines changed

packages/Webkul/Admin/src/Exceptions/Handler.php

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,8 @@ class Handler extends AppExceptionHandler
2828
*/
2929
public function render($request, Throwable $exception)
3030
{
31-
$path = $this->isAdminUri() ? 'admin' : 'front';
32-
33-
if ($path == "front") {
34-
return redirect()->route('admin.session.create');
35-
}
36-
37-
if ($exception instanceof HttpException) {
38-
$statusCode = in_array($exception->getStatusCode(), [401, 403, 404, 503]) ? $exception->getStatusCode() : 500;
39-
40-
return $this->response($path, $statusCode);
41-
} elseif ($exception instanceof ModelNotFoundException) {
42-
return $this->response($path, 404);
43-
} elseif ($exception instanceof PDOException) {
44-
return $this->response($path, 500);
31+
if (! config('app.debug')) {
32+
return $this->renderCustomResponse($request, $exception);
4533
}
4634

4735
return parent::render($request, $exception);
@@ -68,6 +56,32 @@ private function isAdminUri()
6856
return strpos(Request::path(), 'admin') !== false ? true : false;
6957
}
7058

59+
/**
60+
* Render custom HTTP response.
61+
*
62+
* @param \Illuminate\Http\Request $request
63+
* @param \Throwable $exception
64+
* @return \Illuminate\Http\Response|null
65+
*/
66+
private function renderCustomResponse($request, Throwable $exception)
67+
{
68+
$path = $this->isAdminUri() ? 'admin' : 'front';
69+
70+
if ($path == "front") {
71+
return redirect()->route('admin.session.create');
72+
}
73+
74+
if ($exception instanceof HttpException) {
75+
$statusCode = in_array($exception->getStatusCode(), [401, 403, 404, 503]) ? $exception->getStatusCode() : 500;
76+
77+
return $this->response($path, $statusCode);
78+
} elseif ($exception instanceof ModelNotFoundException) {
79+
return $this->response($path, 404);
80+
} elseif ($exception instanceof PDOException) {
81+
return $this->response($path, 500);
82+
}
83+
}
84+
7185
private function response($path, $statusCode)
7286
{
7387
if (request()->expectsJson()) {

packages/Webkul/Admin/src/Resources/views/contacts/organizations/create.blade.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@
4242
{!! view_render_event('admin.contacts.organizations.create.form_controls.before') !!}
4343

4444
@csrf()
45-
46-
<input name="_method" type="hidden" value="PUT">
4745

4846
@include('admin::common.custom-attributes.edit', [
4947
'customAttributes' => app('Webkul\Attribute\Repositories\AttributeRepository')->findWhere([

0 commit comments

Comments
 (0)