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 “”

but i am getting url

which is wrong
we can also use

route('edit.order' , $order)

i dont know the method any help?


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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>';

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x