我使用Laravel 4.如何跟踪用户在Laravel 4中的下载?
我在我的视图中有一个下载按钮。
我有很多users
有权访问see/click
从该按钮下载。
这里是我的问题,
有没有什么办法来保持how many
时间我的文件已经被下载和whom
轨道?
比方说,
- 用户A下载27次
- 用户B下载5次
- 用户C从来没有下载在所有
- 用户d下载200时间
所以等等......
我的C ontroller功能
public function file_download($id)
{
$catalog_download = CatalogDownload::findOrFail($id);
$distributor = Auth::user()->distributor()->first();
$export_type = $distributor->export_type()->first();
$product_export = $catalog_download->product_exports()->first();
$destinationPath = base_path().'/app/files/product_export/'. $catalog_download->id.'/'. $export_type->id.'/';
$file_name = $product_export->file_path;
$pathToFile = $destinationPath .$file_name;
return Response::download($pathToFile);
}
你能给我一个Ajax调用的快速示例代码吗?当你可以 - :)不必是正确的语法,伪代码很好。我只需要看看基本逻辑 - 如果我决定在Ajax中这样做。谢谢。我希望你能为我做到这一点。 – iori 2014-12-11 04:04:34
在这里你会找到一个:[ajax](http://api.jquery.com/jquery.ajax/) – baao 2014-12-11 04:14:54