我有以下功能
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链接。
我该如何解决这个问题?。
答案 0 :(得分:0)
请使用下面使用的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);