controller send html tags with replaced < >
I am using laravel 8 and yajra datatables to display data. I now have to output some data with html tags. However, the controller replaces all < and > with the html codes < and > I can't get my datatable script to display the tags correctly. How can I instruct the controller or the script how to deal with the tags? Adding {!! it does not work. Have anyone a idea how can i solve my problem?
Andreas
´´´
public function index( Request $request ) { if( $request->ajax() ) {
$tbl = ( new User )->table;
$query = User::select( sprintf( '%s.*', $tbl ) );
$table = Datatables::of( $query );
$table->addColumn( 'roles', function( $row ) {
$roles = '';
foreach( $row->roles as $key => $item ) {
$roles .= '<span class="badge badge-info">' . $item->title . '</span>';
}
return $roles;
} );
return $table->make( true );
}
return view( 'admin.users.index' );
}
´´´
in my js i get : <span class="badge badge-info">Admin</span>
´´´ columns: [ { data: 'name', name: 'name' }, { data: 'email', name: 'email' }, { data: 'roles', name: 'roles', render: function( data ) { return data; } } ], ´´´
Please or to participate in this conversation.