Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Passing Additional Parameter To Controller

Tags:

php

laravel

I need to pass an additional parameter($uid) from my index.blade.php to my edit.blade.php by clicking on a button.

My index.blade.php:

<a href="{!!action('FlyersController@edit', ['id' => Auth::user()->id, 'uid' => 1])!!}" type="button" class="btn btn-block btn-lg btn-info vorlageBtn card-link">Edit </a>

My FlyersController:

public function edit($id, $uid)
{

    return view('backend.flyers.edit')->withUid($uid);
}

With the code above I get an error: "Missing argument 2 for App\Http\Controllers\FlyersController::edit()"

What am I doing wrong here?

like image 720
Mamulasa Avatar asked Dec 01 '25 06:12

Mamulasa


1 Answers

The error is not throwing from the action method. It is coming from route for that URL.

Check the URL for passing argument to the the controller.

If this is the your desire URL localhost:8000/backend/flyers/10/edit?%24uid=1 then the second argument is in $request variable not in controller function argument.

like image 105
vinod rajput Avatar answered Dec 03 '25 20:12

vinod rajput



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!