Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Trikucian's avatar

Passing two variables through a route

I am trying to pass two variables through the route that are then used in an if/else statement in the controller. When I try the following code I get an error saying that only 1 variable is detected from the view, not 2. What am I missing?

View (I know something about this routing is wrong, but not sure what):

ajax: '{{ route('this.conditions-datatable', $variable->id, true) }}'

note: "true" is referring to the value of the boolean variable I'm trying to pass into the controller.

Controller

    public function conditionsDatatable($variable_id, $boolean) {
       
    if($boolean == false) {
       //code goes here
    } else  if($boolean == true)  {
        //code goes here
    }

Thanks for any help!
0 likes
1 reply
rawilk's avatar

change it to an array:

ajax: '{{ route('this.conditions-datatable', ['variable_id' => $variable->id, 'boolean' => true]) }}'

Please or to participate in this conversation.