Good content takes time and effort to come up with.
Please consider supporting us by just disabling your AD BLOCKER and reloading this page again.
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
Accessors And Mutators In PHP Laravel
Foreign Key Migrations Simplified In Laravel 7.x
Stripe Payment Integration With Laravel
Move Uploaded Files From Local Computer Or Server To Amazon S3 Bucket In PHP
PHP file_put_contents failed to open stream: Permission denied
Laravel 7.x Multiple Database Connections, Migrations, Relationships & Querying
GitHub Login With PHP Laravel Socialite
Why And How To Use PHP PDO With CRUD Examples
Generate Sitemap in PHP Laravel
Why namespace And use Keywords Used In PHP
Free Live Chat Integration Using TAWK.IO
Push Files To CPanel / Remote Server using FTP Software FileZilla
Create / Save / Download PDF From Blade Template In PHP Laravel
Use Different PHP Versions In Ubuntu / Linux
Route Model Binding In Laravel & Change Default Column id To Another Column