use*_*067 4 laravel-5 yajra-datatable
我在数据表中为这样的图像添加一列:
->addColumn('product_brand_logo', function ($product_brand) {
return '<img src="{{ URL::to('upload/image')'.$img->image.'" border="0" width="40" class="img-rounded" align="center" />';
Run Code Online (Sandbox Code Playgroud)
它没有在检查中输出输出
| {{ URL::to('upload/image')imagename.png}}|
Run Code Online (Sandbox Code Playgroud)
使用laravel 5.3,yajra 数据表 6.0
如果您使用的是数据表7.0
然后你可以使用rawColumns
如果您想呈现 html 内容,请使用 rawColumns api
return DataTables::of($artists)->addColumn('image', function ($artist) {
$url= asset('storage/'.$artist->image);
return '<img src="'.$url.'" border="0" width="40" class="img-rounded" align="center" />';
})->addColumn('action', function ($artist) {
return '<a href="/admin/artist/'.$artist->id.'/edit" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> Edit</a>
<a href="admin/artist/"'.$artist->id .'" class="btn btn-xs btn-danger"><i class="glyphicon glyphicon-trash"></i> Delete</a>';
})->rawColumns(['image', 'action'])->make(true);
Run Code Online (Sandbox Code Playgroud)
您没有关闭{{属性src,请尝试以下操作:
->addColumn('product_brand_logo', function ($product_brand) {
$url=asset("uploads/image/$product_brand->image");
return '<img src='.$url.' border="0" width="40" class="img-rounded" align="center" />';
});
Run Code Online (Sandbox Code Playgroud)