I am facing one problem i want to save data after downloading an image. My image has been successfully downloaded after that i want to maintain the history of downloads.Here is my Function:-
enter code here
public function UserImageDownlaod($userid=null,$imageid=null){
$imagedata = DB::table('alt_images')->where('id',$imageid)->first();
$imagedata = json_decode(json_encode($imagedata),true);
$destination = 'images/ContributorImages'.'/';
$pathToFile = $destination.$imagedata['img'];
return response()->download($pathToFile);
//Now i want to save the history of downloaded images
$history= new DownloadHistory;
$history->user_id = Auth::user()->id;
$history->alt_image_id = $imageid;
$history->save();
}
Now you can see after this return response()->download($pathToFile) line i want to save the history data. I want when User click on OK button then data will saved on history table. Can anyone help me.