How should I call a route from the href link(along with sending a id with it).

How should I call a route from the href link(along with sending a id with it).

lav1lav1 Posts: 1Questions: 1Answers: 0

This is the HTML code

<td><a href="{{ url('/transaction_detail',($orders->id)) }}">{{$orders->id}}</a></td>

what we want to do is that we want to send a route from the controller side. How we send a href url(('/transaction_detail',($orders->id))) to the controller.

$orderdetail[$key]->tripId = '<td><a href=" ">'.$value->trip_transaction_id.'</a></td>';

I am using a data table that is why to send it from the controller side.

I have to send it to the controller.

{{ url('/transaction_detail',($orders->id)) }}
if(!empty($orderdetail)){
    foreach ($orderdetail as $key => $value){
        $orderdetail[$key]->tripId = '<td><a href=" ">'.$value->trip_transaction_id.'</a></td>';
    }
}
$data = array(
    'draw' => $draw,
    'data' => $orderdetail
);
return json_encode($data);

Answers

  • allanallan Posts: 63,195Questions: 1Answers: 10,412 Site admin

    If I understand the code correctly, you are creating the HTML for the table server-side and drawing that on the page. I presume you are then initialising DataTables on that HTML table? If you have a link to your page that would be a great help.

    It sounds like you need to use a query parameter in the href url - e.g.:

    <a href="/my/controller/route?id=4">4</a>
    

    Is that correct?

    Allan

This discussion has been closed.