gpt4 book ai didi

php - Laravel 数据表不返回 html 链接

转载 作者:行者123 更新时间:2023-12-05 06:39:59 24 4
gpt4 key购买 nike

我有以下功能

public function getTasks()
{
$users = User::select(['id','users_full_names', 'email', 'users_telephone_number', 'users_credits', 'users_last_seen_carbon_object','users_profile_picture','updated_at']);

return Datatables::of($users)
->addColumn('action', function ($user) {
return '<a href="/edit/'.$user->id.'" class="btn btn-sm btn-primary"><i class="glyphicon glyphicon-edit"></i> Edit</a> <a href="/delete/'.$user->id.'" class="btn btn-sm btn-danger"><i class="glyphicon glyphicon-trash"></i> Delete</a> <a href="/moderate/'.$user->emp_no.'" class="btn btn-sm btn-primary"><i class="glyphicon glyphicon-ban-circle"></i> Moderate</a> <a href="/view/'.$user->emp_no.'" class="btn btn-sm btn-danger"><i class="glyphicon glyphicon-search"></i> View</a> <a href="/impersonate/'.$user->id.'" class="btn btn-sm btn-primary"><i class="glyphicon glyphicon-user"></i> Impersonate</a>';
})->editColumn('updated_at', function(User $user) {
$dt = $user->updated_at->toDateTimeString();
$datetime = Carbon::parse($dt);;
return $datetime->diffForHumans();
})->editColumn('users_profile_picture', function(User $user) {
$picture = $user->users_profile_picture;
return '<a href="'.url('uploads/'.$picture).'">View Image</a>';
})->make(true);
}

我正在使用它来获取存储在数据库中的图片。这是创建链接的特定部分

->editColumn('users_profile_picture', function(User $user) {
$picture = $user->users_profile_picture;
return '<a href="'.url('uploads/'.$picture).'">View Image</a>';
})->make(true);

但是生成的链接是这样的

<a href="http://198.74.51.225/uploads/1494677997.79843.jpg">View Image</a>

而不是可点击的 html 链接。

我该如何解决这个问题?

最佳答案

请使用下面使用的 rawColumns,

->editColumn('users_profile_picture', function(User $user) {
$picture = $user->users_profile_picture;
return '<a href="'.url('uploads/'.$picture).'">View Image</a>';
})->rawColumns(['users_profile_picture'])->make(true);

请引用,https://github.com/yajra/laravel-datatables/issues/949

关于php - Laravel 数据表不返回 html 链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43967589/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com