Monday, March 13, 2017

Paasing value to the routes in laravel

I checked a lot questions in Stack overflow but i didn't find the answer so posting here.

I have a button like this in my view

 <a class = "btn btn-primary btn-flat" 
href = ""> Create New Tank</a>

And my web route like this

Route::resource('WaterTanks', 'WaterTankController');

And my controller method like this

public function create() {
        return view('WaterTanks.create');
    }

what I want is to pass variable in that route may be like this

<a class = "btn btn-primary btn-flat"  
href = ""> 
Create New Tank</a>

And get that variable in my controller method like this

public function create($type) {
        return view('WaterTanks.create')->with('type',$type);
    }

But that's not happening Showing this error

Call to a member function with() on string

So how can I do that



via Sanooj T

Advertisement