在按钮上单击运行功能并返回文件

My project shares images and the users are allowed to download X amount of images each month.

Currently I'm able to do both of these functions, but I can't do them at the same time. I need to:

  1. Return the requested file for download, it's an image so it can't open in new window.

  2. Decrement or run a function that captures what image was downloaded.

Currently my view looks like this:

@foreach($images as $image)
        <h3 class="panel-title">Image Name</h3>
      <i>{{$image->img_tags}}</i>
          <a class="btn btn-default" href="{{ $image->img_url)}}" download role="button"><span class="glyphicon glyphicon-download-alt" aria-hidden="true"></span> Download</a>
    @endforeach

So it works, it returns the file I want.

But I also want to be able to run this function which is currently in my routes:

Route::get('download', function()
{
 DB::table('users')->decrement('downloads', 1);
});

I've tried using response::download in my route however since the images are stored on S3 it won't work.