If you need public URL but you want them to be secured

If you need public URL but you want them to be secured, use Laravel signed URL

1class AccountController extends Controller
2{
3 public function destroy(Request $request)
4 {
5 $confirmDeleteUrl = URL::signedRoute('confirm-destroy', [
6 $user => $request->user()
7 ]);
8 // Send link by email...
9 }
10 
11 public function confirmDestroy(Request $request, User $user)
12 {
13 if (! $request->hasValidSignature()) {
14 abort(403);
15 }
16 
17 // User confirmed by clikcing on the email
18 $user->delete();
19 
20 return redirect()->route('home');
21 }
22}

Tip given by @anwar_nairi

Like our articles?

Become a Premium Member for $129/year or $29/month
What else you will get:
  • 22 courses (477 lessons, total 38 h 20 min)
  • 2 long-form tutorials (one new every week)
  • access to project repositories
  • access to private Discord