Try to send html from controller Laravel and data tables

Posted 2 years ago by Mahdi_Sahib

Summary of problem or feature request

I want send to the table some HTML tags like

I use editColumn to add some HTML code to this column

the question is how I can send HTML elements to table from controller the example above show the HTML tags when I need to view label

Code snippet of problem

public function CustomerTicketAjax(Request $request, $id)
    if ($request->ajax()) {
        $tickets = Customer::find($id);
        return Datatables::of(CustomerTicket::with('user')->where('customer_id', $tickets->id))

            ->editColumn('status', function ($tickets) {
                if ($tickets->status == 1) {
                    return '<span class="label bg-red" style="font-size: 21px;">open</span>';
                } elseif ($tickets->status == 0) {
                    return '<span class="label bg-red" style="font-size: 21px;">close</span>';

  • PHP 7.1
  • Laravel 5.4
  • Laravel-Datatables 7.*

Please sign in or create an account to participate in this conversation.