I was working on the project and had almost completed it, by then all the sudden my manager told to change the URL prefixes of a few modules of the project. I was searching for routes and replacing them manually. It was a pain in the ass to go and change in all the places.
Then I came across Laravel Named Routes and how it saved me and will save me in future from this kind of situation too.
Named routes allow you to generate URLs without being coupled to the actual URL defined on the route.
Route::get('/auth/login', [AuthController::class, 'login']);
Route::get('/auth/login', [AuthController::class, 'login'])->name('login');
Instead of
{{ url('/auth/login') }}
{{ route('/auth/login') }}
Route::post('/payments/payment-success/{event}', [PaymentController::class, 'store']);
Route::post('/payments/payment-success/{event}', [PaymentController::class, 'store'])->name('payment-success');
{{ url('payments/payment-success/' . $event->id) }}
{{ route('payments/payment-success', ['event' => $event->id]) }}
Route::get('/post/{post}/comment/{comment}', [PostController::class, 'show'])->name('comment.show');
{{ route('comment.show', ['post' => 1, 'comment' => 3]) }}
// http://example.com/post/1/comment/3
route('post.show', ['post' => 1, 'search' => 'rocket']);
// http://example.com/post/1?search=rocket
PHP Built-In Web Server & Testing Your Development Project In Mobile Without Any Software
Push Files To CPanel / Remote Server using FTP Software FileZilla
What Is Method Chaining In PHP?
Debugging Laravel Queue Email Issues
Client-Side Form Validation With Javascript
Laravel Clear Cache Of Route, View, Config Command
SQLite Doesn't Support Dropping Foreign Keys in Laravel
Custom Validation Rules In PHP Laravel (Using Artisan Command)
URL Redirects From Called Functions In Laravel
Generate Sitemap in PHP Laravel