EbrahemSamer
4 months ago
184
2
Laravel

How to control in redirect function depends on the clicked button?

Posted 4 months ago by EbrahemSamer

I can delete users from two pages dashboard page and users page.

when I delete user from users page the page returns back to users page and the same thing happen whien i delete it from dashboard.

What I want is when i delete user from dashboard the page returns to dashboard not users.

// delete user function

public function destroy(User $user)
{
    if($user->emp_type == "employee") {
        $user->userprofile->delete();
    }else {
        $user->companyprofile->delete();
    }
    $user->delete();
    return redirect()->route('users.index')->withStatus(__('User successfully deleted.'));
}

Please sign in or create an account to participate in this conversation.