Skip to content

Commit

Permalink
resolved conflicts.
Browse files Browse the repository at this point in the history
  • Loading branch information
suraj-webkul committed Sep 26, 2024
2 parents c8bdaa6 + df659e3 commit 47d9f9e
Show file tree
Hide file tree
Showing 44 changed files with 635 additions and 465 deletions.
36 changes: 11 additions & 25 deletions packages/Webkul/Admin/src/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,6 @@ public function render($request, Throwable $exception)
return parent::render($request, $exception);
}

/**
* Report the exception.
*
* @return void
*/
public function report(Throwable $exception)
{
//
}

/**
* Convert an authentication exception into a response.
*
Expand All @@ -84,48 +74,44 @@ protected function unauthenticated($request, AuthenticationException $exception)
*/
private function renderCustomResponse(Throwable $exception)
{
$path = request()->routeIs('admin.*') ? 'admin' : 'front';

if ($path == 'front') {
return redirect()->route('admin.session.create');
}

if ($exception instanceof HttpException) {
$statusCode = in_array($exception->getStatusCode(), [401, 403, 404, 503])
? $exception->getStatusCode()
: 500;

return $this->response($path, $statusCode);
return $this->response($statusCode);
}

if ($exception instanceof ValidationException) {
return parent::render(request(), $exception);
}

if ($exception instanceof ModelNotFoundException) {
return $this->response($path, 404);
return $this->response(404);
} elseif ($exception instanceof PDOException || $exception instanceof \ParseError) {
return $this->response($path, 500);
return $this->response(500);
} else {
return $this->response(500);
}
}

/**
* Return custom response.
*
* @param string $path
* @param string $statusCode
* @param string $errorCode
* @return mixed
*/
private function response($path, $statusCode)
private function response($errorCode)
{
if (request()->expectsJson()) {
return response()->json([
'message' => isset($this->jsonErrorMessages[$statusCode])
? $this->jsonErrorMessages[$statusCode]
'message' => isset($this->jsonErrorMessages[$errorCode])
? $this->jsonErrorMessages[$errorCode]
: trans('admin::app.common.something-went-wrong'),
], $statusCode);
], $errorCode);
}

return response()->view("{$path}::errors.{$statusCode}", [], $statusCode);
return response()->view('admin::errors.index', compact('errorCode'));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Webkul\Activity\Repositories\FileRepository;
use Webkul\Admin\DataGrids\Activity\ActivityDataGrid;
use Webkul\Admin\Http\Controllers\Controller;
use Webkul\Admin\Http\Requests\MassDestroyRequest;
use Webkul\Admin\Http\Requests\MassUpdateRequest;
use Webkul\Admin\Http\Resources\ActivityResource;
use Webkul\Attribute\Repositories\AttributeRepository;
Expand Down Expand Up @@ -184,9 +185,13 @@ public function massUpdate(MassUpdateRequest $massUpdateRequest): JsonResponse
*/
public function download(int $id): StreamedResponse
{
$file = $this->fileRepository->findOrFail($id);
try {
$file = $this->fileRepository->findOrFail($id);

return Storage::download($file->path);
return Storage::download($file->path);
} catch (\Exception $exception) {
abort(404);
}
}

/*
Expand Down Expand Up @@ -216,9 +221,9 @@ public function destroy(int $id): JsonResponse
/**
* Mass Delete the specified resources.
*/
public function massDestroy(MassUpdateRequest $massUpdateRequest): JsonResponse
public function massDestroy(MassDestroyRequest $massDestroyRequest): JsonResponse
{
$activities = $this->activityRepository->findWhereIn('id', $massUpdateRequest->input('indices'));
$activities = $this->activityRepository->findWhereIn('id', $massDestroyRequest->input('indices'));

try {
foreach ($activities as $activity) {
Expand All @@ -230,11 +235,11 @@ public function massDestroy(MassUpdateRequest $massUpdateRequest): JsonResponse
}

return response()->json([
'message' => trans('admin::app.response.destroy-success'),
'message' => trans('admin::app.activities.mass-destroy-success'),
]);
} catch (\Exception $exception) {
return response()->json([
'message' => trans('admin::app.response.destroy-failed'),
'message' => trans('admin::app.activities.mass-delete-failed'),
], 400);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ public function get(): JsonResponse

$stage->lead_value = (clone $query)->sum('lead_value');

$data[$stage->id] = (new StageResource($stage))->jsonSerialize();
$data[$stage->sort_order] = (new StageResource($stage))->jsonSerialize();

$data[$stage->id]['leads'] = [
$data[$stage->sort_order]['leads'] = [
'data' => LeadResource::collection($paginator = $query->with([
'tags',
'type',
Expand Down
Loading

0 comments on commit 47d9f9e

Please sign in to comment.