Skip to content

Commit

Permalink
Redirect link for bulk actions
Browse files Browse the repository at this point in the history
  • Loading branch information
burakcakirel committed Jul 30, 2021
1 parent b748d44 commit cd446ec
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 9 additions & 0 deletions app/Http/Controllers/Common/BulkActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Abstracts\Http\Controller;
use App\Http\Requests\Common\BulkAction as Request;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Str;

class BulkActions extends Controller
Expand Down Expand Up @@ -57,6 +58,14 @@ public function action($group, $type, Request $request)

if (!empty($result) && ($result instanceof \Symfony\Component\HttpFoundation\BinaryFileResponse)) {
return $result;
} elseif (!empty($result) && ($result instanceof RedirectResponse)) {
return response()->json([
'success' => true,
'redirect' => $result->getTargetUrl(),
'error' => false,
'data' => [],
'message' => ''
]);
} else {
return response()->json([
'success' => true,
Expand Down
4 changes: 3 additions & 1 deletion resources/assets/js/plugins/bulk-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,10 @@ export default class BulkAction {
}));

type_promise.then(response => {
if (response.data.redirect) {
if (response.data.redirect === true) {
window.location.reload(false);
} else if (typeof response.data.redirect === 'string') {
window.location.href = response.data.redirect;
}
})
.catch(error => {
Expand Down

0 comments on commit cd446ec

Please sign in to comment.