Laravel append URI in route
Created at 07-Sep-2021 ,
By samar
Laravel append URI in route
In this session, we are going to try to solve the "Laravel append URI in route" puzzle by using the computer language.
You can append URI in route using comma separated array value to route. You can redirect to generated query string URL using redirect on controller action and using anchor tag in view file-
Pass query string to url using named route in laravel
<?php <a href="{{ route('searchResult', ['keyword' => 'samar']) }}"> URL with query string </a> //OutputĀ <a href="http://localhost:8000/search/all?keyword=samar" target="_blank" rel="noopener">http://localhost:8000/search/all?keyword=samar</a> //Step by step code implementation //# Create route in web.php use App\Http\Controllers\SearchController; Route::get('/search/all/', [SearchController::class, 'getAllSearchResult'])->name('searchResult'); //Create SearchController if not exists with method getAllSearchResult php artisan make:controller SearchController //#Create controller method //app\Http\Controllers\SearchController.php <?php namespace App\Http\Controllers; use Illuminate\Http\Request; class SearchController extends Controller { public function getAllSearchResult(){ $getQueryString=\Request::fullUrl(); dd($getQueryString); } }
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: Laravel
- Extra Filter Query on Relationships in Laravel
- How to authenticate admin users in Laravel ?
- Route not defined in Laravel
- How to make Copy or Duplicate table row in laravel
- Where to use whereNotNull eloquent in laravel
- Syntax error or access violation: 1072 Key column 'role_id' doesn't exist in table (SQL: alter table `users` add constraint `users_role_id_foreign` foreign key (`role_id`) references `roles` (`id`))
- How to insert dynamic value to additional column in pivot table in laravel
- Permission denied error while creating storage link in Laravel
- Update existing pivot table data in laravel
- How to get session in blade Laravel ?
- How to display pivot table column value in laravel
- Undefined property: stdClass::$title
- Argument 1 passed to Illuminate\Database\Query\Builder::cleanBindings() must be of the type array, null given
- Convert input array to comma-separated string in laravel controller
- How to delete record in Laravel with ajax
- Laravel change date format
- Add a subselect based on relationship using withAggregate method
- How to check record exist or not in relationship table
- Laravel insert query not working
- Automatically remove records using Prunable trait in Laravel
- Method Illuminate\Events\Dispatcher::fire does not exist
- Call to undefined relationship [user] on model [App\Models\Post]
- How to customize pagination view in laravel
- Always load the relationship data with eager loading in Laravel
- How to get path from current URL in Laravel