Hamza Qureshi
Hamza Qureshi

Reputation: 202

how to pass button from controller to view with url?

i am trying to pass button from controller to view here i tried this code

    function sendbutton (){

      $order = 1;
      return   '<a href="{{ url("user/order/geOrder/") . $order) }}" class="btn btn-primary" style="color:white">Edit Order</a>'
    }

it render successfully but problem is that my axpecting url should be "https://example.org/user/order/geOrder/1"

but i am getting url https://example.org/user/order/create/Order/by/%7B%7B%20url(

which is wrong we can also use

route('edit.order' , $order)

i dont know the method any help?

Upvotes: 0

Views: 346

Answers (1)

Rateb Habbab
Rateb Habbab

Reputation: 1789

First, you have some typo when calling the url you have an extra ) after $order. Second, when passing a string from controller to view there is no need to use {{}} to render variables, you must process it as a string and then pass it to view. I think your function should be like this:

function sendbutton (){
    $order = 1;
    $url = url("user/order/geOrder") . '/' . $order;
    return  '<a href="'. $url .'" class="btn btn-primary" style="color:white">Edit Order</a>';
}

Upvotes: 2

Related Questions