title: how to pass variable to Cache::remember function
body: <p>Laravel docs give this example:</p>
  
  <pre><code>$value = Cache::remember('users', $minutes, function() {
      return DB::table('users')-&gt;get();
  });
  </code></pre>
  
  <p>In my case I have</p>
  
  <pre><code>public function thumb($hash, $extension)
  {
      Cache::remember('thumb-'.$hash, 15, function() {
          $image = Image::where('hash', $hash)-&gt;first();
      });
  </code></pre>
  
  <p>If I run that I get <code>ErrorException in ImageController.php line 69: Undefined variable: hash</code>. I tried to pass $hash to function like so:</p>
  
  <pre><code>Cache::remember('thumb-'.$hash, 15, function($hash)
  </code></pre>
  
  <p>but then got another error as below:</p>
  
  <blockquote>
    <p>Missing argument 1 for App\Http\Controllers\ImageController::App\Http\Controllers{closure}(), called in C:\xampp\htdocs\imagesharing\vendor\laravel\framework\src\Illuminate\Cache\Repository.php on line 316 and defined</p>
  </blockquote>
  
  <p>How do I pass argument so I can use it in my query?</p>