How to add an HTML column in Laravel Datatables?

How can I display HTML content in a column using Laravel Datatables? I want to add an HTML column with an “Edit” button that links to the user edit page.

return Datatables::of($users)->addColumn('edit', function($row){
    return '<a href="' . route('user.edit', $row->id) . '">Edit</a>';

I’m using the addColumn() function to add this column, but the problem is that the HTML tags in the column are being converted to special characters, so the button is not displayed properly. How can I modify my code and display the button with the correct HTML tags to prevent this?

You can use the rawColumns(). It tells Datatables that certain columns should be rendered as HTML and not escaped. You can pass an array of column names to this method, indicating which columns should not be escaped.

Here is a solution for you code.

return Datatables::of($users)
->addColumn('edit', function($row){
    return '<a href="' . route('user.edit', $row->id) . '">Edit</a>';