Laravel set value in get route

laravel routes
laravel get current route
laravel route::resource
laravel get route parameters in controller
laravel middleware
laravel request
laravel redirect
laravel route wildcard

I have one route which is accepting one argument perfectly as

  Route::get('view-request/type/{type}/id/{id}', 'CustomerReqController@testing')->name('request.manage');

and also call it in blade by this

<a href="{{route('request.manage',['type'=>'new','id'=>'data'])}}"

and the controller is

public function testing(Request $request,$type,$id){
    dd($request->all());
}

it gives me error

Missing required parameters for [Route: request.manage] [URI: admin/view-request/type/{type}/id/{id}]. (View: /var/www/html/ehs_crm_laravel/resources/views/common/navbar.blade.php) (View: /var/www/html/ehs_crm_laravel/resources/views/common/navbar.blade.php) (View: /var/www/html/ehs_crm_laravel/resources/views/common/navbar.blade.php)

What am i doing wrong?

use:

<a href="{{ route('request.manage', ['type' => 'new', 'id' => 'data']) }}">

HTTP Requests - Laravel, If you need to access a route parameter value outside of a route, you may use the Route::get('user', array('before' => 'old', function() { return 'You are over 200 You may also specify that a filter applies to an entire set of routes based on  There are the following list of the Laravel Route methodes. 1.Route::get ($uri, $callback); 2.Route::post ($uri, $callback); 3.Route::put ($uri, $callback); 4.Route::patch ($uri, $callback); 5.Route::delete ($uri, $callback); 6.Route::options ($uri, $callback); READ : PHP Laravel Get base url Examples.

you can get your route parameter by simply using this code. hope this will work for you. for Get and Post method both.

public function testing(Request $request)
{
    $type= $request->type;
    $id= $request->id;

}

Routing - Laravel, Make sure to give the route's corresponding variable a default value: To get started, assign the throttle middleware to a route or a group of routes. The throttle​  Then in your controller, set default values for those arguments: Laravel Route with 1 required and Optional unlimited parameters. Hot Network Questions

follow steps this code is working to me.

1 : declare route

Route::get('view-request/type/{type}/id/{id}', 'UserController@index')->name('request.manage');

2: create link

<a href="{{ route('request.manage', ['type'=>'test','id'=>6]) }}">Register</a>

3: get data in controller

public function index($type,$id,Request $request){
        echo $type;
        echo $id;

    }

Laravel set value in get route, use: <a href="{{ route('request.manage', ['type' => 'new', 'id' => 'data']) }}">. You may set values by passing an array of key / value pairs to the function: session(['chairs' => 7, 'instruments' => 3]); The session store will be returned if no value is passed to the function:

How to set a route parameter default value from request url in laravel, I have this routing settings: Route::prefix('admin/{storeId}')->group(function ($​storeId) { Route::get('/', 'DashboardController@index'); Route::ge Laravel comes with a few inbuilt middlewares for maintenance, authentication and CSRF protection, which are all found in the app/Http/Middleware directory inside a laravel project folder. Laravel Route Parameters. Laravel routes are located in the app/Http/routes.php file. A route usually has the URL path, and a handler function callback, which

Routing, Route::get($uri, $callback); Route::post($uri, $callback); Route::put($uri, $​callback); Make sure to give the route's corresponding variable a default value: Once the default value for the locale parameter has been set, you are no longer required to pass its value when generating URLs via the route helper. Become a Laravel Partner Laravel Partners are elite shops providing top-notch Laravel development and consulting.

Static route parameters in Laravel, Static route parameters can help you clean up your controller code and define fixed <?php // routes.php Route::get('/imprint', 'ContentController@imprint'); called defaults to set a default parameter value for a given route. If it is not present, Laravel will search for the field in the route parameters. Retrieving JSON Input Values When sending JSON requests to your application, you may access the JSON data via the input method as long as the Content-Type header of the request is properly set to application/json .

Comments
  • The second argument to route() should be an array with the values.
  • but when i made Route::get('delete-tagservicetolocation/{loc_id}/{ser_id}', 'LocationController@DeleteTagServicesToLocation')->name('tagservicetolocation.delete'); and it was working on this route
  • laravel.com/docs/5.7/helpers#method-route, laravel.com/docs/5.7/urls#urls-for-named-routes
  • @MagnusEriksson edited according but not working
  • Are you 100% sure that the above HTML is where that error actually occurs and that you're not calling route('request.manage', ...) from somewhere else as well?
  • what is then in blade is it the same or i have to edit it?
  • you can set this variables according to you by just passing in second parameter of view method. view('view', ['id'=>$id,'type'=>$type]);
  • The question isn't how to get the URL params. It's how to create a url from a named route using the route()-helper. Also, does the $request object really contain the passed route parameters? We're not talking about GET or POST params.