Milan AM
Milan AM

Reputation: 155

Link that passes parameters to Controller function

I currently have a view that is shared by two controller functions that pass in correct variables so i know where it is coming from.

I have a situation where I need URL references that can be clicked by the user that point to a function in both controllers that queries a Model and gets all the data from that model.

I am looking for some pointers on how to handle passing 2 parameters to the controller based on what the user clicked. I will post code to make this more understandable. Also, if I have a function that is querying the entire database, how can I use Query Scopes, so that if these parameters are passed to it, it doesnt query the entire database but instead uses my query scopes.

Here is the code for reference:

the View: http://pastebin.com/dWCEKztS

one of the controllers that I am working on first. The function that queries all of the rows of that Model: http://pastebin.com/LUbMLajs

In the Model, I tried to create these Query Scopes: http://pastebin.com/s30saqBL

So basically in the view, it displays certain names, and corresponding counts for each status. I have this all taken care of in that $totalCount data structure. I need to pass these to the index function so I can query only that certain data based off those parameters. The admin is in another table called admin, and in the advertiser application table there is an assigned_to field that links with that admin ID.

Please let me know if I need to clarify anything further!

Thanks

Upvotes: 1

Views: 77

Answers (1)

Michel
Michel

Reputation: 1165

Set the URL to pass variable with it, in your route.

route::get('/pageName/{variableName}', array('as' => 'page-name', 'uses' => 'yourControllerName@functionName'));

in controller:

public function functionName($variableName){

$get = Model::where('columnName', $variableName)->first();
}

Hope this help.

Upvotes: 2

Related Questions