Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

156
Views
Laravel delete user returns link with ID

I am making a 1 page CRUD application in laravel, Whenever i delete a user i just edited, I get a blank page or a 404. I suppose this happens because the link it returns is: admin/user/{id}. I want to return the base url: admin/user Without the {id} at the end. Is there any way i can do this?

controller destroy code:

public function destroy($id)
    {
       $user = User::find($id);
       $user->delete();
       return back();
    }
almost 4 years ago ยท Santiago Trujillo
1 answers
Answer question

0

Once the record is deleted, then you can't get that record.

If you want to return back then redirect on specific route.

public function destroy($id)
{
    $user = User::find($id);
    $user->delete();
    return redirect()->route('admin.user')->with('success', 'Your success message');
}

also, you can display the flash message when your URL redirect on page.

Happy Coding!!! ๐Ÿš€

almost 4 years ago ยท Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
ยฉ 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!